mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-17 05:51:54 +00:00
TagService -> Tags and more refactoring, close to working again
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
|
||||
local ElevatorsDir = script.Parent
|
||||
local MainDir = ElevatorsDir.Parent
|
||||
local TagService = require(MainDir:WaitForChild("TagService"))
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local TagsModule = require(Storage:WaitForChild("Tags"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
local TagsModule = require(MainDir:WaitForChild("Tags"))
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
type TagsConstructor = TagsModule.TagsConstructor
|
||||
type TagProduct = TagsModule.TagProduct
|
||||
@@ -21,7 +21,7 @@ type Impl_Constructor = {
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
|
||||
CreatePromptButtons: (self: ClassConstructor) -> TagService.ButtonsTree,
|
||||
CreatePromptButtons: (self: ClassConstructor) -> TagsModule.ButtonsTree,
|
||||
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedState: boolean, ActivatedColor: Color3) -> ()
|
||||
} & Impl_Static_Props
|
||||
|
||||
@@ -33,7 +33,7 @@ type Constructor_Fun = (TagsConstructor: TagsConstructor, Model: Enums.ElevatorV
|
||||
type Constructor_Return_Props = {
|
||||
Tags: TagsConstructor,
|
||||
Model: Enums.ElevatorValues,
|
||||
Buttons: TagService.ButtonsTree
|
||||
Buttons: TagsModule.ButtonsTree
|
||||
}
|
||||
|
||||
export type ButtonsConstructor = ClassConstructor
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local ElevatorDir = script.Parent
|
||||
local MainDir = ElevatorDir.Parent
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Tags = require(Storage:WaitForChild("Tags"))
|
||||
local Tags = require(MainDir:WaitForChild("Tags"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
type rbxassetid = string
|
||||
@@ -14,7 +17,7 @@ type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Lanterns,
|
||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Tags.Lanterns,
|
||||
--Class functions
|
||||
Activate: (self: ClassConstructor, EnabledState: boolean, IsDirectionLantern: boolean, Lantern: Lantern) -> (),
|
||||
DirectionUp: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||
@@ -24,12 +27,13 @@ type Impl_Constructor = {
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
Volume: number
|
||||
Volume: number,
|
||||
LightTweenTime: number
|
||||
}
|
||||
|
||||
type Constructor_Fun = (MainDisplay: UnionOperation, ChimeDirectionID: rbxassetid, ChimeLandingID: rbxassetid, Lanterns: Lanterns, Colors: Colors) -> ClassConstructor
|
||||
type Constructor_Fun = (MainDisplay: UnionOperation, ChimeDirectionID: rbxassetid, ChimeLandingID: rbxassetid, Lanterns: Tags.Lanterns, Colors: Colors) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
LanternsMap: Lanterns,
|
||||
LanternsMap: Tags.Lanterns,
|
||||
AudioChimeDirection: Sound,
|
||||
AudioChimeLanding: Sound,
|
||||
Colors: Colors
|
||||
@@ -41,12 +45,6 @@ type Lantern = {
|
||||
Played: boolean
|
||||
}
|
||||
|
||||
type Lanterns = {
|
||||
[number]: Lantern,
|
||||
Up: Lantern,
|
||||
Down: Lantern
|
||||
}
|
||||
|
||||
export type Colors = {
|
||||
Active: Color3,
|
||||
Off: Color3
|
||||
@@ -57,7 +55,8 @@ export type LanternsConstructor = ClassConstructor
|
||||
local Lanterns = {} :: Impl_Constructor
|
||||
Lanterns.__index = Lanterns
|
||||
|
||||
Lanterns.Volume = .8
|
||||
Lanterns.Volume = .5
|
||||
Lanterns.LightTweenTime = 1
|
||||
|
||||
function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, LanternsMap, Colors)
|
||||
local AudioChimeDirection = Instance.new("Sound") :: Sound
|
||||
@@ -78,7 +77,7 @@ function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, Lan
|
||||
}, Lanterns)
|
||||
end
|
||||
|
||||
local LanternLight = Tween.constructor(TweenInfo.new(1))
|
||||
local LanternLight = Tween.constructor(TweenInfo.new(Lanterns.LightTweenTime))
|
||||
|
||||
function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
local Tween = LanternLight:Start(Lantern.Light, {
|
||||
@@ -97,10 +96,14 @@ function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
end
|
||||
|
||||
function Lanterns:Reset()
|
||||
self.LanternsMap.Up.Played = false
|
||||
self.LanternsMap.Down.Played = false
|
||||
self:Activate(false, true, self.LanternsMap.Up)
|
||||
self:Activate(false, true, self.LanternsMap.Down)
|
||||
if self.LanternsMap.Up then
|
||||
self.LanternsMap.Up.Played = false
|
||||
self:Activate(false, true, self.LanternsMap.Up)
|
||||
end
|
||||
if self.LanternsMap.Down then
|
||||
self.LanternsMap.Down.Played = false
|
||||
self:Activate(false, true, self.LanternsMap.Down)
|
||||
end
|
||||
|
||||
for n: number = 1, #self.LanternsMap do
|
||||
self:Activate(false, false, self.LanternsMap[n])
|
||||
@@ -109,14 +112,14 @@ function Lanterns:Reset()
|
||||
end
|
||||
|
||||
function Lanterns:DirectionUp(Enabled)
|
||||
if not self.LanternsMap.Up.Played then
|
||||
if self.LanternsMap.Up and not self.LanternsMap.Up.Played then
|
||||
self.LanternsMap.Up.Played = true
|
||||
self:Activate(Enabled, true, self.LanternsMap.Up)
|
||||
end
|
||||
end
|
||||
|
||||
function Lanterns:DirectionDown(Enabled)
|
||||
if not self.LanternsMap.Down.Played then
|
||||
if self.LanternsMap.Down and not self.LanternsMap.Down.Played then
|
||||
self.LanternsMap.Down.Played = true
|
||||
self:Activate(Enabled, true, self.LanternsMap.Down)
|
||||
end
|
||||
|
||||
@@ -8,8 +8,7 @@ local MainDir = Elevators.Parent
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RS: RunService = game:GetService("RunService")
|
||||
|
||||
local TagsModule = require(Storage:WaitForChild("Tags"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
local Leveling = require(script:WaitForChild("Leveling"))
|
||||
local Doors = require(script:WaitForChild("Doors"))
|
||||
@@ -21,12 +20,12 @@ local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
|
||||
local Lanterns = require(Elevators:WaitForChild("Lanterns"))
|
||||
|
||||
local PromptModule = require(MainDir:WaitForChild("Map"):WaitForChild("Prompts"))
|
||||
local TagService = require(MainDir:WaitForChild("TagService"))
|
||||
local Tags = require(MainDir:WaitForChild("Tags"))
|
||||
|
||||
type rbxassetid = string
|
||||
|
||||
type Tags = TagsModule.ExportedTags
|
||||
type TagsConstructor = TagsModule.TagsConstructor
|
||||
type Tags = Tags.ExportedTags
|
||||
type TagsConstructor = Tags.TagsConstructor
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
@@ -49,7 +48,7 @@ type Impl_Static_Props = {
|
||||
__CurrentFloor: number
|
||||
}
|
||||
|
||||
type Constructor_Fun = (TagsConstructor: TagsConstructor, TagServiceConstructor: TagService.TagsServiceConstructor) -> ClassConstructor
|
||||
type Constructor_Fun = (TagsConstructor: TagsConstructor, ButtonsTags: Tags.ButtonsTree, LanternsTags: Tags.Lanterns) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
Tags: Tags,
|
||||
MOConstructor: MovingObjects.MovingObjectsConstructor,
|
||||
@@ -73,7 +72,10 @@ type Constructor_Return_Props = {
|
||||
__MovingConnection: RBXScriptConnection?,
|
||||
}
|
||||
|
||||
type ButtonFunction = (self: ClassConstructor, ButtonName: string, ButtonsConstructor: ButtonTags.ButtonsConstructor, ButtonTree: ButtonTags.ButtonProperties) -> ()
|
||||
type ButtonFunction = (self: ClassConstructor, ButtonName: string, ButtonsConstructor: ButtonTags.ButtonsConstructor, ButtonTree: Tags.ButtonProperties) -> ()
|
||||
type ButtonFunctions = {
|
||||
[Enums.ButtonTreeValues]: ButtonFunction
|
||||
}
|
||||
|
||||
local Otis1960 = {} :: Impl_Constructor
|
||||
Otis1960.__index = Otis1960
|
||||
@@ -89,13 +91,13 @@ Otis1960.LanternChimeLanding = "rbxassetid://16990290265"
|
||||
Otis1960.__Moving = false
|
||||
Otis1960.__CurrentFloor = 1
|
||||
|
||||
local ButtonFunctions: {[Enums.ButtonTreeValues]: ButtonFunction} = {
|
||||
local ButtonFunctions: ButtonFunctions = {
|
||||
[Enums.ButtonTree.Landing] = function(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
|
||||
end,
|
||||
|
||||
[Enums.ButtonTree.Car] = function(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
local DecodedFloor = TagService.Decoder.CarTag(ButtonName)
|
||||
local DecodedFloor = Tags.Decoders.CarTag(ButtonName)
|
||||
if not DecodedFloor then
|
||||
|
||||
end
|
||||
@@ -134,7 +136,7 @@ local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTag
|
||||
end
|
||||
end
|
||||
|
||||
function Otis1960.constructor(TagsConstructor, TagServiceConstructor)
|
||||
function Otis1960.constructor(TagsConstructor, ButtonsTags, LanternsTags)
|
||||
local self = {} :: Constructor_Return_Props
|
||||
self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||
self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
|
||||
@@ -155,10 +157,10 @@ function Otis1960.constructor(TagsConstructor, TagServiceConstructor)
|
||||
self.MOConstructor = MovingObjects.constructor({MachineRoom = self.MachineRoom} :: MovingObjects.InstanceTree)
|
||||
|
||||
--Audio
|
||||
local LanternDisplay = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation
|
||||
local LaternTags = TagServiceConstructor:Lanterns(Enums.Elevator.Otis1960) :: TagService.Lanterns
|
||||
local LanternDisplay = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation
|
||||
local LanternTags = TagsConstructor:ElevatorLanterns()[Enums.Elevator.Otis1960]
|
||||
|
||||
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LaternTags, {
|
||||
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LanternTags, {
|
||||
Active = Otis1960.LanternDisplayColorOn,
|
||||
Off = Otis1960.LanternDisplayColorOff
|
||||
} :: Lanterns.Colors)
|
||||
@@ -177,7 +179,7 @@ function Otis1960.constructor(TagsConstructor, TagServiceConstructor)
|
||||
local ClassConstructor = setmetatable(self, Otis1960)
|
||||
HookButtons(ClassConstructor, ButtonsConstructor, Enums.ButtonTree.Car)
|
||||
|
||||
print("[DEBUG] Otis1960 Lanterns=", LaternTags)
|
||||
print("[DEBUG] Otis1960 Lanterns=", LanternTags)
|
||||
print("[DEBUG] Otis1960 Buttons=", Otis1960_Buttons)
|
||||
print("🔝 Otis1960 initialized and ready")
|
||||
return ClassConstructor
|
||||
|
||||
Reference in New Issue
Block a user