Files
Roblox-Elevator-Game/src/server/main/Elevators/TractionRopes.luau

53 lines
1.4 KiB
Lua

--!optimize 2
--!native
--!strict
type RopeTags = {Instance}
type Leveling = {number}
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
Move: (self: ClassConstructor, Offset: number, ElevatorPosition: Vector3) -> (),
Stopped: (self: ClassConstructor) -> (),
}
type Constructor_Fun = (RopeTags: RopeTags, ElevatorBox: UnionOperation, Leveling: Leveling) -> ClassConstructor
type Constructor_Return_Props = {
Ropes: RopeTags,
Leveling: Leveling,
BiggestRopeLength: number,
}
export type TractionRopesConstructor = ClassConstructor
local TractionRopes = {} :: Impl_Constructor
TractionRopes.__index = TractionRopes
function TractionRopes.constructor(RopeTags, ElevatorBox, Leveling)
local ArbitraryRopeContact = RopeTags[1].Parent :: BasePart
local HighestLevel = Leveling[#Leveling]
local BiggestRopeLength = HighestLevel-(ArbitraryRopeContact.Position.Y-HighestLevel)
return setmetatable({
Ropes = RopeTags,
Leveling = Leveling,
BiggestRopeLength = BiggestRopeLength
}, TractionRopes)
end
function TractionRopes:Move(Offset, ElevatorPosition)
local l = self.BiggestRopeLength-ElevatorPosition.Y+Offset
for i: number = 1, #self.Ropes do
(self.Ropes[i] :: RopeConstraint).Length = l
end
end
function TractionRopes:Stopped()
end
return TractionRopes