mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Type vacuuming and working classes types
This commit is contained in:
@@ -2,12 +2,47 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local Actions = {}
|
|
||||||
Actions.__index = Actions
|
|
||||||
|
|
||||||
type UDP = UnreliableRemoteEvent
|
type UDP = UnreliableRemoteEvent
|
||||||
type TCP = RemoteEvent
|
type TCP = RemoteEvent
|
||||||
type inherented = any
|
type inherented = any
|
||||||
|
type CurrentCamera = Camera
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
EnableSneak: (self: ClassConstructor) -> (),
|
||||||
|
DisableSneak: (self: ClassConstructor) -> (),
|
||||||
|
EnableCrouch: (self: ClassConstructor) -> (),
|
||||||
|
DisableCrouch: (self: ClassConstructor) -> (),
|
||||||
|
EnableFlashlight: (self: ClassConstructor, FlashlightKey: Enum.KeyCode) -> (),
|
||||||
|
DisableFlashlight: (self: ClassConstructor, FlashlightKey: Enum.KeyCode) -> (),
|
||||||
|
ToggleFlashlight: (self: ClassConstructor, FlashlightKey: Enum.KeyCode) -> ()
|
||||||
|
} & Impl_Static_Props
|
||||||
|
|
||||||
|
type Constructor_Fun = (HumanoidSettings: inherented, CurrentCamera: CurrentCamera, ActionsTCP: TCP) -> ClassConstructor
|
||||||
|
type Impl_Static_Props = {
|
||||||
|
DoingAction: boolean,
|
||||||
|
Sneaking: boolean,
|
||||||
|
Crouching: boolean,
|
||||||
|
Walk: number,
|
||||||
|
SneakingSpeed: number,
|
||||||
|
StandHeight: number,
|
||||||
|
CrouchHeight: number,
|
||||||
|
WalkSpeedMultiplier: number,
|
||||||
|
CrouchSpeed: number,
|
||||||
|
FlashlightEnabled: boolean
|
||||||
|
}
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
Humanoid: Humanoid,
|
||||||
|
HumanoidSettings: any,
|
||||||
|
CurrentCamera: CurrentCamera,
|
||||||
|
ActionsTCP: TCP
|
||||||
|
}
|
||||||
|
|
||||||
|
local Actions = {} :: Impl_Constructor
|
||||||
|
Actions.__index = Actions
|
||||||
|
|
||||||
--Sneak static properties
|
--Sneak static properties
|
||||||
Actions.DoingAction = false
|
Actions.DoingAction = false
|
||||||
@@ -34,7 +69,7 @@ local Delta = require(Storage:WaitForChild("Delta"))
|
|||||||
|
|
||||||
local CrouchTween = Tween.constructor()
|
local CrouchTween = Tween.constructor()
|
||||||
|
|
||||||
function Actions.constructor(HumanoidSettings: inherented, CurrentCamera: Camera, ActionsTCP: TCP)
|
function Actions.constructor(HumanoidSettings: inherented, CurrentCamera: CurrentCamera, ActionsTCP: TCP)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Humanoid = HumanoidSettings.Humanoid,
|
Humanoid = HumanoidSettings.Humanoid,
|
||||||
HumanoidSettings = HumanoidSettings,
|
HumanoidSettings = HumanoidSettings,
|
||||||
|
|||||||
@@ -2,7 +2,47 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local Bobbing = {}
|
type AnimationsMap = {
|
||||||
|
Idle: (tick: number, dt: number) -> Euler,
|
||||||
|
Walk: (tick: number, dt: number) -> Euler,
|
||||||
|
Stop: () -> Euler,
|
||||||
|
Falling: () -> Euler
|
||||||
|
}
|
||||||
|
type Euler = CFrame
|
||||||
|
type HumanoidRootPart = BasePart
|
||||||
|
type deltatime = number
|
||||||
|
type tick = number
|
||||||
|
type EulerValue = number
|
||||||
|
type CurrentCamera = Camera
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
Frame: (self: ClassConstructor, dt: number) -> ()
|
||||||
|
} & Impl_Static_Props
|
||||||
|
|
||||||
|
type Constructor_Fun = (HumanoidRootPart: HumanoidRootPart, CurrentCamera: CurrentCamera, Humanoid: Humanoid) -> ClassConstructor
|
||||||
|
type Impl_Static_Props = {
|
||||||
|
TurnAlpha: number,
|
||||||
|
LeanMultiplier: number,
|
||||||
|
SwayMultiplier: number,
|
||||||
|
AnimationAlpha: number,
|
||||||
|
MaxGimbalLockY: number,
|
||||||
|
AnimationSpeed: number,
|
||||||
|
Tick: number,
|
||||||
|
ForceStop: boolean
|
||||||
|
}
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
HumanoidRootPart: HumanoidRootPart,
|
||||||
|
CurrentCamera: CurrentCamera,
|
||||||
|
Humanoid: Humanoid
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BobbingConstructor = ClassConstructor
|
||||||
|
|
||||||
|
local Bobbing = {} :: Impl_Constructor
|
||||||
Bobbing.__index = Bobbing
|
Bobbing.__index = Bobbing
|
||||||
|
|
||||||
Bobbing.TurnAlpha = 0.050
|
Bobbing.TurnAlpha = 0.050
|
||||||
@@ -14,12 +54,7 @@ Bobbing.AnimationSpeed = 200
|
|||||||
Bobbing.Tick = 0
|
Bobbing.Tick = 0
|
||||||
Bobbing.ForceStop = false
|
Bobbing.ForceStop = false
|
||||||
|
|
||||||
type AnimationsMap = {[string]: (tick: number, dt: number) -> Euler}
|
local Animations = {} :: AnimationsMap
|
||||||
|
|
||||||
local Animations: AnimationsMap = {}
|
|
||||||
|
|
||||||
type Euler = CFrame
|
|
||||||
type HumanoidRootPart = BasePart
|
|
||||||
|
|
||||||
local UIS = game:GetService("UserInputService")
|
local UIS = game:GetService("UserInputService")
|
||||||
|
|
||||||
@@ -28,7 +63,7 @@ local ANG = CFrame.Angles
|
|||||||
local CameraLean = CN()
|
local CameraLean = CN()
|
||||||
local Animation = CN()
|
local Animation = CN()
|
||||||
|
|
||||||
function Bobbing.constructor(HumanoidRootPart: HumanoidRootPart, CurrentCamera: Camera, Humanoid: Humanoid)
|
function Bobbing.constructor(HumanoidRootPart: HumanoidRootPart, CurrentCamera: CurrentCamera, Humanoid: Humanoid)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
HumanoidRootPart = HumanoidRootPart,
|
HumanoidRootPart = HumanoidRootPart,
|
||||||
CurrentCamera = CurrentCamera,
|
CurrentCamera = CurrentCamera,
|
||||||
@@ -36,10 +71,6 @@ function Bobbing.constructor(HumanoidRootPart: HumanoidRootPart, CurrentCamera:
|
|||||||
}, Bobbing)
|
}, Bobbing)
|
||||||
end
|
end
|
||||||
|
|
||||||
type deltatime = number
|
|
||||||
type tick = number
|
|
||||||
type EulerValue = number
|
|
||||||
|
|
||||||
function Animations.Idle(t: tick, dt: deltatime)
|
function Animations.Idle(t: tick, dt: deltatime)
|
||||||
return ANG(
|
return ANG(
|
||||||
math.rad(math.cos(t/80)/(Bobbing.AnimationSpeed+50)),
|
math.rad(math.cos(t/80)/(Bobbing.AnimationSpeed+50)),
|
||||||
@@ -78,7 +109,7 @@ local function Camera_YArc(Camera: Camera): EulerValue --stop Euler gimbal lock
|
|||||||
return math.abs(math.deg(EulerY))
|
return math.abs(math.deg(EulerY))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CameraAnimation(self, dt: deltatime)
|
local function CameraAnimation(self: ClassConstructor, dt: deltatime)
|
||||||
--crying
|
--crying
|
||||||
Bobbing.Tick += 1
|
Bobbing.Tick += 1
|
||||||
|
|
||||||
|
|||||||
@@ -2,27 +2,37 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local Camera = {}
|
|
||||||
local FakeCamera = {}
|
|
||||||
Camera.__index = Camera
|
|
||||||
FakeCamera.__index = FakeCamera
|
|
||||||
|
|
||||||
local RS = game:GetService("RunService")
|
|
||||||
local Bobbing = require(script:WaitForChild("Bobbing"))
|
local Bobbing = require(script:WaitForChild("Bobbing"))
|
||||||
|
|
||||||
type FakeCamera = BasePart
|
type FakeCamera = BasePart
|
||||||
type CurrentCamera = Camera
|
type CurrentCamera = Camera
|
||||||
type HumanoidRootPart = BasePart
|
type HumanoidRootPart = BasePart
|
||||||
|
type Module = any
|
||||||
|
|
||||||
type Camera_struct = {
|
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,
|
CameraFPS: boolean,
|
||||||
CurrentCamera: CurrentCamera,
|
CurrentCamera: CurrentCamera,
|
||||||
HumanoidRootPart: HumanoidRootPart,
|
HumanoidRootPart: HumanoidRootPart,
|
||||||
BobbingCamera: any
|
BobbingCamera: Bobbing.BobbingConstructor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local Camera = {} :: Impl_Constructor
|
||||||
|
Camera.__index = Camera
|
||||||
|
|
||||||
|
local RS = game:GetService("RunService")
|
||||||
|
|
||||||
function Camera.constructor(CurrentCamera: CurrentCamera, HumanoidRootPart: HumanoidRootPart, Humanoid: Humanoid)
|
function Camera.constructor(CurrentCamera: CurrentCamera, HumanoidRootPart: HumanoidRootPart, Humanoid: Humanoid)
|
||||||
local self = {} :: Camera_struct
|
local self = {}
|
||||||
self.CameraFPS = false
|
self.CameraFPS = false
|
||||||
self.CurrentCamera = CurrentCamera
|
self.CurrentCamera = CurrentCamera
|
||||||
self.HumanoidRootPart = HumanoidRootPart
|
self.HumanoidRootPart = HumanoidRootPart
|
||||||
@@ -48,7 +58,7 @@ function Camera:DisableBobbing()
|
|||||||
else
|
else
|
||||||
print("Character Camera: DisableBobbing was called before EnableBobbing", debug.traceback())
|
print("Character Camera: DisableBobbing was called before EnableBobbing", debug.traceback())
|
||||||
end
|
end
|
||||||
(self.CurrentCamera :: Camera).CFrame *= CFrame.Angles(0,0,0)
|
self.CurrentCamera.CFrame *= CFrame.Angles(0,0,0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Camera
|
return Camera
|
||||||
@@ -2,12 +2,29 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local HumanoidModule = {}
|
|
||||||
HumanoidModule.__index = HumanoidModule
|
|
||||||
|
|
||||||
type WalkSpeed = number?
|
type WalkSpeed = number?
|
||||||
type JumpHeight = number?
|
type JumpHeight = number?
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
SetWalkSpeed: (self: ClassConstructor, Speed: WalkSpeed) -> (),
|
||||||
|
SetJumpHeight: (self: ClassConstructor, Height: JumpHeight) -> ()
|
||||||
|
} & Impl_Static_Props
|
||||||
|
|
||||||
|
type Constructor_Fun = (Humanoid: Humanoid) -> ClassConstructor
|
||||||
|
type Impl_Static_Props = {
|
||||||
|
Running: boolean
|
||||||
|
}
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
Humanoid: Humanoid
|
||||||
|
}
|
||||||
|
|
||||||
|
local HumanoidModule = {} :: Impl_Constructor
|
||||||
|
HumanoidModule.__index = HumanoidModule
|
||||||
|
|
||||||
function HumanoidModule.constructor(Humanoid: Humanoid)
|
function HumanoidModule.constructor(Humanoid: Humanoid)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Humanoid = Humanoid
|
Humanoid = Humanoid
|
||||||
|
|||||||
@@ -2,10 +2,26 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local HumanoidRPSettings = {}
|
type HumanoidRootPart = BasePart
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
DisableRobloxSounds: (self: ClassConstructor) -> (),
|
||||||
|
Velocity: (self: ClassConstructor) -> Vector3
|
||||||
|
}
|
||||||
|
|
||||||
|
type Constructor_Fun = (HumanoidRootPart: HumanoidRootPart) -> ClassConstructor
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
HumanoidRootPart: HumanoidRootPart
|
||||||
|
}
|
||||||
|
|
||||||
|
local HumanoidRPSettings = {} :: Impl_Constructor
|
||||||
HumanoidRPSettings.__index = HumanoidRPSettings
|
HumanoidRPSettings.__index = HumanoidRPSettings
|
||||||
|
|
||||||
function HumanoidRPSettings.constructor(HumanoidRootPart: BasePart)
|
function HumanoidRPSettings.constructor(HumanoidRootPart: HumanoidRootPart)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
HumanoidRootPart = HumanoidRootPart
|
HumanoidRootPart = HumanoidRootPart
|
||||||
}, HumanoidRPSettings)
|
}, HumanoidRPSettings)
|
||||||
|
|||||||
@@ -2,19 +2,31 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local Spine = {
|
|
||||||
Running = false
|
|
||||||
}
|
|
||||||
Spine.__index = Spine
|
|
||||||
|
|
||||||
type UDP = UnreliableRemoteEvent
|
type UDP = UnreliableRemoteEvent
|
||||||
type CurrentCamera = Camera
|
type CurrentCamera = Camera
|
||||||
|
|
||||||
type struct_Spine = {
|
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,
|
Remote: UDP,
|
||||||
CurrentCamera: CurrentCamera
|
CurrentCamera: CurrentCamera
|
||||||
}
|
}
|
||||||
type CharacterSharedFolder = Folder
|
|
||||||
|
local Spine = {} :: Impl_Constructor
|
||||||
|
Spine.__index = Spine
|
||||||
|
|
||||||
|
Spine.Running = false
|
||||||
|
|
||||||
local Storage = game:GetService("ReplicatedStorage")
|
local Storage = game:GetService("ReplicatedStorage")
|
||||||
local Players = game:GetService("Players")
|
local Players = game:GetService("Players")
|
||||||
|
|||||||
@@ -2,14 +2,34 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local Actions = {}
|
|
||||||
Actions.__index = Actions
|
|
||||||
|
|
||||||
type EventFunction = (KeyPressed: Enum.KeyCode) -> ()
|
type EventFunction = (KeyPressed: Enum.KeyCode) -> ()
|
||||||
type ActionsTCP = RBXScriptConnection
|
type ActionsTCP = RBXScriptConnection
|
||||||
type LocalPlayer = Player
|
type LocalPlayer = Player
|
||||||
type TCP = RemoteEvent
|
type TCP = RemoteEvent
|
||||||
|
|
||||||
|
type EventsDict = {
|
||||||
|
[Enum.KeyCode]: EventFunction
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
Add: (self: ClassConstructor, Key: Enum.KeyCode, f: EventFunction) -> (),
|
||||||
|
Remove: (self: ClassConstructor, Key: Enum.KeyCode) -> ()
|
||||||
|
} & Impl_Static_Props
|
||||||
|
|
||||||
|
type Constructor_Fun = (LocalPlayer: LocalPlayer) -> ClassConstructor
|
||||||
|
type Impl_Static_Props = {}
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
Events: EventsDict,
|
||||||
|
CurrentActionsTCP_Event: ActionsTCP?
|
||||||
|
}
|
||||||
|
|
||||||
|
local Actions = {} :: Impl_Constructor
|
||||||
|
Actions.__index = Actions
|
||||||
|
|
||||||
local CharacterShared = _G.include(script, "CharacterShared")
|
local CharacterShared = _G.include(script, "CharacterShared")
|
||||||
|
|
||||||
local Remote = Instance.new("RemoteEvent") :: TCP
|
local Remote = Instance.new("RemoteEvent") :: TCP
|
||||||
@@ -19,9 +39,7 @@ Remote.Parent = CharacterShared
|
|||||||
local ActionsTCP_Event: ActionsTCP?
|
local ActionsTCP_Event: ActionsTCP?
|
||||||
|
|
||||||
function Actions.constructor(LocalPlayer: LocalPlayer)
|
function Actions.constructor(LocalPlayer: LocalPlayer)
|
||||||
local Events: {
|
local Events: EventsDict = {}
|
||||||
[Enum.KeyCode]: EventFunction
|
|
||||||
} = {}
|
|
||||||
|
|
||||||
if ActionsTCP_Event then
|
if ActionsTCP_Event then
|
||||||
warn("[Server Actions]: TCP event was already created, duplicating...", debug.traceback())
|
warn("[Server Actions]: TCP event was already created, duplicating...", debug.traceback())
|
||||||
|
|||||||
@@ -8,9 +8,28 @@ type LocalPlayer = Player
|
|||||||
type HumanoidRootPart = BasePart
|
type HumanoidRootPart = BasePart
|
||||||
type EulerXYZ_struct = {number}
|
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.__index = Flashlight
|
||||||
|
|
||||||
Flashlight.Enabled = false
|
Flashlight.Enabled = false
|
||||||
@@ -83,15 +102,15 @@ end
|
|||||||
function Flashlight:On()
|
function Flashlight:On()
|
||||||
Flashlight.Enabled = true
|
Flashlight.Enabled = true
|
||||||
|
|
||||||
(self.ToggleSound :: Sound):Play();
|
self.ToggleSound:Play();
|
||||||
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
self.SpotLight.Enabled = Flashlight.Enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
function Flashlight:Off()
|
function Flashlight:Off()
|
||||||
Flashlight.Enabled = false
|
Flashlight.Enabled = false
|
||||||
|
|
||||||
(self.ToggleSound :: Sound):Play();
|
self.ToggleSound:Play();
|
||||||
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
self.SpotLight.Enabled = Flashlight.Enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
function Flashlight:Toggle()
|
function Flashlight:Toggle()
|
||||||
@@ -102,8 +121,4 @@ function Flashlight:Toggle()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Flashlight:SetCFrame(CameraCFrame: CFrame)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
return Flashlight
|
return Flashlight
|
||||||
@@ -4,7 +4,23 @@
|
|||||||
|
|
||||||
--This really should be only client
|
--This really should be only client
|
||||||
|
|
||||||
local Shadows = {}
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
PartToggle: (self: ClassConstructor, Instance: BasePart, CastingShadow: boolean) -> (),
|
||||||
|
Remove: (self: ClassConstructor, Key: Enum.KeyCode) -> (),
|
||||||
|
on: (self: ClassConstructor) -> (),
|
||||||
|
off: (self: ClassConstructor) -> ()
|
||||||
|
}
|
||||||
|
|
||||||
|
type Constructor_Fun = (Character: Character) -> ClassConstructor
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
Character: Character
|
||||||
|
}
|
||||||
|
|
||||||
|
local Shadows = {} :: Impl_Constructor
|
||||||
Shadows.__index = Shadows
|
Shadows.__index = Shadows
|
||||||
|
|
||||||
type Character = Model
|
type Character = Model
|
||||||
@@ -21,10 +37,10 @@ function Shadows:PartToggle(Instance: BasePart, CastingShadow: boolean)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CharacterShadows(self, enabled: boolean)
|
local function CharacterShadows(self: ClassConstructor, enabled: boolean)
|
||||||
local CharacterDescendants = self.Character:GetDescendants()
|
local CharacterDescendants = self.Character:GetDescendants()
|
||||||
for i = 1, #CharacterDescendants do
|
for i = 1, #CharacterDescendants do
|
||||||
self:PartToggle(CharacterDescendants[i], enabled)
|
self:PartToggle(CharacterDescendants[i] :: BasePart, enabled)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,23 +2,33 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local Spine = {
|
|
||||||
Enabled = true,
|
|
||||||
Multiplier = .5
|
|
||||||
}
|
|
||||||
Spine.__index = Spine
|
|
||||||
|
|
||||||
type Head = BasePart
|
type Head = BasePart
|
||||||
type UpperTorso = BasePart
|
type UpperTorso = BasePart
|
||||||
type Neck = Motor6D
|
type Neck = Motor6D
|
||||||
type Waist = Motor6D
|
type Waist = Motor6D
|
||||||
|
|
||||||
type NeckC0 = CFrame
|
type NeckC0 = CFrame
|
||||||
type WaistC0 = CFrame
|
type WaistC0 = CFrame
|
||||||
|
|
||||||
type UDP = UnreliableRemoteEvent
|
type UDP = UnreliableRemoteEvent
|
||||||
|
|
||||||
type struct_Spine = {
|
type struct_SpineMovement = {
|
||||||
|
Neck: CFrame,
|
||||||
|
Waist: CFrame
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
Move: (self: ClassConstructor, CameraCFrame: CFrame, IsFirstPerson: boolean) -> ()
|
||||||
|
} & Impl_Static_Props
|
||||||
|
|
||||||
|
type Constructor_Fun = (Head: Head, UpperTorso: UpperTorso) -> ClassConstructor
|
||||||
|
type Impl_Static_Props = {
|
||||||
|
Enabled: boolean,
|
||||||
|
Multiplier: number
|
||||||
|
}
|
||||||
|
type Constructor_Return_Props = {
|
||||||
Remote: UDP,
|
Remote: UDP,
|
||||||
Head: Head,
|
Head: Head,
|
||||||
UpperTorso: UpperTorso,
|
UpperTorso: UpperTorso,
|
||||||
@@ -28,29 +38,29 @@ type struct_Spine = {
|
|||||||
WaistC0: WaistC0
|
WaistC0: WaistC0
|
||||||
}
|
}
|
||||||
|
|
||||||
local Remote = Instance.new("UnreliableRemoteEvent")
|
local Spine = {} :: Impl_Constructor
|
||||||
|
Spine.__index = Spine
|
||||||
|
|
||||||
|
Spine.Enabled = true
|
||||||
|
Spine.Multiplier = .5
|
||||||
|
|
||||||
|
local Remote = Instance.new("UnreliableRemoteEvent") :: UDP
|
||||||
Remote.Name = "SpineStream"
|
Remote.Name = "SpineStream"
|
||||||
Remote.Parent = _G.include(script, "CharacterShared")
|
Remote.Parent = _G.include(script, "CharacterShared")
|
||||||
|
|
||||||
function Spine.constructor(Head: Head, UpperTorso: UpperTorso)
|
function Spine.constructor(Head: Head, UpperTorso: UpperTorso)
|
||||||
local self = {} :: struct_Spine
|
local self = {}
|
||||||
self.Head = Head
|
self.Head = Head
|
||||||
self.UpperTorso = UpperTorso
|
self.UpperTorso = UpperTorso
|
||||||
self.Neck = Head:WaitForChild("Neck") :: Neck
|
self.Neck = Head:WaitForChild("Neck") :: Motor6D
|
||||||
self.Waist = UpperTorso:WaitForChild("Waist") :: Waist
|
self.Waist = UpperTorso:WaitForChild("Waist") :: Motor6D
|
||||||
self.Remote = Remote :: UDP
|
self.Remote = Remote
|
||||||
|
self.NeckC0 = (self.Neck :: Motor6D).C0
|
||||||
self.NeckC0 = self.Neck.C0
|
self.WaistC0 = (self.Neck :: Motor6D).C0
|
||||||
self.WaistC0 = self.Waist.C0
|
|
||||||
return setmetatable(self, Spine)
|
return setmetatable(self, Spine)
|
||||||
end
|
end
|
||||||
|
|
||||||
type struct_SpineMovement = {
|
local function SpineMovement(self: ClassConstructor, CameraCFrame: CFrame, IsFirstPerson: boolean): struct_SpineMovement
|
||||||
Neck: CFrame,
|
|
||||||
Waist: CFrame
|
|
||||||
}
|
|
||||||
|
|
||||||
local function SpineMovement(self, CameraCFrame: CFrame, IsFirstPerson: boolean): struct_SpineMovement
|
|
||||||
local HeadCFrame: CFrame = self.Head.CFrame
|
local HeadCFrame: CFrame = self.Head.CFrame
|
||||||
local TorsoPosition: Vector3 = self.UpperTorso.Position
|
local TorsoPosition: Vector3 = self.UpperTorso.Position
|
||||||
local TorsoLookVector: Vector3 = self.UpperTorso.CFrame.LookVector
|
local TorsoLookVector: Vector3 = self.UpperTorso.CFrame.LookVector
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
-- type AccountImpl = {
|
|
||||||
-- __index: AccountImpl,
|
|
||||||
-- new: (name: string, balance: number) -> Account,
|
|
||||||
-- deposit: (self: Account, credit: number) -> (),
|
|
||||||
-- withdraw: (self: Account, debit: number) -> (),
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- type Account = typeof(setmetatable({} :: { name: string, balance: number }, {} :: AccountImpl))
|
|
||||||
|
|
||||||
type hself<T,U> = {__index: T} & U
|
|
||||||
export type constructor<T,U> = typeof(setmetatable({} :: T & hself<T,U>, {} :: U))
|
|
||||||
Reference in New Issue
Block a user