Forgot staged files
This commit is contained in:
47
koptilnya/car_systems/entities/light.txt
Normal file
47
koptilnya/car_systems/entities/light.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
-- @shared
|
||||
-- @name Light
|
||||
-- @include ../helpers/helpers.txt
|
||||
require("../helpers/helpers.txt")
|
||||
|
||||
Light = class("Light")
|
||||
|
||||
function Light:initialize(params)
|
||||
self.target = 0
|
||||
self.entity = params.Entity
|
||||
self.colors = params.Colors
|
||||
self.lerpSpeed = params.LerpSpeed or 0.2
|
||||
self.active = false
|
||||
|
||||
self.entity:setColor(self.colors.Off)
|
||||
self.entity:suppressEngineLighting(true)
|
||||
end
|
||||
|
||||
|
||||
function Light:_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 Light:setActive(val)
|
||||
self.active = val
|
||||
end
|
||||
|
||||
|
||||
function Light:use(val)
|
||||
self.target = val or 0
|
||||
end
|
||||
|
||||
|
||||
function Light:update()
|
||||
self:_process()
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user