components/colourtweener.lua
131415161718192021222324
self.time = nil
self.timepassed = 0
end)
function ColourTweener:EndTween()
--Set all values to final values
if self.t_colour_r and self.t_colour_g and self.t_colour_b then
self.inst.AnimState:SetMultColour(self.t_colour_r, self.t_colour_g, self.t_colour_b, self.t_alpha)
end
13141516171819202122232425262728293031
self.time = nil
self.timepassed = 0
self.tweening = false
end)
function ColourTweener:IsTweening()
return self.tweening
end
function ColourTweener:EndTween()
--Set all values to final values
if self.t_colour_r and self.t_colour_g and self.t_colour_b and self.t_alpha then
self.inst.AnimState:SetMultColour(self.t_colour_r, self.t_colour_g, self.t_colour_b, self.t_alpha)
end
25262728293031
if self.callback then
self.callback(self.inst)
end
self.inst:PushEvent("colourtweener_end")
self.inst:StopUpdatingComponent(self)
end
32333435363738
if self.callback then
self.callback(self.inst)
end
self.tweening = false
self.inst:PushEvent("colourtweener_end")
self.inst:StopUpdatingComponent(self)
end
52535455565758
self.time = time
self.timepassed = 0
self.inst:PushEvent("colourtweener_start")
if self.time > 0 then
self.inst:StartUpdatingComponent(self)
else
59606162636465
self.time = time
self.timepassed = 0
self.inst:PushEvent("colourtweener_start")
self.tweening = true
if self.time > 0 then
self.inst:StartUpdatingComponent(self)
else
636465666768697071727374757677787980
function ColourTweener:OnUpdate(dt)
self.timepassed = self.timepassed + dt
local t = self.timepassed/self.time
if self.i_colour_r and self.t_colour_r and
self.i_colour_g and self.t_colour_g and
self.i_colour_b and self.t_colour_b and
self.i_alpha and self.t_alpha then
self.inst.AnimState:SetMultColour(
Lerp(self.i_colour_r, self.t_colour_r, t),
Lerp(self.i_colour_g, self.t_colour_g, t),
Lerp(self.i_colour_b, self.t_colour_b, t),
Lerp(self.i_alpha, self.t_alpha, t))
end
if self.timepassed >= self.time then
70717273747576777879808182838485868788
function ColourTweener:OnUpdate(dt)
self.timepassed = self.timepassed + dt
local t = self.timepassed/self.time
if t > 1 then
t = 1
end
if self.i_colour_r and self.t_colour_r and
self.i_colour_g and self.t_colour_g and
self.i_colour_b and self.t_colour_b and
self.i_alpha and self.t_alpha then
self.inst.AnimState:SetMultColour(
Lerp(self.i_colour_r, self.t_colour_r, t),
Lerp(self.i_colour_g, self.t_colour_g, t),
Lerp(self.i_colour_b, self.t_colour_b, t),
Lerp(self.i_alpha, self.t_alpha, t))
end
if self.timepassed >= self.time then