Server character restructure

This commit is contained in:
2024-04-20 15:05:43 -04:00
parent 4baf7bff51
commit b82606d64c
21 changed files with 2 additions and 2 deletions

View 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