mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
move lanterns directory into system
This commit is contained in:
63
src/server/main/Elevators/System/Lanterns/Arrows.luau
Normal file
63
src/server/main/Elevators/System/Lanterns/Arrows.luau
Normal 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
|
||||
Reference in New Issue
Block a user