mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
rename everything to .luau extension
This commit is contained in:
64
src/client/Character/Camera/init.luau
Normal file
64
src/client/Character/Camera/init.luau
Normal file
@@ -0,0 +1,64 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local Bobbing = require(script:WaitForChild("Bobbing"))
|
||||
|
||||
type CurrentCamera = Camera
|
||||
type HumanoidRootPart = BasePart
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
EnableBobbing: (self: ClassConstructor) -> (),
|
||||
DisableBobbing: (self: ClassConstructor) -> ()
|
||||
}
|
||||
|
||||
type Constructor_Fun = (CurrentCamera: CurrentCamera, HumanoidRootPart: HumanoidRootPart, Humanoid: Humanoid) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
CameraFPS: boolean,
|
||||
CurrentCamera: CurrentCamera,
|
||||
HumanoidRootPart: HumanoidRootPart,
|
||||
BobbingCamera: Bobbing.BobbingConstructor
|
||||
}
|
||||
|
||||
export type CameraConstructor = ClassConstructor
|
||||
|
||||
local Camera = {} :: Impl_Constructor
|
||||
Camera.__index = Camera
|
||||
|
||||
local RS = game:GetService("RunService")
|
||||
|
||||
function Camera.constructor(CurrentCamera: CurrentCamera, HumanoidRootPart: HumanoidRootPart, Humanoid: Humanoid)
|
||||
local self = {} :: Constructor_Return_Props
|
||||
self.CameraFPS = false
|
||||
self.CurrentCamera = CurrentCamera
|
||||
self.HumanoidRootPart = HumanoidRootPart
|
||||
self.BobbingCamera = Bobbing.constructor(HumanoidRootPart, CurrentCamera, Humanoid)
|
||||
return setmetatable(self, Camera)
|
||||
end
|
||||
|
||||
function Camera:EnableBobbing()
|
||||
if not self.CameraFPS then
|
||||
RS:BindToRenderStep("CameraAnimations", Enum.RenderPriority.Camera.Value+1, function(dt)
|
||||
self.BobbingCamera:Frame(dt)
|
||||
end)
|
||||
self.CameraFPS = true
|
||||
else
|
||||
print("Character Camera: Cannot call EnableBobbing while its active", debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
function Camera:DisableBobbing()
|
||||
if self.CameraFPS then
|
||||
RS:UnbindFromRenderStep("CameraAnimations")
|
||||
self.CameraFPS = false
|
||||
else
|
||||
print("Character Camera: DisableBobbing was called before EnableBobbing", debug.traceback())
|
||||
end
|
||||
self.CurrentCamera.CFrame *= CFrame.Angles(0,0,0)
|
||||
end
|
||||
|
||||
return Camera
|
||||
Reference in New Issue
Block a user