Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lua/entities/gmod_wire_expression2/core/custom/cl_prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ E2Helper.Descriptions["setPos(e:v)"] = "Sets the position of an entity."
E2Helper.Descriptions["reposition(e:v)"] = "Deprecated. Kept for backwards-compatibility."
E2Helper.Descriptions["setAng(e:a)"] = "Set the rotation of an entity."
E2Helper.Descriptions["rerotate(e:a)"] = "Deprecated. Kept for backwards-compatibility."
E2Helper.Descriptions["setPosInterpolated(e:v)"] = "Sets the position of an entity with interpolation."
E2Helper.Descriptions["setAngInterpolated(e:a)"] = "Set the rotation of an entity with interpolation."
E2Helper.Descriptions["parentTo(e:e)"] = "Parents one entity to another."
E2Helper.Descriptions["parentTo(e:)"] = E2Helper.Descriptions["parentTo(e:e)"]
E2Helper.Descriptions["deparent(e:)"] = "Unparents an entity, so it moves freely again."
Expand Down
20 changes: 17 additions & 3 deletions lua/entities/gmod_wire_expression2/core/custom/prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,18 @@ function PropCore.CreateProp(self,model,pos,angles,freeze,isVehicle)
return prop
end

function PropCore.PhysManipulate(this, pos, rot, freeze, gravity, notsolid)
function PropCore.PhysManipulate(this, pos, rot, freeze, gravity, notsolid, interpolate)
if pos ~= nil and not interpolate then WireLib.setPos( this, Vector( pos[1],pos[2],pos[3] ) ) end
if rot ~= nil and not interpolate then WireLib.setAng( this, Angle( rot[1],rot[2],rot[3] ) ) end

local phys = this:GetPhysicsObject()
if IsValid( phys ) then
if pos ~= nil then WireLib.setPos( phys, Vector( pos[1],pos[2],pos[3] ) ) end
if rot ~= nil then WireLib.setAng( phys, Angle( rot[1],rot[2],rot[3] ) ) end
if pos ~= nil and interpolate then WireLib.setPos( phys, Vector( pos[1],pos[2],pos[3] ) ) end
if rot ~= nil and interpolate then WireLib.setAng( phys, Angle( rot[1],rot[2],rot[3] ) ) end
if freeze ~= nil and this:GetUnFreezable() ~= true then phys:EnableMotion( freeze == 0 ) end
if gravity ~= nil then phys:EnableGravity( gravity ~= 0 ) end
if notsolid ~= nil then this:SetSolid( notsolid ~= 0 and SOLID_NONE or SOLID_VPHYSICS ) end

phys:Wake()
end
end
Expand Down Expand Up @@ -445,6 +449,16 @@ end

e2function void entity:rerotate(angle rot) = e2function void entity:setAng(angle rot)

e2function void entity:setPosInterpolated(vector pos)
if not PropCore.ValidAction(self, this, "pos") then return end
PropCore.PhysManipulate(this, pos, nil, nil, nil, nil, true)
end

e2function void entity:setAngInterpolated(angle rot)
if not PropCore.ValidAction(self, this, "ang") then return end
PropCore.PhysManipulate(this, nil, rot, nil, nil, nil, true)
end

--------------------------------------------------------------------------------

local function parent_check( child, parent )
Expand Down