From e5f1a546b1ddff47b4edb69ddd9ad45824dc918c Mon Sep 17 00:00:00 2001 From: unittensor Date: Wed, 21 Feb 2024 13:23:23 -0500 Subject: [PATCH] Actor support --- default.project.json | 15 ++-- sourcemap.json | 1 + src/client/Character/Client/Flashlight.lua | 15 ++++ .../Character/Client/HumanoidRootPart.lua | 4 ++ .../Character/Client/SpineKinematics.lua | 2 +- src/client/Character/Client/init.client.lua | 42 +++++++++--- src/client/Character/Server/Flashlight.lua | 68 +++++++++++++++++++ .../Character/Server/SpineKinematics.lua | 2 +- src/client/Character/Server/init.server.lua | 31 +++++++-- src/client/Player/UI/Crosshair.lua | 18 ++++- src/client/Player/UI/Health.lua | 34 ++++++++++ src/client/Player/init.client.lua | 18 ++++- src/load/intro/IntroGui.lua | 10 ++- src/load/intro/init.client.lua | 4 +- src/server/Elevators/Floors.lua | 28 ++++++-- src/server/Elevators/Otis1960/Doors.lua | 30 ++++---- src/server/Elevators/Otis1960/main.server.lua | 18 ++--- src/server/Studio/Workspace.lua | 2 +- src/shared/AlgebraEasings.lua | 5 +- src/shared/Client/KeyBinds.lua | 8 +-- src/shared/Tags.lua | 2 +- 21 files changed, 284 insertions(+), 73 deletions(-) create mode 100644 sourcemap.json create mode 100644 src/client/Character/Client/Flashlight.lua create mode 100644 src/client/Character/Server/Flashlight.lua create mode 100644 src/client/Player/UI/Health.lua diff --git a/default.project.json b/default.project.json index 26b37ed..cfbef0f 100644 --- a/default.project.json +++ b/default.project.json @@ -2,7 +2,6 @@ "name": "ElevatorGame", "tree": { "$className": "DataModel", - "ReplicatedStorage": { "$path": "src/shared" }, @@ -12,16 +11,20 @@ "ReplicatedFirst": { "$path": "src/load" }, - "StarterPlayer": { "StarterPlayerScripts": { - "Player": { - "$path": "src/client/Player" + "PlayerRoot -rapid": { + "$className": "Actor", + "Player": { + "$path": "src/client/Player" + } } }, - "StarterCharacterScripts": { - "$path": "src/client/Character" + "CharacterRoot -rapid": { + "$className": "Actor", + "$path": "src/client/Character" + } } } } diff --git a/sourcemap.json b/sourcemap.json new file mode 100644 index 0000000..8cfcec1 --- /dev/null +++ b/sourcemap.json @@ -0,0 +1 @@ +{"name":"ElevatorGame","className":"DataModel","filePaths":["default.project.json"],"children":[{"name":"ReplicatedFirst","className":"ReplicatedFirst","children":[{"name":"intro","className":"LocalScript","filePaths":["src/load/intro/init.client.lua"],"children":[{"name":"IntroGui","className":"ModuleScript","filePaths":["src/load/intro/IntroGui.lua"]}]}]},{"name":"ReplicatedStorage","className":"ReplicatedStorage","children":[{"name":"AlgebraEasings","className":"ModuleScript","filePaths":["src/shared/AlgebraEasings.lua"]},{"name":"Client","className":"Folder","children":[{"name":"Camera","className":"ModuleScript","filePaths":["src/shared/Client/Camera.lua"]},{"name":"KeyBinds","className":"ModuleScript","filePaths":["src/shared/Client/KeyBinds.lua"]}]},{"name":"Delta","className":"ModuleScript","filePaths":["src/shared/Delta.lua"]},{"name":"Server","className":"Folder","children":[{"name":"holder","className":"ModuleScript","filePaths":["src/shared/Server/holder.lua"]}]},{"name":"String","className":"ModuleScript","filePaths":["src/shared/String.lua"]},{"name":"Tags","className":"ModuleScript","filePaths":["src/shared/Tags.lua"]},{"name":"Tween","className":"ModuleScript","filePaths":["src/shared/Tween.lua"]},{"name":"types","className":"Folder","children":[{"name":"class","className":"ModuleScript","filePaths":["src/shared/types/class.lua"]}]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"Elevators","className":"Folder","children":[{"name":"Floors","className":"ModuleScript","filePaths":["src/server/Elevators/Floors.lua"]},{"name":"Leveling","className":"ModuleScript","filePaths":["src/server/Elevators/Leveling.lua"]},{"name":"Mover","className":"ModuleScript","filePaths":["src/server/Elevators/Mover.lua"]},{"name":"Otis1960","className":"Folder","children":[{"name":"Doors","className":"ModuleScript","filePaths":["src/server/Elevators/Otis1960/Doors.lua"]},{"name":"main","className":"Script","filePaths":["src/server/Elevators/Otis1960/main.server.lua"]}]}]},{"name":"Studio","className":"Script","filePaths":["src/server/Studio/init.server.lua"],"children":[{"name":"EditorEntities","className":"ModuleScript","filePaths":["src/server/Studio/EditorEntities.lua"]},{"name":"Lighting","className":"ModuleScript","filePaths":["src/server/Studio/Lighting/init.lua"],"children":[{"name":"Sky","className":"ModuleScript","filePaths":["src/server/Studio/Lighting/Sky.lua"]}]},{"name":"StarterPlayer","className":"ModuleScript","filePaths":["src/server/Studio/StarterPlayer.lua"]},{"name":"Workspace","className":"ModuleScript","filePaths":["src/server/Studio/Workspace.lua"]}]}]},{"name":"StarterPlayer","className":"StarterPlayer","children":[{"name":"StarterCharacterScripts","className":"StarterCharacterScripts","children":[{"name":"Client","className":"LocalScript","filePaths":["src/client/Character/Client/init.client.lua"],"children":[{"name":"Camera","className":"ModuleScript","filePaths":["src/client/Character/Client/Camera/init.lua"],"children":[{"name":"Bobbing","className":"ModuleScript","filePaths":["src/client/Character/Client/Camera/Bobbing.lua"]}]},{"name":"Crouch","className":"ModuleScript","filePaths":["src/client/Character/Client/Crouch.lua"]},{"name":"Humanoid","className":"ModuleScript","filePaths":["src/client/Character/Client/Humanoid.lua"]},{"name":"HumanoidRootPart","className":"ModuleScript","filePaths":["src/client/Character/Client/HumanoidRootPart.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client/Character/Client/SpineKinematics.lua"]}]},{"name":"Server","className":"Script","filePaths":["src/client/Character/Server/init.server.lua"],"children":[{"name":"Shadows","className":"ModuleScript","filePaths":["src/client/Character/Server/Shadows.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client/Character/Server/SpineKinematics.lua"]}]}]},{"name":"StarterPlayerScripts","className":"StarterPlayerScripts","children":[{"name":"Player","className":"LocalScript","filePaths":["src/client/Player/init.client.lua"],"children":[{"name":"CoreGuis","className":"ModuleScript","filePaths":["src/client/Player/CoreGuis.lua"]},{"name":"GuiService","className":"ModuleScript","filePaths":["src/client/Player/GuiService.lua"]},{"name":"Mouse","className":"ModuleScript","filePaths":["src/client/Player/Mouse.lua"]},{"name":"UI","className":"Folder","children":[{"name":"Crosshair","className":"ModuleScript","filePaths":["src/client/Player/UI/Crosshair.lua"]},{"name":"Vignette","className":"ModuleScript","filePaths":["src/client/Player/UI/Vignette.lua"]}]}]}]}]}]} \ No newline at end of file diff --git a/src/client/Character/Client/Flashlight.lua b/src/client/Character/Client/Flashlight.lua new file mode 100644 index 0000000..b2fb314 --- /dev/null +++ b/src/client/Character/Client/Flashlight.lua @@ -0,0 +1,15 @@ +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/HumanoidRootPart.lua b/src/client/Character/Client/HumanoidRootPart.lua index 6b104dd..60246bb 100644 --- a/src/client/Character/Client/HumanoidRootPart.lua +++ b/src/client/Character/Client/HumanoidRootPart.lua @@ -18,4 +18,8 @@ function HumanoidRPSettings:DisableRobloxSounds() end end +function HumanoidRPSettings:Velocity() + return self.HumanoidRootPart:GetVelocityAtPosition(self.HumanoidRootPart.Position) +end + return HumanoidRPSettings \ No newline at end of file diff --git a/src/client/Character/Client/SpineKinematics.lua b/src/client/Character/Client/SpineKinematics.lua index 4027dea..5758768 100644 --- a/src/client/Character/Client/SpineKinematics.lua +++ b/src/client/Character/Client/SpineKinematics.lua @@ -21,7 +21,7 @@ type struct_Spine = { type CharacterSharedFolder = Folder function Spine.constructor(CurrentCamera: CurrentCamera) - local self: struct_Spine = {} + local self = {} :: struct_Spine self.Remote = CharacterShared:WaitForChild("SpineStream") self.CurrentCamera = CurrentCamera return setmetatable(self, Spine) diff --git a/src/client/Character/Client/init.client.lua b/src/client/Character/Client/init.client.lua index 1d2dd65..38869e2 100644 --- a/src/client/Character/Client/init.client.lua +++ b/src/client/Character/Client/init.client.lua @@ -1,10 +1,10 @@ -local Character = script.Parent +local Character = script.Parent.Parent local preprocessor = {} type CharacterSharedFolder = Folder function preprocessor.CharacterShared(): CharacterSharedFolder - return script.Parent:WaitForChild("shared") + return Character:WaitForChild("shared") end _G.include = function(this: LuaSourceContainer, FunName: string, ...) @@ -17,6 +17,8 @@ _G.include = function(this: LuaSourceContainer, FunName: string, ...) end local Storage = game:GetService("ReplicatedStorage") +local RS = game:GetService("RunService") :: RunService + local ClientStorage = Storage:WaitForChild("Client") local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete") @@ -31,6 +33,7 @@ local CameraModule = require(script:WaitForChild("Camera")) local CrouchModule = require(script:WaitForChild("Crouch")) local HumanoidModule = require(script:WaitForChild("Humanoid")) local SpineModule = require(script:WaitForChild("SpineKinematics")) +local FlashlightModule = require(script:WaitForChild("Flashlight")) local BindModule = require(ClientStorage:WaitForChild("KeyBinds")) local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") @@ -41,33 +44,54 @@ 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 Walking = 10/2 --10 is default +local ClientBindMap = BindModule.constructor(false) local function ClientCharacterBinds() local CrouchConstructor = CrouchModule.constructor(Humanoid) - local BindMap = BindModule.constructor() - --Crouch - BindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function() + ClientBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function() CrouchConstructor:Crouch(10) end) - BindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function() + ClientBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function() CrouchConstructor:Stand(5) end) --Walk - BindMap:AddInputBegan({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function() + ClientBindMap:AddInputBegan({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function() HumanoidSettings:SetWalkSpeed(Walking) end) - BindMap:AddInputEnded({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function() + ClientBindMap:AddInputEnded({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function() HumanoidSettings:SetWalkSpeed(10) end) end +local function Crosshair3DVelocity_Effect(): RBXScriptSignal + local RootVelocity = ClientStorage:WaitForChild("RootVelocity") :: BindableEvent + + local RootVelocitySteps = RS.Heartbeat:ConnectParallel(function(_dt) + RootVelocity:Fire(HRPSettings:Velocity()) + end) + return RootVelocitySteps +end + +local function FlashlightToggle() + ClientBindMap:AddInputBegan({Enum.KeyCode.F}, function() + Flashlight:Toggle() + end) +end + +local function HealthChangeBind() + +end + HumanoidSettings:SetWalkSpeed() HumanoidSettings:SetJumpHeight() HRPSettings:DisableRobloxSounds() CameraConsturctor:EnableBobbing() SpineMovement:Enable() -ClientCharacterBinds() \ No newline at end of file +ClientCharacterBinds() +Crosshair3DVelocity_Effect() +FlashlightToggle() \ No newline at end of file diff --git a/src/client/Character/Server/Flashlight.lua b/src/client/Character/Server/Flashlight.lua new file mode 100644 index 0000000..54df6d2 --- /dev/null +++ b/src/client/Character/Server/Flashlight.lua @@ -0,0 +1,68 @@ +local Flashlight = {} +Flashlight.__index = Flashlight + +local Remote = Instance.new("RemoteEvent") :: RemoteEvent +Remote.Name = "Flashlight" +Remote.Parent = _G.include(script, "CharacterShared") + +function Flashlight.constructor(Head: BasePart) + local FlashlightPart = Instance.new("Part") :: Part + FlashlightPart.Size = Vector3.new(.1,.1,.1) + FlashlightPart.CFrame = Head.CFrame+Vector3.yAxis + FlashlightPart.CanCollide = false + FlashlightPart.CastShadow = false + FlashlightPart.Transparency = 1 + + local SpotLight = Instance.new("SpotLight") :: SpotLight + SpotLight.Color = Color3.new(1,1,1) + SpotLight.Angle = 80 + SpotLight.Range = 30 + SpotLight.Brightness = 1 + SpotLight.Shadows = true + SpotLight.Enabled = false + SpotLight.Parent = FlashlightPart + + local Weld = Instance.new("WeldConstraint") :: WeldConstraint + Weld.Part0 = Head + Weld.Part1 = FlashlightPart + Weld.Parent = FlashlightPart + + FlashlightPart.Anchored = false + FlashlightPart.Parent = Head + + local ToggleSound = Instance.new("Sound") :: Sound + ToggleSound.SoundId = "rbxassetid://16454678462" + ToggleSound.Volume = .5 + ToggleSound.Parent = Head + + return setmetatable({ + SpotLight = SpotLight, + ToggleSound = ToggleSound, + Remote = Remote + }, Flashlight) +end + +local FlashlightEnabled = false + +function Flashlight:On() + FlashlightEnabled = true + self.ToggleSound:Play() + self.SpotLight.Enabled = FlashlightEnabled +end + +function Flashlight:Off() + FlashlightEnabled = false + self.ToggleSound:Play() + self.SpotLight.Enabled = FlashlightEnabled +end + +function Flashlight:Toggle() + -- FlashlightEnabled = not FlashlightEnabled + if FlashlightEnabled then + self:Off() + else + self:On() + end +end + +return Flashlight \ No newline at end of file diff --git a/src/client/Character/Server/SpineKinematics.lua b/src/client/Character/Server/SpineKinematics.lua index 0d2f398..6ad5f51 100644 --- a/src/client/Character/Server/SpineKinematics.lua +++ b/src/client/Character/Server/SpineKinematics.lua @@ -25,7 +25,7 @@ Remote.Name = "SpineStream" Remote.Parent = _G.include(script, "CharacterShared") function Spine.constructor(Head: Head, UpperTorso: UpperTorso) - local self: struct_Spine = {} + local self = {} :: struct_Spine self.Head = Head self.UpperTorso = UpperTorso self.Neck = Head:WaitForChild("Neck") diff --git a/src/client/Character/Server/init.server.lua b/src/client/Character/Server/init.server.lua index 31acc9f..e33150c 100644 --- a/src/client/Character/Server/init.server.lua +++ b/src/client/Character/Server/init.server.lua @@ -1,4 +1,4 @@ -local Character = script.Parent +local Character = script.Parent.Parent local preprocessor = {} --Create the character shared directory here @@ -12,7 +12,7 @@ function preprocessor.CharacterShared(): CharacterSharedFolder end _G.include = function(this: LuaSourceContainer, FunName: string, ...) - --its not extremely necessary to have security for the server-side + --its not extremely necessary to have this security on the server-side if this:IsDescendantOf(script) then --getfenv is being removed local switch = preprocessor[FunName] return type(switch) == "function" and switch(...) or switch @@ -23,8 +23,9 @@ end local Players = game:GetService("Players") -local Shadows = require(script:WaitForChild("Shadows")) -local SpineModule = require(script:WaitForChild("SpineKinematics")) +local Shadows = require(script:WaitForChild("Shadows")) +local SpineModule = require(script:WaitForChild("SpineKinematics")) +local FlashlightModule = require(script:WaitForChild("Flashlight")) local Head = Character:WaitForChild("Head") local UpperTorso = Character:WaitForChild("UpperTorso") @@ -33,6 +34,7 @@ local LocalPlayer = Players:GetPlayerFromCharacter(Character) local CharacterShadows = Shadows.constructor(Character) local Spine = SpineModule.constructor(Head, UpperTorso) +local Flashlight = FlashlightModule.constructor(Head) CharacterShadows:off() --I plan having 2 player support and characters block a ton of light @@ -41,12 +43,27 @@ Character.DescendantAdded:Connect(function(Instance) CharacterShadows:PartToggle(Instance, false) end) -Spine.Remote.OnServerEvent:Connect(function(Messenger: Player, CameraPosition: Vector3, IsFirstPerson: boolean) +Spine.Remote.OnServerEvent:Connect(function(Messenger: Player, CameraPosition: CFrame, IsFirstPerson: boolean) if Messenger.UserId == LocalPlayer.UserId then if Spine.Enabled then Spine:Move(CameraPosition, IsFirstPerson) + else + --reset + print("TODO reached -", script.Name..".lua") + end + end +end) + +local FlashlightDebounce = false + +Flashlight.Remote.OnServerEvent:Connect(function(Messenger: Player) + if Messenger.UserId == LocalPlayer.UserId then + if not FlashlightDebounce then + Flashlight:Toggle() + + FlashlightDebounce = true + task.wait(.10) + FlashlightDebounce = false end - else - warn("hacker") end end) \ No newline at end of file diff --git a/src/client/Player/UI/Crosshair.lua b/src/client/Player/UI/Crosshair.lua index aaf64c1..ab18cbe 100644 --- a/src/client/Player/UI/Crosshair.lua +++ b/src/client/Player/UI/Crosshair.lua @@ -3,6 +3,9 @@ local CrosshairModule = { } CrosshairModule.__index = CrosshairModule +local Storage = game:GetService("ReplicatedStorage") +local Easings = require(Storage:WaitForChild("AlgebraEasings")) + --Use a custom crosshair so we can do effects to it type rbxassetid = string @@ -17,15 +20,24 @@ function CrosshairModule.constructor(PlayerGui: PlayerGui) end function CrosshairModule:Enable() - self.Screen.Enabled = true + (self.Screen :: ScreenGui).Enabled = true end function CrosshairModule:Disable() - self.Screen.Enabled = false + (self.Screen :: ScreenGui).Enabled = false end function CrosshairModule:Change(ID: rbxassetid) - self.Icon.Image = ID or CrosshairModule.Icon + (self.Icon :: ImageLabel).Image = ID or CrosshairModule.Icon +end + +function CrosshairModule:Jump(RootVelocity: Vector3) + local X, Y = RootVelocity.X, RootVelocity.Y; + + (self.Icon :: ImageLabel).Position = UDim2.fromScale( + Y>1 and Easings.Linear(.5,.5+(X/1000),.3) or .5, + math.clamp(.4, .5-(-Y/1000), .6) + ) end return CrosshairModule \ No newline at end of file diff --git a/src/client/Player/UI/Health.lua b/src/client/Player/UI/Health.lua new file mode 100644 index 0000000..e6b783c --- /dev/null +++ b/src/client/Player/UI/Health.lua @@ -0,0 +1,34 @@ +local HealthModule = {} +HealthModule.__index = HealthModule + +function HealthModule.constructor(PlayerGui: PlayerGui) + local HealthGui = PlayerGui:WaitForChild("Health") + local Amount = HealthGui:WaitForChild("Amount") + + return setmetatable({ + HealthGui = HealthGui, + Amount = Amount + }, HealthGui) +end + +function HealthModule:Enable() + HealthModule.Enabled = true +end + +function HealthModule:Disable() + HealthModule.Enabled = false +end + +function HealthModule:DisplayHealth(Amount: number) + self.Amount.Text = tostring(Amount) + + if Amount <= 40 then + self.Amount.TextColor3 = Color3.fromRGB(255,238,0) + elseif Amount <= 20 then + self.Amount.TextColor3 = Color3.fromRGB(255,0,38) + else + self.Amount.TextColor3 = Color3.new(1,1,1) + end +end + +return HealthModule \ No newline at end of file diff --git a/src/client/Player/init.client.lua b/src/client/Player/init.client.lua index 23fa6f9..5e3ac5e 100644 --- a/src/client/Player/init.client.lua +++ b/src/client/Player/init.client.lua @@ -1,11 +1,13 @@ local UI = script:WaitForChild("UI") local CrosshairSettings = require(UI:WaitForChild("Crosshair")) local VignetteSettings = require(UI:WaitForChild("Vignette")) +local HealthSettings = require(UI:WaitForChild("Health")) local CoreGuis = require(script:WaitForChild("CoreGuis")) local Mouse = require(script:WaitForChild("Mouse")) local Players = game:GetService("Players") local Storage = game:GetService("ReplicatedStorage") +local RS = game:GetService("RunService") :: RunService local ClientStorage = Storage:WaitForChild("Client") local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete") @@ -33,7 +35,7 @@ local Crosshair = CrosshairSettings.constructor(PlayerGui) --Keybinds local function CameraBinds() - local CameraBindMap = KeyBindsModule.constructor() + local CameraBindMap = KeyBindsModule.constructor(false) CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function() Camera:ZoomIn(Vignette, Crosshair) @@ -43,9 +45,21 @@ local function CameraBinds() end) end +local function Crosshair3DEffect() + local RootVelocity = Instance.new("BindableEvent") :: BindableEvent + RootVelocity.Name = "RootVelocity" + RootVelocity.Parent = ClientStorage + + RootVelocity.Event:Connect(function(RootVelocity: Vector3) + Crosshair:Jump(RootVelocity) + end) +end + CoreGuis:Off() Camera:FirstPerson() Mouse:DisablePointer() Crosshair:Enable() +HealthSettings:Enable() -CameraBinds() \ No newline at end of file +CameraBinds() +Crosshair3DEffect() \ No newline at end of file diff --git a/src/load/intro/IntroGui.lua b/src/load/intro/IntroGui.lua index 4431935..9c9ef66 100644 --- a/src/load/intro/IntroGui.lua +++ b/src/load/intro/IntroGui.lua @@ -7,7 +7,7 @@ local Storage = game:GetService("ReplicatedStorage") local LoadingFun = true -local function GuiDependencies(IntroGui: ScreenGui): typeof(GuiDependencies) +local function GuiDependencies(IntroGui: ScreenGui) IntroGui.Enabled = true local Frame = IntroGui:WaitForChild("Frame") @@ -86,11 +86,10 @@ local function GUI_LoadFinish(Stepped: Stepped, Gui: GUIs) --We can now access t Gui.IntroGui:Destroy() --We dont need the intro gui anymore end -type GL_Cube = BasePart -type GL_Side = BasePart -type LoadFinishedSignal = RBXScriptSignal +type GL_Cube = Instance +type GL_Side = Instance -return function(IntroGui: ScreenGui, load_elapse_start: number): LoadFinishedSignal +return function(IntroGui: ScreenGui, load_elapse_start: number) local Gui = GuiDependencies(IntroGui) Gui.ViewportCamera.CFrame = CFrame.lookAt(Gui.GL_Cube.Position-Vector3.new(3,-2.5,5), Gui.GL_Cube.Position) @@ -114,7 +113,6 @@ return function(IntroGui: ScreenGui, load_elapse_start: number): LoadFinishedSig if LoadingFun then task.wait(math.max(0, 3-load_elapse)) --Only if you take longer than or exactly 3 seconds to load end - print(load_elapse) GUI_LoadFinish(Stepped, Gui) end) diff --git a/src/load/intro/init.client.lua b/src/load/intro/init.client.lua index b0e5709..b7ed9c7 100644 --- a/src/load/intro/init.client.lua +++ b/src/load/intro/init.client.lua @@ -28,13 +28,13 @@ local function LoadingIntroGUI() end local PlayerGui = Player:WaitForChild("PlayerGui") - IntroGui = PlayerGui:WaitForChild("rhpidframework_intro", 10) + IntroGui = PlayerGui:WaitForChild("rhpidframework_intro", 30) if IntroGui then --Let the magic begin RunIntroGui(IntroGui, load_elapse_start) else - warn("Waited 10 seconds for the intro gui without success") + warn("Waited 30 seconds for the intro gui without success") end end diff --git a/src/server/Elevators/Floors.lua b/src/server/Elevators/Floors.lua index 8a83a0a..4bb2538 100644 --- a/src/server/Elevators/Floors.lua +++ b/src/server/Elevators/Floors.lua @@ -2,17 +2,31 @@ local Floors = {} Floors.__index = Floors local Storage = game:GetService("ReplicatedStorage") +local CS = game:GetService("CollectionService") + local Tags = require(Storage:WaitForChild("Tags")) -function Floors.constructor(NumberOfFloors: number) - return setmetatable({NumberOfFloors = NumberOfFloors}, Floors) +function Floors.constructor(NumberOfFloors: number, Year: string) + local Floors = {} + for i: number = 1, NumberOfFloors do + local FloorTag_1 = CS:GetTagged(`ElevatorDoor_{Year}_Floor{tostring(i)}_1`) + local FloorTag_2 = CS:GetTagged(`ElevatorDoor_{Year}_Floor{tostring(i)}_2`) + if FloorTag_1 then + table.insert(Floors, FloorTag_1) + end + if FloorTag_2 then + table.insert(Floors, FloorTag_2) + end + end + + return setmetatable({ + NumberOfFloors = NumberOfFloors, + Floors = Floors + }, Floors) end ---NumberOfFloors syntax: ElevatorDoor_(year)_Floor(floors amount)_1/2 -function Floors:GetFloors(Year: string) - for i: number = 1, self.NumberOfFloors do - - end +function Floors:GetFloor(Floor: number): Instance? + end return Floors \ No newline at end of file diff --git a/src/server/Elevators/Otis1960/Doors.lua b/src/server/Elevators/Otis1960/Doors.lua index 8e216d5..927be7d 100644 --- a/src/server/Elevators/Otis1960/Doors.lua +++ b/src/server/Elevators/Otis1960/Doors.lua @@ -18,10 +18,11 @@ local Tags = require(Storage:WaitForChild("Tags")) local Floor10_Door1 = Tags.ElevatorDoor_1960_Floor10_1 local Floor10_Door2 = Tags.ElevatorDoor_1960_Floor10_2 +type DoorSensors = { + [string]: Instance +} + function Doors.constructor(ElevatorBox: BasePart, ElevatorDoor1: BasePart, ElevatorDoor2: BasePart, ElevatorDoorSensor: Folder) - type DoorSensors = { - [string]: BasePart - } local DoorTween1 = Tween.constructor(nil, ElevatorDoor1) local DoorTween2 = Tween.constructor(nil, ElevatorDoor2) local DoorSensor: DoorSensors = { @@ -29,7 +30,7 @@ function Doors.constructor(ElevatorBox: BasePart, ElevatorDoor1: BasePart, Eleva End = ElevatorDoorSensor:WaitForChild("End") } - local DoorClosingClick = Instance.new("Sound") + local DoorClosingClick = Instance.new("Sound") :: Sound DoorClosingClick.SoundId = "rbxassetid://16357740945" DoorClosingClick.Volume = .1 DoorClosingClick.Parent = ElevatorDoor2 @@ -66,10 +67,10 @@ local function DoorsAnimationFloor(floor: number, opening: boolean?, activated_v activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle, Enum.EasingDirection.InOut ), Floor10_Door2) - local Door1Tween_Floor: Tween = Floor10_Door1:Start(nil, { + local Door1Tween_Floor: Tween = DoorTween1:Start(nil, { Position = opening and init_closed_door1 or init_opened_door1 }) - local Door2Tween_Floor: Tween = Floor10_Door2:Start(nil, { + local Door2Tween_Floor: Tween = DoorTween2:Start(nil, { Position = opening and init_closed_door1 or init_opened_door1 }) @@ -79,8 +80,8 @@ end local function DoorsAnimation(self, opening: boolean?, activated_via_censor: boolean?) self.ElevatorBox.Anchored = true - local ElevatorDoor1_P = self.ElevatorDoor1.Position - local ElevatorDoor2_P = self.ElevatorDoor2.Position + local ElevatorDoor1_P: Vector3 = self.ElevatorDoor1.Position + local ElevatorDoor2_P: Vector3 = self.ElevatorDoor2.Position local TweenTime = activated_via_censor and sensor_opening_speed or opening and opening_speed or Doors.ElevatorDoorTime @@ -115,7 +116,7 @@ local function DoorsAnimation(self, opening: boolean?, activated_via_censor: boo --Door clicking noise task.delay(Doors.ElevatorDoorTime-.90, function() --is the door close enough to closing? - if init_closed_door2.X-self.ElevatorDoor2.Position.X>5 then + if (init_closed_door2 :: Vector3).X-self.ElevatorDoor2.Position.X>5 then self.DoorClosingClick:Play() end end) @@ -140,12 +141,15 @@ for n: number = 1, #workspace_items do end end -function Doors:DetectSensorHit(DoorTween1, DoorTween2): RBXScriptSignal? - local Step = nil +type this = any --yeah, +type PossibleStepConnection = any + +function Doors:DetectSensorHit(DoorTween1, DoorTween2): RBXScriptSignal + local Step: PossibleStepConnection = nil if Doors.Sensors and Doors.Closed then raycastParams.FilterDescendantsInstances = {self.ElevatorBox, table.unpack(RayIgnoring)} - Step = RS.Stepped:Connect(function(_delta, _dt) + Step = (RS :: RunService).Stepped:Connect(function(_delta, _dt) local DoorSensor = workspace:Raycast(self.DoorSensor.Start.Position, self.DoorSensor.End.Position, raycastParams) if DoorSensor and DoorSensor.Instance and DoorSensor.Instance:IsA("BasePart") then @@ -153,7 +157,7 @@ function Doors:DetectSensorHit(DoorTween1, DoorTween2): RBXScriptSignal? DoorTween1:Pause() DoorTween2:Pause() task.wait(1) --elevators irl have this delay - DoorsAnimation(self, true, true) + DoorsAnimation((self :: this), true, true) -- DoorTween1:Destroy() -- DoorTween2:Destroy() end diff --git a/src/server/Elevators/Otis1960/main.server.lua b/src/server/Elevators/Otis1960/main.server.lua index 1488a11..be8e722 100644 --- a/src/server/Elevators/Otis1960/main.server.lua +++ b/src/server/Elevators/Otis1960/main.server.lua @@ -1,23 +1,23 @@ local Elevator = script.Parent -local Elevators = Elevator.Parent +local Elevators = (Elevator :: Instance).Parent local RS = game:GetService("ReplicatedStorage") local Tags = require(RS:WaitForChild("Tags")) local Leveling = require(Elevators:WaitForChild("Leveling")) local Doors = require(Elevator:WaitForChild("Doors")) +local ElevatorMover = require(Elevators:WaitForChild("Mover")) + +local ElevatorBox_1960 = Tags.ElevatorMover_1960 +local ElevatorBox = Tags.ElevatorMover_1960 :: BasePart +local ElevatorDoor1 = Tags.ElevatorDoor_1960_1 :: BasePart +local ElevatorDoor2 = Tags.ElevatorDoor_1960_2 :: BasePart +local ElevatorDoorSensor = Tags.ElevatorDoor_Sensor_1960 :: Folder -local ElevatorBox_1960: BasePart = Tags.ElevatorMover_1960 local ElevatorBoxStartPos = ElevatorBox_1960.Position -local ElevatorMover = require(Elevators:WaitForChild("Mover")) local _BoxAttachment, BoxAlignPosition, _BoxAlignOrientation = ElevatorMover(ElevatorBox_1960, ElevatorBoxStartPos) -local ElevatorBox: BasePart = Tags.ElevatorMover_1960 -local ElevatorDoor1: BasePart = Tags.ElevatorDoor_1960_1 -local ElevatorDoor2: BasePart = Tags.ElevatorDoor_1960_2 -local ElevatorDoorSensor: Folder = Tags.ElevatorDoor_Sensor_1960 - local ElevatorDoors = Doors.constructor(ElevatorBox, ElevatorDoor1, ElevatorDoor2, ElevatorDoorSensor) local function MoveFloors(level: number) @@ -33,6 +33,8 @@ local function GoTo_Level(requested_level: number) end end +print("[DEBUG]: Tags:",Tags) + -- while true do -- task.wait(2) -- ElevatorDoors:Opening(true) diff --git a/src/server/Studio/Workspace.lua b/src/server/Studio/Workspace.lua index 0248ff8..c7e69e6 100644 --- a/src/server/Studio/Workspace.lua +++ b/src/server/Studio/Workspace.lua @@ -1,3 +1,3 @@ return function() - workspace.Gravity = 150 + workspace.Gravity = 50 end \ No newline at end of file diff --git a/src/shared/AlgebraEasings.lua b/src/shared/AlgebraEasings.lua index 9dcd685..d5d837d 100644 --- a/src/shared/AlgebraEasings.lua +++ b/src/shared/AlgebraEasings.lua @@ -1,14 +1,15 @@ --My versions type EaseFunction = (n: number) -> number +type LinearFunction = (a: number, b: number, t: number) -> number export type EasingStyles = { - Linear: EaseFunction, + Linear: LinearFunction, InOutBack: EaseFunction, OutBounce: EaseFunction } -local Ease: EasingStyles = {} +local Ease = {} :: EasingStyles --Google straight up gives wrong/bad math function Ease.Linear(a,b,t) diff --git a/src/shared/Client/KeyBinds.lua b/src/shared/Client/KeyBinds.lua index 1654a28..5817ded 100644 --- a/src/shared/Client/KeyBinds.lua +++ b/src/shared/Client/KeyBinds.lua @@ -15,14 +15,14 @@ export type InputEnded = RBXScriptConnection type CallbackFunction = () -> () -function BindLink.constructor() --Allow multiple bindings of the same keys, no overwrites +function BindLink.constructor(gameProcessing: boolean) --Allow multiple bindings of the same keys, no overwrites type BindConstructor = { BindMap: KeyBindMap, InputBegan: InputBegan, InputEnded: InputEnded } - local self: BindConstructor = {} + local self = {} :: BindConstructor self.BindMap = { Began = {}, Ended = {} @@ -30,7 +30,7 @@ function BindLink.constructor() --Allow multiple bindings of the same keys, no o --Return these for convenience self.InputBegan = UIS.InputBegan:Connect(function(input, gameProcessedEvent) - if not gameProcessedEvent then + if gameProcessing and gameProcessedEvent or not gameProcessedEvent then local switch = self.BindMap.Began[input.KeyCode] if switch then switch() @@ -40,7 +40,7 @@ function BindLink.constructor() --Allow multiple bindings of the same keys, no o end end) self.InputEnded = UIS.InputEnded:Connect(function(input, gameProcessedEvent) - if not gameProcessedEvent then + if gameProcessing and gameProcessedEvent or not gameProcessedEvent then local switch = self.BindMap.Ended[input.KeyCode] if switch then switch() diff --git a/src/shared/Tags.lua b/src/shared/Tags.lua index d770c6b..6e809cd 100644 --- a/src/shared/Tags.lua +++ b/src/shared/Tags.lua @@ -1,6 +1,6 @@ local CS = game:GetService("CollectionService") -local exports: {[string]: BasePart} = {} +local exports: {[string]: Instance} = {} local AllTags = CS:GetAllTags() for i = 1, #AllTags do