Skip to content

Commit

Permalink
Change up First() a bit here
Browse files Browse the repository at this point in the history
  • Loading branch information
marchc1 committed Dec 27, 2024
1 parent db9870b commit 8c9711c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lua/ponder/instructions_cl/ponder.placemodel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ PlaceModel.ComeFrom = Vector(0, 0, 32)
PlaceModel.RotateFrom = Angle(0, 0, 0)
PlaceModel.Time = 0
PlaceModel.Length = .5
PlaceModel.LocalPos = true
PlaceModel.LocalTransform = true

function PlaceModel:Preload()
util.PrecacheModel(self.Model)
end

function PlaceModel:First(playback)
local env = playback.Environment
local mdl = env:NewModel(self.Model, self.Name)
local mdl = env:NewModel(self.Model, self.Name, true)
if self.ParentTo then
local parent = env:GetNamedModel(self.ParentTo)
if IsValid(parent) then
Expand All @@ -24,14 +24,25 @@ function PlaceModel:First(playback)
Ponder.Print("Can't parent; parent target not found")
end
end

if self.LocalTransform then
local p, a = LocalToWorld(self.ComeFrom, self.RotateFrom, self.Position, self.Angles)
mdl:SetPos(p)
mdl:SetAngles(a)
else
mdl:SetPos(self.Position + self.ComeFrom)
mdl:SetAngles(self.Angles + self.RotateFrom)
end

mdl:Spawn()
end

function PlaceModel:Update(playback)
local env = playback.Environment
local progress = math.ease.OutQuad(playback:GetInstructionProgress(self))
local object = env:GetNamedModel(self.Name)

if self.LocalPos then
if self.LocalTransform then
local p, a = LocalToWorld(
LerpVector(progress, self.ComeFrom, vector_origin),
LerpAngle(progress, self.RotateFrom, angle_zero),
Expand Down

0 comments on commit 8c9711c

Please sign in to comment.