Implementing light system
This commit is contained in:
parent
9ff9b08a42
commit
bacc7c617f
42
koptilnya/car_systems/entities/animated_light.txt
Normal file
42
koptilnya/car_systems/entities/animated_light.txt
Normal file
@ -0,0 +1,42 @@
|
||||
-- @shared
|
||||
-- @name Animated light
|
||||
-- @include ../../helpers/helpers.txt
|
||||
require("../helpers/helpers.txt")
|
||||
|
||||
-- this entity implements composite pattern
|
||||
AnimatedLight = class("AnimatedLight")
|
||||
|
||||
function AnimatedLight:new(cfg)
|
||||
self.keyframes = cfg.keyframes
|
||||
|
||||
end
|
||||
|
||||
|
||||
function AnimatedLight:_process()
|
||||
local targetColor = self.colors.Off
|
||||
|
||||
if self.active == true and self.colors.Active then
|
||||
targetColor = self.target > 0 and self.colors.On or self.colors.Active
|
||||
elseif self.target > 0 then
|
||||
targetColor = self.colors.On
|
||||
end
|
||||
|
||||
self.entity:setColor(lerpColor(self.lerpSpeed, self.entity:getColor(), targetColor))
|
||||
end
|
||||
|
||||
|
||||
function AnimatedLight:setActive(val)
|
||||
self.active = val
|
||||
end
|
||||
|
||||
|
||||
function AnimatedLight:use(val)
|
||||
self.target = val or 0
|
||||
end
|
||||
|
||||
|
||||
function AnimatedLight:update()
|
||||
self:_process()
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user