Sounds and working

This commit is contained in:
2024-08-23 00:54:46 -04:00
parent b6bb2bddf1
commit 7a2169ea4a
8 changed files with 302 additions and 106 deletions

View File

@@ -73,20 +73,26 @@ export type Attributes = {
}
export type Events = {
Progression: RBXScriptSignal<number, number, number>,
Traveling: RBXScriptSignal<number, Vector3>,
Parked: RBXScriptSignal,
Leveling: RBXScriptSignal,
Progression: RBXScriptSignal<number, number, number>,
Traveling: RBXScriptSignal<number, Vector3>,
TravelStart: RBXScriptSignal,
ManualTravelRequested: RBXScriptSignal,
Parked: RBXScriptSignal,
Leveling: RBXScriptSignal,
Leveling3Phase: RBXScriptSignal,
__eventInstances__: {
Progression: BindableEvent,
Traveling: BindableEvent,
Parked: BindableEvent,
Leveling: BindableEvent,
Traveling: BindableEvent,
TravelStart: BindableEvent,
ManualTravelRequested: BindableEvent,
Parked: BindableEvent,
Leveling: BindableEvent,
Leveling3Phase: BindableEvent,
}
}
export type constructor = ClassConstructor
local Elevator = {} :: Impl_Constructor
Elevator.__index = Elevator
@@ -146,17 +152,19 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
local RelayAlgorithmConstructor = RelayAlgorithm.constructor(BoxAlignPosition)
local CabProgression = Instance.new("BindableEvent") :: BindableEvent
local CabTraveling = Instance.new("BindableEvent") :: BindableEvent
local Parked = Instance.new("BindableEvent") :: BindableEvent
local Leveling = Instance.new("BindableEvent") :: BindableEvent
local CabTraveling = Instance.new("BindableEvent") :: BindableEvent
local CabTravelStart = Instance.new("BindableEvent") :: BindableEvent
local ManualTravelRequested = Instance.new("BindableEvent") :: BindableEvent
local Parked = Instance.new("BindableEvent") :: BindableEvent
local Leveling = Instance.new("BindableEvent") :: BindableEvent
local Leveling3Phase = Instance.new("BindableEvent") :: BindableEvent
local Attributes = {
PreviousFloor = Instance.new("IntValue") :: IntValue,
CurrentFloor = Instance.new("IntValue") :: IntValue,
NextFloor = Instance.new("IntValue") :: IntValue,
Goal = Instance.new("IntValue") :: IntValue,
PreviousFloor = Instance.new("IntValue") :: IntValue,
CurrentFloor = Instance.new("IntValue") :: IntValue,
NextFloor = Instance.new("IntValue") :: IntValue,
Goal = Instance.new("IntValue") :: IntValue,
TravelingUpwards = Instance.new("BoolValue") :: BoolValue,
Stopped = Instance.new("BoolValue") :: BoolValue
Stopped = Instance.new("BoolValue") :: BoolValue
}
Attributes.CurrentFloor.Value = 1
Attributes.PreviousFloor.Value = Attributes.CurrentFloor.Value
@@ -178,17 +186,22 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
AlignPosition = BoxAlignPosition,
Configuration = ElevatorConfigurationTable,
},
Events = {
Progression = CabProgression.Event,
Traveling = CabTraveling.Event,
Parked = Parked.Event,
Leveling = Leveling.Event,
Traveling = CabTraveling.Event,
TravelStart = CabTravelStart.Event,
ManualTravelRequested = ManualTravelRequested.Event,
Parked = Parked.Event,
Leveling = Leveling.Event,
Leveling3Phase = Leveling3Phase.Event,
__eventInstances__ = {
Progression = CabProgression,
Traveling = CabTraveling,
Parked = Parked,
Leveling = Leveling,
Traveling = CabTraveling,
TravelStart = CabTravelStart,
ManualTravelRequested = ManualTravelRequested,
Parked = Parked,
Leveling = Leveling,
Leveling3Phase = Leveling3Phase,
}
},
@@ -377,6 +390,7 @@ end
function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP)
if self.Elevator.Configuration.Functions.ManualTravelStart then
self.Events.__eventInstances__.ManualTravelRequested:Fire()
self.__functionEvents.StartTraveling.Event:Wait()
end
if self.__Connections.Moving and self.__Connections.Moving.Connected then
@@ -384,6 +398,7 @@ function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP)
end
assert(not self.Elevator.BoxModel.Anchored, "The elevator cannot move! Its box model is Anchored.")
self.Events.__eventInstances__.TravelStart:Fire()
local ElevatorTravelingUpwards = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, Level_Int)
self.Attributes.Goal.Value = Level_Int
@@ -405,17 +420,20 @@ function Elevator:RequestLevelAsync(RequestedLevel, Direction)
local Level = self:GetLevel(RequestedLevel)
if Level then
if (RequestedLevel == 1 and Direction == Enums.ElevatorCallDirection.Down) or (RequestedLevel == #self.FloorLevelingPositions and Direction == Enums.ElevatorCallDirection.Up) then
self.ewarn(`Impossible direction requested, Direction={Direction}, RequestedLevel={Level}`)
return false
else
local DirectionQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
-- local OppositeQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Down or self.RelayAlgorithm.FloorQueue.Up
if (RequestedLevel == 1 and Direction == Enums.ElevatorCallDirection.Down) then
self.ewarnStudio(`Impossible direction requested, Direction={Direction}, RequestedLevel={RequestedLevel}. correcting...`)
Direction = Enums.ElevatorCallDirection.Up
elseif (RequestedLevel == #self.FloorLevelingPositions and Direction == Enums.ElevatorCallDirection.Up) then
self.ewarnStudio(`Impossible direction requested, Direction={Direction}, RequestedLevel={RequestedLevel}. correcting...`)
Direction = Enums.ElevatorCallDirection.Down
end
self.RelayAlgorithm:AddFloor(Direction :: Enums.ElevatorCallDirectionValues, RequestedLevel)
if #DirectionQueue == 1 then
self:__TravelToFloorAsync(RequestedLevel, Level)
end
local DirectionQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
-- local OppositeQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Down or self.RelayAlgorithm.FloorQueue.Up
self.RelayAlgorithm:AddFloor(Direction :: Enums.ElevatorCallDirectionValues, RequestedLevel)
if #DirectionQueue == 1 then
self:__TravelToFloorAsync(RequestedLevel, Level)
end
return true
end