mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Server character restructure
This commit is contained in:
62
src/client/Character/SpineKinematics.lua
Normal file
62
src/client/Character/SpineKinematics.lua
Normal file
@@ -0,0 +1,62 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
type UDP = UnreliableRemoteEvent
|
||||
type CurrentCamera = Camera
|
||||
|
||||
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 = (CurrentCamera: CurrentCamera) -> ClassConstructor
|
||||
type Impl_Static_Props = {
|
||||
Running: boolean
|
||||
}
|
||||
type Constructor_Return_Props = {
|
||||
Remote: UDP,
|
||||
CurrentCamera: CurrentCamera
|
||||
}
|
||||
|
||||
local Spine = {} :: Impl_Constructor
|
||||
Spine.__index = Spine
|
||||
|
||||
Spine.Running = false
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local Players = game:GetService("Players")
|
||||
|
||||
local Delta = require(Storage:WaitForChild("Delta"))
|
||||
|
||||
local Player = Players.LocalPlayer
|
||||
local CharacterShared = _G.include(script, "CharacterShared")
|
||||
|
||||
function Spine.constructor(CurrentCamera: CurrentCamera)
|
||||
return setmetatable({
|
||||
Remote = CharacterShared:WaitForChild("SpineStream"),
|
||||
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
|
||||
Reference in New Issue
Block a user