diff --git a/src/server/main/EditorEntities.lua b/src/server/main/EditorEntities.lua index ed68380..99c7db1 100644 --- a/src/server/main/EditorEntities.lua +++ b/src/server/main/EditorEntities.lua @@ -24,14 +24,14 @@ local function HidePart(Part: BasePart, enabled: boolean) end local function HideIndicatorPart(Part: BasePart, enabled: boolean) - local billboard_light_indicator = Part:FindFirstChildOfClass("BillboardGui") - if billboard_light_indicator then - if enabled then - billboard_light_indicator:Destroy() - end - else - warn("Indicator source had no image indicator", Part:GetFullName()) - end + --local billboard_light_indicator = Part:FindFirstChildOfClass("BillboardGui") + --if billboard_light_indicator then + -- if enabled then + -- billboard_light_indicator:Destroy() + -- end + --else + -- warn("Indicator source had no image indicator", Part:GetFullName()) + --end HidePart(Part, enabled) end diff --git a/src/server/main/Elevators/Otis1960/MovingObjects.lua b/src/server/main/Elevators/Otis1960/MovingObjects.lua new file mode 100644 index 0000000..d21c7e8 --- /dev/null +++ b/src/server/main/Elevators/Otis1960/MovingObjects.lua @@ -0,0 +1,72 @@ +--!optimize 2 +--!native +--!strict + +type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor)) +type Impl_Constructor = { + __index: Impl_Constructor, + constructor: Constructor_Fun, + --Class functions + FR_Pullies: (self: ClassConstructor, Delta: number, ElevatorVelocity_Y: number) -> (), + FR_PiePlate: (self: ClassConstructor) -> () +} + +type Constructor_Fun = (InstanceTree: InstanceTree) -> ClassConstructor +type Constructor_Return_Props = { + PulleyCFrame: CFrame, + Pulley2CFrame: CFrame, + GovernorCFrame: CFrame, + GovernorFlyballsCFrame: CFrame, + PieplatePulleyCFrame: CFrame, + Pulley: UnionOperation, + Pulley2: UnionOperation, + Governor: UnionOperation, + GovernorFlyballs: UnionOperation, + PieplatePulley: UnionOperation, +} + +export type InstanceTree = { + Pulley: UnionOperation, + Pulley2: UnionOperation, + Governor: UnionOperation, + GovernorFlyballs: UnionOperation, + PieplatePulley: UnionOperation, +} + +export type MovingObjectsConstructor = ClassConstructor + +local MovingObjects = {} :: Impl_Constructor +MovingObjects.__index = MovingObjects + +local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage") +local Tween = require(Storage:WaitForChild("Tween")) +local Easing = require(Storage:WaitForChild("AlgebraEasings")) + +function MovingObjects.constructor(InstanceTree) + local self = InstanceTree + self.PulleyCFrame = InstanceTree.Pulley.CFrame + self.Pulley2CFrame = InstanceTree.Pulley2.CFrame + self.GovernorCFrame = InstanceTree.Governor.CFrame + self.GovernorFlyballsCFrame = InstanceTree.GovernorFlyballs.CFrame + self.PieplatePulleyCFrame = InstanceTree.PieplatePulley.CFrame + + return setmetatable(self, MovingObjects) +end + +function MovingObjects:FR_Pullies(Delta, ElevatorVelocity_Y) + local RotAngle = Delta*ElevatorVelocity_Y + local PullAngle_2 = math.rad(RotAngle/2) + local PullAngle = math.rad(RotAngle) + + self.Pulley.CFrame = self.PulleyCFrame *CFrame.Angles(-PullAngle_2, 0, 0) + self.Pulley2.CFrame = self.Pulley2CFrame *CFrame.Angles(PullAngle_2, 0, 0) + self.Governor.CFrame = self.GovernorCFrame *CFrame.Angles(0, PullAngle_2, 0) + self.GovernorFlyballs.CFrame = self.GovernorFlyballsCFrame*CFrame.Angles(PullAngle, 0, 0) + self.PieplatePulley.CFrame = self.PieplatePulleyCFrame *CFrame.Angles(PullAngle_2, 0, 0) +end + +function MovingObjects:FR_PiePlate() + +end + +return MovingObjects \ No newline at end of file diff --git a/src/server/main/Elevators/Otis1960/init.lua b/src/server/main/Elevators/Otis1960/init.lua index 0dd2e02..7a43a9b 100644 --- a/src/server/main/Elevators/Otis1960/init.lua +++ b/src/server/main/Elevators/Otis1960/init.lua @@ -13,13 +13,14 @@ local Easings = require(Storage:WaitForChild("AlgebraEasings")) local Leveling = require(script:WaitForChild("Leveling")) local Doors = require(script:WaitForChild("Doors")) local PieplateModule = require(script:WaitForChild("PiePlateSelector")) +local MovingObjects = require(script:WaitForChild("MovingObjects")) local Enums = require(Elevators:WaitForChild("Enums")) local ElevatorMover = require(Elevators:WaitForChild("Mover")) local ButtonTags = require(Elevators:WaitForChild("Buttons")) local TractionRopes = require(Elevators:WaitForChild("TractionRopes")) -type Tags = TagsModule.ExportedTags +type Tags = TagsModule.ExportedTags type TagsConstructor = TagsModule.TagsConstructor type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor)) @@ -39,24 +40,27 @@ type Impl_Static_Props = { type Constructor_Fun = (TagsConstructor: TagsConstructor) -> ClassConstructor type Constructor_Return_Props = { - Tags: Tags, - ElevatorBox_1960: UnionOperation, - ElevatorDoor1: BasePart, - ElevatorDoor2: BasePart, - ElevatorDoorSensor: Folder, - BoxAttachment: Attachment, - BoxAlignPosition: AlignPosition, - BoxAlignOrientation: AlignOrientation, - ElevatorDoors: Doors.DoorConstructor, - Ropes: {Instance}, - TractionRopes: TractionRopes.TractionRopesConstructor, - PiePlateSelector: UnionOperation, - Pulley: UnionOperation, - Pulley2: UnionOperation, - Governor: UnionOperation, - GovernorFlyballs: UnionOperation, - PieplatePulley: UnionOperation, - __MovingConnection: RBXScriptConnection? + Tags: Tags, + MOConstructor: MovingObjects.MovingObjectsConstructor, + ElevatorBox_1960: UnionOperation, + ElevatorDoor1: BasePart, + ElevatorDoor2: BasePart, + ElevatorDoorSensor: Folder, + BoxAttachment: Attachment, + BoxAlignPosition: AlignPosition, + BoxAlignOrientation: AlignOrientation, + ElevatorDoors: Doors.DoorConstructor, + Ropes: {Instance}, + TractionRopes: TractionRopes.TractionRopesConstructor, + PiePlateSelector: UnionOperation, + Pulley: UnionOperation, + Pulley2: UnionOperation, + Governor: UnionOperation, + GovernorFlyballs: UnionOperation, + PieplatePulley: UnionOperation, + Audio_ChimeDirection: Sound, + Audio_ChimeLanding: Sound, + __MovingConnection: RBXScriptConnection? } type ButtonFunction = () -> () @@ -64,7 +68,7 @@ type ButtonFunction = () -> () local Otis1960 = {} :: Impl_Constructor Otis1960.__index = Otis1960 -Otis1960.Moving = false +Otis1960.Moving = false Otis1960.Responsiveness = 50 Otis1960.MaxVelocity = 10 @@ -150,13 +154,32 @@ function Otis1960.constructor(TagsConstructor) self.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation self.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation - --Rotation objects + --Rotation objects self.Pulley = TagsConstructor:Request("Otis1960_Pulley") :: UnionOperation self.Pulley2 = TagsConstructor:Request("Otis1960_Pulley2") :: UnionOperation self.Governor = TagsConstructor:Request("Otis1960_Governor") :: UnionOperation self.GovernorFlyballs = TagsConstructor:Request("Otis1960_GovernorFlyballs") :: UnionOperation self.PieplatePulley = TagsConstructor:Request("Otis1960_PieplatePulley") :: UnionOperation + self.MOConstructor = MovingObjects.constructor({ + Pulley = self.Pulley, + Pulley2 = self.Pulley2, + Governor = self.Governor, + GovernorFlyballs = self.GovernorFlyballs, + PieplatePulley = self.PieplatePulley, + } :: MovingObjects.InstanceTree) + + --Audio + local Lantern = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation + + self.Audio_ChimeDirection = Instance.new("Sound") :: Sound + self.Audio_ChimeDirection.SoundId = "rbxassetid://16990287228" + self.Audio_ChimeDirection.Parent = Lantern + + self.Audio_ChimeLanding = Instance.new("Sound") :: Sound + self.Audio_ChimeLanding.SoundId = "rbxassetid://16990290265" + self.Audio_ChimeLanding.Parent = Lantern + self.BoxAttachment, self.BoxAlignPosition, self.BoxAlignOrientation = ElevatorMover(self.ElevatorBox_1960, self.ElevatorBox_1960.Position, Otis1960.Responsiveness, Otis1960.MaxVelocity) @@ -178,17 +201,10 @@ function Otis1960.constructor(TagsConstructor) end function Otis1960:_MoveFloors(Level) - local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position - local RotationDelta = 0 - local PulleyPosition = self.Pulley.CFrame - local GovernorPosition = self.Governor.CFrame - local FlyballPosition = self.GovernorFlyballs.CFrame - local Pulley2Position = self.Pulley2.CFrame - local PieplatePulleyPosition = self.PieplatePulley.CFrame + local RotationDelta = 0 + local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position - local LastVelocityDelta = 0 - - if self.__MovingConnection then + if self.__MovingConnection and self.__MovingConnection.Connected then self.__MovingConnection:Disconnect() end --Otis1960_ShaftGovernor @@ -198,17 +214,10 @@ function Otis1960:_MoveFloors(Level) local ElevatorPosition = self.ElevatorBox_1960.Position local ElevatorVelocity = self.ElevatorBox_1960:GetVelocityAtPosition(ElevatorPosition).Y - local VelocitySmoothing = Easings.Linear(LastVelocityDelta, ElevatorVelocity, .5) - LastVelocityDelta = ElevatorVelocity + + --local VelocitySmoothing = Easings.Linear(LastVelocityDelta, ElevatorVelocity, .5) + --LastVelocityDelta = ElevatorVelocity - local PullAngle_2 = math.rad(RotationDelta*VelocitySmoothing/2) - local PullAngle = math.rad(RotationDelta*VelocitySmoothing) - - self.Pulley.CFrame = PulleyPosition *CFrame.Angles(-PullAngle_2, 0, 0) - self.Pulley2.CFrame = Pulley2Position *CFrame.Angles(PullAngle_2, 0, 0) - self.Governor.CFrame = GovernorPosition *CFrame.Angles(0, PullAngle_2, 0) - self.GovernorFlyballs.CFrame = FlyballPosition *CFrame.Angles(PullAngle, 0, 0) - self.PieplatePulley.CFrame = PieplatePulleyPosition*CFrame.Angles(PullAngle_2, 0, 0) self.TractionRopes:Move(26.3, ElevatorPosition)