diff --git a/src/client/Character/Client/Actions.lua b/src/client/Character/Client/Actions.lua index 6cfd680..fc7bc0e 100644 --- a/src/client/Character/Client/Actions.lua +++ b/src/client/Character/Client/Actions.lua @@ -2,25 +2,120 @@ --!native --!strict -local Actions = { - ActionCurrent = false, - Walk = 10, - Sneaking = 10/2 --10 is default -} +local Actions = {} Actions.__index = Actions -function Actions.constructor(HumanoidSettingsInherent, Humanoid: Humanoid) +--Sneak static properties +Actions.DoingAction = false +Actions.Sneaking = false +Actions.Crouching = false +Actions.Walk = 10 +Actions.SneakingSpeed = 10/2 --10 is default +--Crouch static properties +Actions.Crouching = false +Actions.StandHeight = 2.1 +Actions.CrouchHeight = .6 +Actions.WalkSpeedMultiplier = 6 +Actions.CrouchSpeed = .2 +--Flashlight static properties +Actions.FlashlightEnabled = false + +local CharacterShared = _G.include(script, "CharacterShared") +local FlashlightRemote = CharacterShared:WaitForChild("Flashlight") + +local Storage = game:GetService("ReplicatedStorage") +local RS = game:GetService("RunService") + +local Tween = require(Storage:WaitForChild("Tween")) +local Delta = require(Storage:WaitForChild("Delta")) + +type inherented = any + +function Actions.constructor(HumanoidSettings: inherented, Humanoid: Humanoid, CurrentCamera: Camera) return setmetatable({ Humanoid = Humanoid, - HumanoidSettingsInherent = HumanoidSettingsInherent + HumanoidSettings = HumanoidSettings, + CurrentCamera = CurrentCamera }, Actions) end -function Actions:Enable() - self.HumanoidSettingsInherent:SetWalkSpeed(Actions.Sneaking) +function Actions:EnableSneak() + Actions.DoingAction = true + Actions.Sneaking = true + self.HumanoidSettings:SetWalkSpeed(Actions.SneakingSpeed) end -function Actions:Disable() - self.HumanoidSettingsInherent:SetWalkSpeed(Actions.Walk) +function Actions:DisableSneak() + Actions.DoingAction = false + Actions.Sneaking = false + self.HumanoidSettings:SetWalkSpeed(Actions.Walk) end +local CrouchTween = Tween.constructor() + +function Actions:EnableCrouch(StandingWalkSpeed: number) + Actions.DoingAction = true + Actions.Crouching = true + + local Easing = TweenInfo.new(Actions.CrouchSpeed, Enum.EasingStyle.Linear) + + CrouchTween:Start(self.Humanoid, { + HipHeight = Actions.CrouchHeight, + WalkSpeed = math.max(1, StandingWalkSpeed-Actions.WalkSpeedMultiplier) + }, Easing) +end + +function Actions:DisableCrouch(CrouchingWalkSpeed: number) + Actions.DoingAction = false + Actions.Crouching = false + + local Easing = TweenInfo.new(Actions.CrouchSpeed, Enum.EasingStyle.Linear) + + CrouchTween:Start(self.Humanoid, { + HipHeight = Actions.StandHeight, + WalkSpeed = math.max(1, CrouchingWalkSpeed+Actions.WalkSpeedMultiplier) + }, Easing) +end + +function Actions:EnableFlashlight() + Actions.FlashlightEnabled = true + + task.spawn(function() + while Actions.FlashlightEnabled do + + Delta:time() + end + end) +end + +function Actions:DisableFlashlight() + Actions.FlashlightEnabled = false +end + +function Actions:EnableFlashlight() + if Actions.FlashlightEnabled then + + else + + end +end + +function Actions:ToggleCrouch() + if not Actions.DoingAction then + if Actions.Crouching then + self:DisableCrouch() + else + self:EnableCrouch() + end + end +end + +function Actions:ToggleSneak() + if not Actions.DoingAction then + if Actions.Sneaking then + self:DisableSneak() + else + self:EnableSneak() + end + end +end \ No newline at end of file diff --git a/src/client/Character/Client/Camera/Bobbing.lua b/src/client/Character/Client/Camera/Bobbing.lua index ead177a..178af0d 100644 --- a/src/client/Character/Client/Camera/Bobbing.lua +++ b/src/client/Character/Client/Camera/Bobbing.lua @@ -1,3 +1,7 @@ +--!optimize 2 +--!native +--!strict + local Bobbing = {} Bobbing.__index = Bobbing @@ -84,8 +88,7 @@ local function CameraAnimation(self, dt: deltatime) --go go boolean algebra local MaxMinY: boolean = Camera_YArc(self.CurrentCamera)>Bobbing.MaxGimbalLockY --TODO: instead, make this an equation so it will just subtract from the existing animation radians - local ForceStop: boolean = Bobbing.ForceStop and "Stop" - local AnimationType: string = ForceStop or RootMagnitude>1 and "Walk" or (not MaxMinY and "Idle" or "Stop") + local AnimationType: string = Bobbing.ForceStop and "Stop" or RootMagnitude>1 and "Walk" or (not MaxMinY and "Idle" or "Stop") local CurrentAnimation: CFrame = Animations[AnimationType](Bobbing.Tick, dt) --"Lerp" so the transitions between walking and idling are smoothed instead of instant diff --git a/src/client/Character/Client/Camera/init.lua b/src/client/Character/Client/Camera/init.lua index 0a51659..ef49012 100644 --- a/src/client/Character/Client/Camera/init.lua +++ b/src/client/Character/Client/Camera/init.lua @@ -1,3 +1,7 @@ +--!optimize 2 +--!native +--!strict + local Camera = {} local FakeCamera = {} Camera.__index = Camera @@ -35,7 +39,7 @@ function Camera:DisableBobbing() else print("Character Camera: DisableBobbing was called before EnableBobbing", debug.traceback()) end - self.CurrentCamera.CFrame *= CFrame.Angles(0,0,0) + (self.CurrentCamera :: Camera).CFrame *= CFrame.Angles(0,0,0) end return Camera \ No newline at end of file diff --git a/src/client/Character/Client/Crouch.lua b/src/client/Character/Client/Crouch.lua deleted file mode 100644 index 22b1be8..0000000 --- a/src/client/Character/Client/Crouch.lua +++ /dev/null @@ -1,44 +0,0 @@ ---!optimize 2 ---!native ---!strict - -local CrouchModule = { - IsCrouching = false, - StandHeight = 2.1, - CrouchHeight = .6, - WalkSpeedMultiplier = 6, - CrouchSpeed = .2 -} -CrouchModule.__index = CrouchModule - -local Tween = require(game:GetService("ReplicatedStorage"):WaitForChild("Tween")) - -function CrouchModule.constructor(Humanoid: Humanoid) - return setmetatable({ - Humanoid = Humanoid - }, CrouchModule) -end - -local CrouchTween = Tween.constructor() - -function CrouchModule:Crouch(StandingWalkSpeed: number) - local Easing = TweenInfo.new(CrouchModule.CrouchSpeed, Enum.EasingStyle.Linear) - - CrouchTween:Start(self.Humanoid, { - HipHeight = CrouchModule.CrouchHeight, - WalkSpeed = math.max(1, StandingWalkSpeed-CrouchModule.WalkSpeedMultiplier) - }, Easing) - CrouchModule.IsCrouching = true -end - -function CrouchModule:Stand(CrouchingWalkSpeed: number) - local Easing = TweenInfo.new(CrouchModule.CrouchSpeed, Enum.EasingStyle.Linear) - - CrouchTween:Start(self.Humanoid, { - HipHeight = CrouchModule.StandHeight, - WalkSpeed = math.max(1, CrouchingWalkSpeed+CrouchModule.WalkSpeedMultiplier) - }, Easing) - CrouchModule.IsCrouching = false -end - -return CrouchModule \ No newline at end of file diff --git a/src/client/Character/Client/Flashlight.lua b/src/client/Character/Client/Flashlight.lua deleted file mode 100644 index 18d6f1d..0000000 --- a/src/client/Character/Client/Flashlight.lua +++ /dev/null @@ -1,19 +0,0 @@ ---!optimize 2 ---!native ---!strict - -local Flashlight = {} -Flashlight.__index = Flashlight - -local CharacterShared = _G.include(script, "CharacterShared") -local FlashlightRemote = CharacterShared:WaitForChild("Flashlight") - -function Flashlight.constructor() - return setmetatable({}, Flashlight) -end - -function Flashlight:Toggle() - FlashlightRemote:FireServer() -end - -return Flashlight \ No newline at end of file diff --git a/src/client/Character/Client/SpineKinematics.lua b/src/client/Character/Client/SpineKinematics.lua index 09409a5..3bd2521 100644 --- a/src/client/Character/Client/SpineKinematics.lua +++ b/src/client/Character/Client/SpineKinematics.lua @@ -21,14 +21,13 @@ type struct_Spine = { Remote: UnreliableRemoteEvent, CurrentCamera: CurrentCamera } - type CharacterSharedFolder = Folder function Spine.constructor(CurrentCamera: CurrentCamera) - local self = {} :: struct_Spine - self.Remote = CharacterShared:WaitForChild("SpineStream") - self.CurrentCamera = CurrentCamera - return setmetatable(self, Spine) + return setmetatable({ + Remote = CharacterShared:WaitForChild("SpineStream"), + CurrentCamera = CurrentCamera + }, Spine) end function Spine:Enable() diff --git a/src/client/Character/Client/init.client.lua b/src/client/Character/Client/init.client.lua index 4d7f0ee..a387716 100644 --- a/src/client/Character/Client/init.client.lua +++ b/src/client/Character/Client/init.client.lua @@ -49,7 +49,6 @@ local HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart) local CameraConsturctor = CameraModule.constructor(CurrentCamera, HumanoidRootPart, Humanoid) local HumanoidSettings = HumanoidModule.constructor(Humanoid) local SpineMovement = SpineModule.constructor(CurrentCamera) -local Flashlight = FlashlightModule.constructor() local ClientBindMap = BindModule.constructor(false) @@ -105,4 +104,6 @@ SpineMovement:Enable() ClientCharacterBinds() Crosshair3DVelocity_Effect() -FlashlightToggle() \ No newline at end of file +FlashlightToggle() + +_G.include = nil \ No newline at end of file diff --git a/src/client/Character/Server/Flashlight.lua b/src/client/Character/Server/Flashlight.lua index 487418a..513abcb 100644 --- a/src/client/Character/Server/Flashlight.lua +++ b/src/client/Character/Server/Flashlight.lua @@ -5,7 +5,7 @@ local Flashlight = {} Flashlight.__index = Flashlight -local Remote = Instance.new("RemoteEvent") :: RemoteEvent +local Remote = Instance.new("UnreliableRemoteEvent") :: UnreliableRemoteEvent Remote.Name = "Flashlight" Remote.Parent = _G.include(script, "CharacterShared") diff --git a/src/client/Character/Server/init.server.lua b/src/client/Character/Server/init.server.lua index 5556f9d..1ab409f 100644 --- a/src/client/Character/Server/init.server.lua +++ b/src/client/Character/Server/init.server.lua @@ -22,6 +22,7 @@ _G.include = function(this: LuaSourceContainer, FunName: string, ...) return type(switch) == "function" and switch(...) or switch else warn(`Preprocessor append failed "{FunName}"`, debug.traceback()) + return nil end end diff --git a/src/load/intro/init.client.lua b/src/load/intro/init.client.lua index df4695a..498e900 100644 --- a/src/load/intro/init.client.lua +++ b/src/load/intro/init.client.lua @@ -48,4 +48,4 @@ end LoadedBind() -ReplicatedFirst:RemoveDefaultLoadingScreen() \ No newline at end of file +ReplicatedFirst:RemoveDefaultLoadingScreen()