mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 23:01:53 +00:00
more roact
This commit is contained in:
@@ -7,25 +7,31 @@ type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
FR_Pullies: (self: ClassConstructor, Delta: number, ElevatorVelocity_Y: number) -> (),
|
||||
FR_PiePlate: (self: ClassConstructor) -> ()
|
||||
UpdateCFrame: (self: ClassConstructor) -> (),
|
||||
Frame_Pullies: (self: ClassConstructor, Delta: number, ElevatorVelocity_Y: number) -> (),
|
||||
Frame_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,
|
||||
MachineRoom: {
|
||||
Pulley: UnionOperation,
|
||||
Pulley2: UnionOperation,
|
||||
Governor: UnionOperation,
|
||||
GovernorFlyballs: UnionOperation,
|
||||
PieplatePulley: UnionOperation,
|
||||
|
||||
_CFrame: {
|
||||
PulleyCFrame: CFrame,
|
||||
Pulley2CFrame: CFrame,
|
||||
GovernorCFrame: CFrame,
|
||||
GovernorFlyballsCFrame: CFrame,
|
||||
PieplatePulleyCFrame: CFrame,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type InstanceTree = {
|
||||
export type MachineRoom = {
|
||||
Pulley: UnionOperation,
|
||||
Pulley2: UnionOperation,
|
||||
Governor: UnionOperation,
|
||||
@@ -33,6 +39,10 @@ export type InstanceTree = {
|
||||
PieplatePulley: UnionOperation,
|
||||
}
|
||||
|
||||
export type InstanceTree = {
|
||||
MachineRoom: MachineRoom
|
||||
}
|
||||
|
||||
export type MovingObjectsConstructor = ClassConstructor
|
||||
|
||||
local MovingObjects = {} :: Impl_Constructor
|
||||
@@ -43,29 +53,37 @@ 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
|
||||
local self = InstanceTree :: Constructor_Return_Props
|
||||
self.MachineRoom._CFrame.PulleyCFrame = InstanceTree.MachineRoom.Pulley.CFrame
|
||||
self.MachineRoom._CFrame.Pulley2CFrame = InstanceTree.MachineRoom.Pulley2.CFrame
|
||||
self.MachineRoom._CFrame.GovernorCFrame = InstanceTree.MachineRoom.Governor.CFrame
|
||||
self.MachineRoom._CFrame.GovernorFlyballsCFrame = InstanceTree.MachineRoom.GovernorFlyballs.CFrame
|
||||
self.MachineRoom._CFrame.PieplatePulleyCFrame = InstanceTree.MachineRoom.PieplatePulley.CFrame
|
||||
|
||||
return setmetatable(self, MovingObjects)
|
||||
end
|
||||
|
||||
function MovingObjects:FR_Pullies(Delta, ElevatorVelocity_Y)
|
||||
function MovingObjects:UpdateCFrame()
|
||||
self.MachineRoom._CFrame.PulleyCFrame = self.MachineRoom.Pulley.CFrame
|
||||
self.MachineRoom._CFrame.Pulley2CFrame = self.MachineRoom.Pulley2.CFrame
|
||||
self.MachineRoom._CFrame.GovernorCFrame = self.MachineRoom.Governor.CFrame
|
||||
self.MachineRoom._CFrame.GovernorFlyballsCFrame = self.MachineRoom.GovernorFlyballs.CFrame
|
||||
self.MachineRoom._CFrame.PieplatePulleyCFrame = self.MachineRoom.PieplatePulley.CFrame
|
||||
end
|
||||
|
||||
function MovingObjects:Frame_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)
|
||||
self.MachineRoom.Pulley.CFrame = self.MachineRoom._CFrame.PulleyCFrame *CFrame.Angles(-PullAngle_2, 0, 0)
|
||||
self.MachineRoom.Pulley2.CFrame = self.MachineRoom._CFrame.Pulley2CFrame *CFrame.Angles(PullAngle_2, 0, 0)
|
||||
self.MachineRoom.Governor.CFrame = self.MachineRoom._CFrame.GovernorCFrame *CFrame.Angles(0, PullAngle_2, 0)
|
||||
self.MachineRoom.GovernorFlyballs.CFrame = self.MachineRoom._CFrame.GovernorFlyballsCFrame*CFrame.Angles(PullAngle, 0, 0)
|
||||
self.MachineRoom.PieplatePulley.CFrame = self.MachineRoom._CFrame.PieplatePulleyCFrame *CFrame.Angles(PullAngle_2, 0, 0)
|
||||
end
|
||||
|
||||
function MovingObjects:FR_PiePlate()
|
||||
function MovingObjects:Frame_PiePlate()
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@ type Constructor_Return_Props = {
|
||||
PieplatePulley: UnionOperation,
|
||||
Audio_ChimeDirection: Sound,
|
||||
Audio_ChimeLanding: Sound,
|
||||
__MovingConnection: RBXScriptConnection?
|
||||
MachineRoom: MovingObjects.MachineRoom,
|
||||
__MovingConnection: RBXScriptConnection?,
|
||||
}
|
||||
|
||||
type ButtonFunction = () -> ()
|
||||
@@ -154,19 +155,16 @@ function Otis1960.constructor(TagsConstructor)
|
||||
self.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
|
||||
self.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation
|
||||
|
||||
--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
|
||||
--Rotation objects
|
||||
self.MachineRoom = {} :: MovingObjects.MachineRoom
|
||||
self.MachineRoom.Pulley = TagsConstructor:Request("Otis1960_Pulley") :: UnionOperation
|
||||
self.MachineRoom.Pulley2 = TagsConstructor:Request("Otis1960_Pulley2") :: UnionOperation
|
||||
self.MachineRoom.Governor = TagsConstructor:Request("Otis1960_Governor") :: UnionOperation
|
||||
self.MachineRoom.GovernorFlyballs = TagsConstructor:Request("Otis1960_GovernorFlyballs") :: UnionOperation
|
||||
self.MachineRoom.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,
|
||||
MachineRoom = self.MachineRoom
|
||||
} :: MovingObjects.InstanceTree)
|
||||
|
||||
--Audio
|
||||
@@ -212,13 +210,10 @@ function Otis1960:_MoveFloors(Level)
|
||||
self.__MovingConnection = RS.Heartbeat:Connect(function(_dt) --Not safe for parallel
|
||||
RotationDelta+=1
|
||||
|
||||
local ElevatorPosition = self.ElevatorBox_1960.Position
|
||||
local ElevatorVelocity = self.ElevatorBox_1960:GetVelocityAtPosition(ElevatorPosition).Y
|
||||
local ElevatorPosition: Vector3 = self.ElevatorBox_1960.Position
|
||||
local ElevatorVelocityY: number = self.ElevatorBox_1960:GetVelocityAtPosition(ElevatorPosition).Y
|
||||
|
||||
--local VelocitySmoothing = Easings.Linear(LastVelocityDelta, ElevatorVelocity, .5)
|
||||
--LastVelocityDelta = ElevatorVelocity
|
||||
|
||||
|
||||
self.MOConstructor:Frame_Pullies(RotationDelta, ElevatorVelocityY)
|
||||
self.TractionRopes:Move(26.3, ElevatorPosition)
|
||||
|
||||
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y then
|
||||
|
||||
Reference in New Issue
Block a user