Files
Roblox-Elevator-Game/src/client/Character/SpineKinematics.lua

63 lines
1.5 KiB
Lua

--!optimize 2
--!native
--!strict
type UDP = UnreliableRemoteEvent
type CurrentCamera = Camera
type CharacterShared = Folder
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
Enable: (self: ClassConstructor) -> (),
Disable: (self: ClassConstructor) -> ()
} & Impl_Static_Props
type Constructor_Fun = (CharacterShared: CharacterShared, CurrentCamera: CurrentCamera) -> ClassConstructor
type Impl_Static_Props = {
Running: boolean
}
type Constructor_Return_Props = {
Remote: UDP,
CurrentCamera: CurrentCamera
}
export type SpineConstructor = ClassConstructor
local Spine = {} :: Impl_Constructor
Spine.__index = Spine
Spine.Running = false
local Storage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Delta = require(Storage:WaitForChild("Delta"))
function Spine.constructor(CharacterShared, CurrentCamera)
return setmetatable({
Remote = CharacterShared:WaitForChild("SpineStream") :: UDP,
CurrentCamera = CurrentCamera :: CurrentCamera
}, Spine)
end
function Spine:Enable()
Spine.Running = true
task.spawn(function()
while Spine.Running do
self.Remote:FireServer(self.CurrentCamera.CFrame, Player.CameraMode == Enum.CameraMode.LockFirstPerson)
Delta:time()
end
end)
end
function Spine:Disable()
Spine.Running = false
Delta:time()
end
return Spine