moving objects module

This commit is contained in:
2024-04-03 21:19:03 -04:00
parent b65ab0e9aa
commit 731720ac3b
3 changed files with 130 additions and 49 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -13,6 +13,7 @@ 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"))
@@ -40,6 +41,7 @@ type Impl_Static_Props = {
type Constructor_Fun = (TagsConstructor: TagsConstructor) -> ClassConstructor
type Constructor_Return_Props = {
Tags: Tags,
MOConstructor: MovingObjects.MovingObjectsConstructor,
ElevatorBox_1960: UnionOperation,
ElevatorDoor1: BasePart,
ElevatorDoor2: BasePart,
@@ -56,6 +58,8 @@ type Constructor_Return_Props = {
Governor: UnionOperation,
GovernorFlyballs: UnionOperation,
PieplatePulley: UnionOperation,
Audio_ChimeDirection: Sound,
Audio_ChimeLanding: Sound,
__MovingConnection: RBXScriptConnection?
}
@@ -157,6 +161,25 @@ function Otis1960.constructor(TagsConstructor)
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 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 PullAngle_2 = math.rad(RotationDelta*VelocitySmoothing/2)
local PullAngle = math.rad(RotationDelta*VelocitySmoothing)
--local VelocitySmoothing = Easings.Linear(LastVelocityDelta, ElevatorVelocity, .5)
--LastVelocityDelta = ElevatorVelocity
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)