Forgot staged files

This commit is contained in:
Иван Грачёв
2021-06-06 21:57:41 +05:00
parent bacc7c617f
commit e893f7fcb2
4 changed files with 230 additions and 6 deletions

View 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