Big elevator refactoring

This commit is contained in:
2024-05-11 00:03:21 -04:00
parent 17193ac908
commit 73045d5bf6
9 changed files with 272 additions and 142 deletions

View File

@@ -11,6 +11,8 @@ local Tween = require(Storage:WaitForChild("Tween"))
local Tags = require(LoadDir:WaitForChild("Tags"))
local Enums = require(Storage:WaitForChild("Enums"))
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
type rbxassetid = string
type TagProduct = Tags.TagProduct
@@ -32,17 +34,34 @@ type Impl_Static_Props = {
LightTweenTime: number
}
type Constructor_Fun = (MainDisplay: UnionOperation, ChimeDirectionID: rbxassetid, ChimeLandingID: rbxassetid, Lanterns: Tags.Lanterns, Colors: Colors) -> ClassConstructor
type Constructor_Fun = (MainDisplay: UnionOperation, LanternsMap: Tags.Lanterns, ElevatorSounds: ElevatorSounds, Colors: ElevatorButtonColors) -> ClassConstructor
type Constructor_Return_Props = {
LanternsMap: Tags.Lanterns,
AudioChimeDirection: Sound,
AudioChimeLanding: Sound,
Colors: Colors
Colors: ElevatorButtonColors
}
export type Colors = {
Active: Color3,
Off: Color3
type ElevatorAttributes = {
PassingFloor: IntValue,
Moving: BoolValue,
CurrentFloor: IntValue
}
type ElevatorEvents = {
ButtonActivated: BindableEvent
}
type ElevatorButtonColors = {
ButtonActivated: Color3,
ButtonDeactivated: Color3,
LanternDisplayOn: Color3,
LanternDisplayOff: Color3,
}
type ElevatorSounds = {
LanternChimeDirection: SoundEnums.Otis1960LanternChimeDirection,
LanternChimeLanding: SoundEnums.Otis1960LanternChimeLanding,
}
export type LanternsConstructor = ClassConstructor
@@ -53,12 +72,12 @@ Lanterns.__index = Lanterns
Lanterns.Volume = .5
Lanterns.LightTweenTime = 1
function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, LanternsMap, Colors)
function Lanterns.constructor(MainDisplay, LanternsMap, ElevatorSounds, Colors)
local AudioChimeDirection = Instance.new("Sound") :: Sound
AudioChimeDirection.SoundId = ChimeDirectionID
AudioChimeDirection.SoundId = ElevatorSounds.LanternChimeDirection
AudioChimeDirection.Volume = Lanterns.Volume
local AudioChimeLanding = Instance.new("Sound") :: Sound
AudioChimeLanding.SoundId = ChimeLandingID
AudioChimeLanding.SoundId = ElevatorSounds.LanternChimeLanding
AudioChimeLanding.Volume = Lanterns.Volume
AudioChimeDirection.Parent = MainDisplay
@@ -76,7 +95,7 @@ local LanternLight = Tween.constructor(TweenInfo.new(Lanterns.LightTweenTime))
function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern, Chime)
local Tween = LanternLight:Start(Lantern.Light, {
Color = EnabledState and self.Colors.Active or self.Colors.Off
Color = EnabledState and self.Colors.LanternDisplayOn or self.Colors.LanternDisplayOff
})
if EnabledState then
@@ -93,7 +112,7 @@ function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern, Chime)
if Lantern.PointLight then
Lantern.PointLight.Enabled = true
LanternLight:Start(Lantern.PointLight, {
Color = self.Colors.Active
Color = self.Colors.LanternDisplayOn
})
end
else