Type vacuuming and working classes types

This commit is contained in:
2024-03-08 00:46:59 -05:00
parent a6df78e64f
commit 04fc707bec
11 changed files with 260 additions and 91 deletions

View File

@@ -8,9 +8,28 @@ type LocalPlayer = Player
type HumanoidRootPart = BasePart
type EulerXYZ_struct = {number}
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
On: (self: ClassConstructor) -> (),
Off: (self: ClassConstructor) -> (),
Toggle: (self: ClassConstructor) -> ()
} & Impl_Static_Props
type Constructor_Fun = (LocalPlayer: LocalPlayer, HumanoidRootPart: HumanoidRootPart) -> ClassConstructor
type Impl_Static_Props = {
Enabled: boolean,
HeadHeight: number
}
type Constructor_Return_Props = {
FlashlightPart: Part,
SpotLight: SpotLight,
ToggleSound: Sound
}
local Flashlight = {}
local Flashlight = {} :: Impl_Constructor
Flashlight.__index = Flashlight
Flashlight.Enabled = false
@@ -83,15 +102,15 @@ end
function Flashlight:On()
Flashlight.Enabled = true
(self.ToggleSound :: Sound):Play();
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
self.ToggleSound:Play();
self.SpotLight.Enabled = Flashlight.Enabled
end
function Flashlight:Off()
Flashlight.Enabled = false
(self.ToggleSound :: Sound):Play();
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
self.ToggleSound:Play();
self.SpotLight.Enabled = Flashlight.Enabled
end
function Flashlight:Toggle()
@@ -102,8 +121,4 @@ function Flashlight:Toggle()
end
end
function Flashlight:SetCFrame(CameraCFrame: CFrame)
end
return Flashlight