-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Proper Clipping compatibility
- Fixed the physclipped entity recalculation bit, now it'll use the correct hooks. - Replaced some hijacked Proper Clipping functions with their intended hooks. - Reverted use of ACF.Check instead of IsValid on the contraption library.
- Loading branch information
1 parent
e2bb9d8
commit f30735c
Showing
3 changed files
with
44 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,50 @@ | ||
-- Resolves issues with properClipping | ||
-- Triggers an ACF.Activate update whenever a new clip is created or removed | ||
local hook = hook | ||
local ACF = ACF | ||
|
||
local timerSimple = timer.Simple | ||
do -- Triggers an ACF.Activate update whenever a new physical clip is created or removed | ||
local timer = timer | ||
|
||
local function activate(ent) | ||
if ent._ACF_ProperClipping then return end | ||
local function Update(Entity) | ||
if Entity._ACF_Physclip_Update then return end | ||
|
||
ent._ACF_ProperClipping = true | ||
Entity._ACF_Physclip_Update = true | ||
|
||
timerSimple(engine.TickInterval() * 2, function() | ||
if not IsValid(ent) then return end | ||
timer.Simple(0, function() | ||
if not IsValid(Entity) then return end | ||
|
||
ent._ACF_ProperClipping = nil | ||
Entity._ACF_Physclip_Update = nil | ||
|
||
ACF.Activate(ent, true) | ||
end) | ||
ACF.Activate(Entity, true) | ||
end) | ||
end | ||
|
||
hook.Add("ProperClippingPhysicsClipped", "ACF", Update) | ||
hook.Add("ProperClippingPhysicsReset", "ACF", Update) | ||
end | ||
|
||
hook.Add("ProperClippingClipAdded", "ACF", activate) | ||
hook.Add("ProperClippingClipRemoved", "ACF", activate) | ||
do -- Forces an ACF armored entity to get rid of their mass entity modifier and use the ACF_Armor one instead | ||
local duplicator = duplicator | ||
|
||
local function UpdateMass(Entity) | ||
local EntMods = Entity.EntityMods | ||
|
||
if not EntMods then return end | ||
|
||
local Armor = EntMods.ACF_Armor | ||
|
||
if Armor and Armor.Thickness then | ||
local MassMod = EntMods and EntMods.mass | ||
|
||
if MassMod then | ||
duplicator.ClearEntityModifier(Entity, "ACF_Armor") | ||
duplicator.StoreEntityModifier(Entity, "ACF_Armor", { Ductility = Armor.Ductility }) | ||
else | ||
duplicator.ClearEntityModifier(Entity, "mass") | ||
end | ||
end | ||
end | ||
|
||
hook.Add("ProperClippingClipAdded", "ACF", UpdateMass) | ||
hook.Add("ProperClippingClipRemoved", "ACF", UpdateMass) | ||
hook.Add("ProperClippingClipsRemoved", "ACF", UpdateMass) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters