move lanterns directory into system

This commit is contained in:
2024-09-11 15:55:27 -04:00
parent 35fdaf56a9
commit 80b0edeca8
3 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,63 @@
--!optimize 2
--!strict
local MainDir = script.Parent.Parent.Parent
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
local TS = game:GetService("TweenService")
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
Toggle: (self: ClassConstructor, OnState: boolean, UpDirection: boolean) -> Tween?,
Off: (self: ClassConstructor) -> (Tween?, Tween?),
}
type Constructor_Fun = (Lanterns: TagsModule.Lanterns, ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable) -> ClassConstructor
type Constructor_Return_Props = {
Lanterns: TagsModule.Lanterns,
ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable
}
local ArrowLanterns = {} :: Impl_Constructor
ArrowLanterns.__index = ArrowLanterns
function ArrowLanterns.constructor(Lanterns, ElevatorConfig)
return setmetatable({
Lanterns = Lanterns,
ElevatorConfig = ElevatorConfig
}, ArrowLanterns)
end
function ArrowLanterns:Toggle(OnState, UpDirection)
local LanternType = UpDirection and self.Lanterns.Up or self.Lanterns.Down
if LanternType then
--mega boolean short circuit
local ConfigState = OnState and (UpDirection and self.ElevatorConfig.Lanterns.On.Up or self.ElevatorConfig.Lanterns.On.Down) or (UpDirection and self.ElevatorConfig.Lanterns.Off.Up or self.ElevatorConfig.Lanterns.Off.Down)
LanternType.Inst.Material = ConfigState.Material
local TweenTime = TweenInfo.new(ConfigState.Time)
local UpArrowTween = TS:Create(LanternType.Inst, TweenTime, {
Color = ConfigState.Color
})
UpArrowTween:Play()
TS:Create(LanternType.PointLight, TweenTime, {
Brightness = OnState and 1 or 0
}):Play()
return UpArrowTween
else
warn(`[{self.ElevatorConfig.Name}]: Could not toggle a direction lantern. UpDirection={UpDirection} OnState={OnState}, LaternType={LanternType}`)
end
return nil
end
function ArrowLanterns:Off()
return self:Toggle(false, true), self:Toggle(false, false)
end
return ArrowLanterns