diff --git a/sourcemap.json b/sourcemap.json index 423a74b..5c95e48 100644 --- a/sourcemap.json +++ b/sourcemap.json @@ -1 +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":"Algebra","className":"ModuleScript","filePaths":["src/shared\\Algebra.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":"Enums","className":"ModuleScript","filePaths":["src/shared\\Enums.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":"Tween","className":"ModuleScript","filePaths":["src/shared\\Tween.lua"]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"rapid/server","className":"Actor","children":[{"name":"main","className":"Script","filePaths":["src/server\\main\\init.server.lua"],"children":[{"name":"Characters","className":"ModuleScript","filePaths":["src/server\\main\\Characters\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/server\\main\\Characters\\Actions.lua"]},{"name":"Flashlight","className":"ModuleScript","filePaths":["src/server\\main\\Characters\\Flashlight.lua"]},{"name":"Shadows","className":"ModuleScript","filePaths":["src/server\\main\\Characters\\Shadows.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/server\\main\\Characters\\SpineKinematics.lua"]}]},{"name":"EditorEntities","className":"ModuleScript","filePaths":["src/server\\main\\EditorEntities.lua"]},{"name":"Elevators","className":"Folder","children":[{"name":"Buttons","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Buttons.lua"]},{"name":"Floors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Floors.lua"]},{"name":"Lanterns","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Lanterns.lua"]},{"name":"Mover","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Mover.lua"]},{"name":"Otis1960","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\init.lua"],"children":[{"name":"Doors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Doors.lua"]},{"name":"Leveling","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Leveling.lua"]},{"name":"MovingObjects","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\MovingObjects.lua"]}]},{"name":"TractionRopes","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\TractionRopes.lua"]}]},{"name":"Lighting","className":"ModuleScript","filePaths":["src/server\\main\\Lighting\\init.lua"]},{"name":"Map","className":"Folder","children":[{"name":"Interactions","className":"Folder","children":[{"name":"LightSwitches","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Interactions\\LightSwitches.lua"]}]},{"name":"Prompts","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Prompts.lua"]}]},{"name":"StarterPlayer","className":"ModuleScript","filePaths":["src/server\\main\\StarterPlayer.lua"]},{"name":"Tags","className":"ModuleScript","filePaths":["src/server\\main\\Tags.lua"]},{"name":"Workspace","className":"ModuleScript","filePaths":["src/server\\main\\Workspace.lua"]}]}]}]},{"name":"StarterPlayer","className":"StarterPlayer","children":[{"name":"StarterPlayerScripts","className":"StarterPlayerScripts","children":[{"name":"rapid/client","className":"Actor","children":[{"name":"Player","className":"LocalScript","filePaths":["src/client\\init.client.lua"],"children":[{"name":"Character","className":"ModuleScript","filePaths":["src/client\\Character\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client\\Character\\Actions.lua"]},{"name":"Camera","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\init.lua"],"children":[{"name":"Bobbing","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\Bobbing.lua"]}]},{"name":"Humanoid","className":"ModuleScript","filePaths":["src/client\\Character\\Humanoid.lua"]},{"name":"HumanoidRootPart","className":"ModuleScript","filePaths":["src/client\\Character\\HumanoidRootPart.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client\\Character\\SpineKinematics.lua"]}]},{"name":"CoreGuis","className":"ModuleScript","filePaths":["src/client\\CoreGuis.lua"]},{"name":"GuiService","className":"ModuleScript","filePaths":["src/client\\GuiService.lua"]},{"name":"Mouse","className":"ModuleScript","filePaths":["src/client\\Mouse.lua"]},{"name":"UI","className":"Folder","children":[{"name":"Crosshair","className":"ModuleScript","filePaths":["src/client\\UI\\Crosshair.lua"]},{"name":"Health","className":"ModuleScript","filePaths":["src/client\\UI\\Health.lua"]},{"name":"Vignette","className":"ModuleScript","filePaths":["src/client\\UI\\Vignette.lua"]}]}]}]}]}]}]} \ No newline at end of file +{"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":"Algebra","className":"ModuleScript","filePaths":["src/shared\\Algebra.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":"Enums","className":"ModuleScript","filePaths":["src/shared\\Enums.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":"Tween","className":"ModuleScript","filePaths":["src/shared\\Tween.lua"]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"rapid/server","className":"Actor","children":[{"name":"main","className":"Script","filePaths":["src/server\\main\\init.server.lua"],"children":[{"name":"EditorEntities","className":"ModuleScript","filePaths":["src/server\\main\\EditorEntities.lua"]},{"name":"Elevators","className":"Folder","children":[{"name":"Buttons","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Buttons.lua"]},{"name":"Floors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Floors.lua"]},{"name":"Lanterns","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Lanterns.lua"]},{"name":"Mover","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Mover.lua"]},{"name":"Otis1960","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\init.lua"],"children":[{"name":"Doors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Doors.lua"]},{"name":"Leveling","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Leveling.lua"]},{"name":"MovingObjects","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\MovingObjects.lua"]}]},{"name":"TractionRopes","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\TractionRopes.lua"]}]},{"name":"Lighting","className":"ModuleScript","filePaths":["src/server\\main\\Lighting\\init.lua"]},{"name":"Map","className":"Folder","children":[{"name":"Interactions","className":"Folder","children":[{"name":"LightSwitches","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Interactions\\LightSwitches.lua"]}]},{"name":"Prompts","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Prompts.lua"]}]},{"name":"PlayerAdded","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\init.lua"],"children":[{"name":"Character","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Actions.lua"]},{"name":"Flashlight","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Flashlight.lua"]},{"name":"Shadows","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Shadows.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\SpineKinematics.lua"]}]},{"name":"Users","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Users.lua"]}]},{"name":"StarterPlayer","className":"ModuleScript","filePaths":["src/server\\main\\StarterPlayer.lua"]},{"name":"Tags","className":"ModuleScript","filePaths":["src/server\\main\\Tags.lua"]},{"name":"Workspace","className":"ModuleScript","filePaths":["src/server\\main\\Workspace.lua"]}]}]}]},{"name":"StarterPlayer","className":"StarterPlayer","children":[{"name":"StarterPlayerScripts","className":"StarterPlayerScripts","children":[{"name":"rapid/client","className":"Actor","children":[{"name":"Player","className":"LocalScript","filePaths":["src/client\\init.client.lua"],"children":[{"name":"Character","className":"ModuleScript","filePaths":["src/client\\Character\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client\\Character\\Actions.lua"]},{"name":"Camera","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\init.lua"],"children":[{"name":"Bobbing","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\Bobbing.lua"]}]},{"name":"Humanoid","className":"ModuleScript","filePaths":["src/client\\Character\\Humanoid.lua"]},{"name":"HumanoidRootPart","className":"ModuleScript","filePaths":["src/client\\Character\\HumanoidRootPart.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client\\Character\\SpineKinematics.lua"]}]},{"name":"CoreGuis","className":"ModuleScript","filePaths":["src/client\\CoreGuis.lua"]},{"name":"GuiService","className":"ModuleScript","filePaths":["src/client\\GuiService.lua"]},{"name":"Mouse","className":"ModuleScript","filePaths":["src/client\\Mouse.lua"]},{"name":"UI","className":"Folder","children":[{"name":"Crosshair","className":"ModuleScript","filePaths":["src/client\\UI\\Crosshair.lua"]},{"name":"Health","className":"ModuleScript","filePaths":["src/client\\UI\\Health.lua"]},{"name":"Vignette","className":"ModuleScript","filePaths":["src/client\\UI\\Vignette.lua"]}]}]}]}]}]}]} \ No newline at end of file diff --git a/src/server/main/Characters/init.lua b/src/server/main/Characters/init.lua deleted file mode 100644 index fc09039..0000000 --- a/src/server/main/Characters/init.lua +++ /dev/null @@ -1,84 +0,0 @@ ---!optimize 2 ---!native ---!strict - -type UDP = UnreliableRemoteEvent -type CharacterSharedFolder = Folder - -local Players = game:GetService("Players") - -local Dir = script.Parent -local Character = Dir.Parent -local preprocessor = {} - ---Create the character shared directory here -local CharacterShared = Instance.new("Folder") -CharacterShared.Name = "shared" -CharacterShared.Parent = Character - -function preprocessor.CharacterShared(): Instance - return CharacterShared :: CharacterSharedFolder -end - -_G.include = function(this: LuaSourceContainer, FunName: string, ...) - --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 - else - warn(`Preprocessor append failed "{FunName}"`, debug.traceback()) - return nil - end -end - -local Shadows = require(script:WaitForChild("Shadows")) -local SpineModule = require(script:WaitForChild("SpineKinematics")) -local FlashlightModule = require(script:WaitForChild("Flashlight")) -local ActionsModule = require(script:WaitForChild("Actions")) - -local Head = Character:WaitForChild("Head") -local UpperTorso = Character:WaitForChild("UpperTorso") -local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") - -local LocalPlayer = Players:GetPlayerFromCharacter(Character) - -local CharacterShadows = Shadows.constructor(Character) -local Spine = SpineModule.constructor(Head, UpperTorso) -local Flashlight = FlashlightModule.constructor(LocalPlayer, HumanoidRootPart) -local Actions = ActionsModule.constructor(LocalPlayer, HumanoidRootPart) - -local FlashlightDebounce = false - -CharacterShadows:off() --I plan having 2 player support and characters block a ton of light - -Character.DescendantAdded:Connect(function(Instance) - task.wait() --Wait for the instance to properly replicate? - CharacterShadows:PartToggle(Instance, false) -end) - -local FlashlightCooldown = .10 - -Actions:Add(Enum.KeyCode.F, function(_KeyPressed) - if not FlashlightDebounce then - Flashlight:Toggle() - - FlashlightDebounce = true - task.wait(FlashlightCooldown) - FlashlightDebounce = false - end -end); - -Spine.Remote.OnServerEvent:Connect(function(Messenger: Player, CameraPosition: CFrame, IsFirstPerson: boolean) - if Messenger.UserId == LocalPlayer.UserId then - if SpineModule.Enabled then - Spine:Move(CameraPosition, IsFirstPerson) - else - --reset - print("TODO reached -", script.Name..".lua") - end - else - Messenger:Kick(`"{Messenger.Name}", {Messenger.UserId} r="{Spine.Remote.Name}", 1="{tostring(CameraPosition)}", 2="{tostring(IsFirstPerson)}"`) - end -end) - -_G.include = nil \ No newline at end of file diff --git a/src/server/main/Characters/Actions.lua b/src/server/main/PlayerAdded/Character/Actions.lua similarity index 65% rename from src/server/main/Characters/Actions.lua rename to src/server/main/PlayerAdded/Character/Actions.lua index ff9bef1..3c3c802 100644 --- a/src/server/main/Characters/Actions.lua +++ b/src/server/main/PlayerAdded/Character/Actions.lua @@ -6,6 +6,7 @@ type EventFunction = (KeyPressed: Enum.KeyCode) -> () type ActionsTCP = RBXScriptConnection type LocalPlayer = Player type TCP = RemoteEvent +type CharacterShared = Folder type EventsDict = { [Enum.KeyCode]: EventFunction @@ -20,31 +21,26 @@ type Impl_Constructor = { Remove: (self: ClassConstructor, Key: Enum.KeyCode) -> () } & Impl_Static_Props -type Constructor_Fun = (LocalPlayer: LocalPlayer) -> ClassConstructor +type Constructor_Fun = (CharacterShared: CharacterShared, LocalPlayer: LocalPlayer) -> ClassConstructor type Impl_Static_Props = {} type Constructor_Return_Props = { Events: EventsDict, - CurrentActionsTCP_Event: ActionsTCP? + CurrentActionsTCP_Event: ActionsTCP } +export type ActionsConstructor = ClassConstructor + local Actions = {} :: Impl_Constructor Actions.__index = Actions -local CharacterShared = _G.include(script, "CharacterShared") - -local Remote = Instance.new("RemoteEvent") :: TCP -Remote.Name = "Actions" -Remote.Parent = CharacterShared - -local ActionsTCP_Event: ActionsTCP? - -function Actions.constructor(LocalPlayer: LocalPlayer) +function Actions.constructor(CharacterShared, LocalPlayer) local Events: EventsDict = {} - if ActionsTCP_Event then - warn("[Server Actions]: TCP event was already created, duplicating...", debug.traceback()) - end - ActionsTCP_Event = Remote.OnServerEvent:Connect(function(Messenger: Player, Key: Enum.KeyCode) + local Remote = Instance.new("RemoteEvent") :: TCP + Remote.Name = "Actions" + Remote.Parent = CharacterShared + + local ActionsTCP_Event = Remote.OnServerEvent:Connect(function(Messenger: Player, Key: Enum.KeyCode) if Messenger.UserId == LocalPlayer.UserId then if typeof(Key) == "EnumItem" then local switch = Events[Key] @@ -65,15 +61,15 @@ function Actions.constructor(LocalPlayer: LocalPlayer) }, Actions) end -function Actions:Add(Key: Enum.KeyCode, f: EventFunction) +function Actions:Add(Key, f) self.Events[Key] = f end -function Actions:Remove(Key: Enum.KeyCode) +function Actions:Remove(Key) self.Events[Key] = nil if not next(self.Events) then - (self.CurrentActionsTCP_Event :: ActionsTCP):Disconnect() + self.CurrentActionsTCP_Event:Disconnect() print("[Server Actions]: ") end end diff --git a/src/server/main/Characters/Flashlight.lua b/src/server/main/PlayerAdded/Character/Flashlight.lua similarity index 77% rename from src/server/main/Characters/Flashlight.lua rename to src/server/main/PlayerAdded/Character/Flashlight.lua index 2aa7f38..fcf4d1f 100644 --- a/src/server/main/Characters/Flashlight.lua +++ b/src/server/main/PlayerAdded/Character/Flashlight.lua @@ -7,6 +7,8 @@ type FlashlightUDP = RBXScriptConnection type LocalPlayer = Player type HumanoidRootPart = BasePart type EulerXYZ_struct = {number} +type rbxassetid = string +type CharacterShared = Folder type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor)) type Impl_Constructor = { @@ -18,10 +20,11 @@ type Impl_Constructor = { Toggle: (self: ClassConstructor) -> () } & Impl_Static_Props -type Constructor_Fun = (LocalPlayer: LocalPlayer, HumanoidRootPart: HumanoidRootPart) -> ClassConstructor +type Constructor_Fun = (CharacterShared: CharacterShared, LocalPlayer: LocalPlayer, HumanoidRootPart: HumanoidRootPart) -> ClassConstructor type Impl_Static_Props = { Enabled: boolean, - HeadHeight: number + HeadHeight: number, + ToggleSound: rbxassetid } type Constructor_Return_Props = { FlashlightPart: Part, @@ -29,19 +32,14 @@ type Constructor_Return_Props = { ToggleSound: Sound } +export type FlashlightConstructor = ClassConstructor + local Flashlight = {} :: Impl_Constructor Flashlight.__index = Flashlight -Flashlight.Enabled = false -Flashlight.HeadHeight = 1 - -local CharacterShared = _G.include(script, "CharacterShared") - -local Flashlight_UDP = Instance.new("UnreliableRemoteEvent") :: UDP -Flashlight_UDP.Name = "Flashlight" -Flashlight_UDP.Parent = CharacterShared - -local FlashlightUDP_Event: FlashlightUDP? +Flashlight.Enabled = false +Flashlight.HeadHeight = 1 +Flashlight.ToggleSound = "rbxassetid://16454678462" local function FlashlightPart(HumanoidRootPart: HumanoidRootPart): (Part, SpotLight, Sound) local FlashlightPart = Instance.new("Part") :: Part @@ -63,7 +61,7 @@ local function FlashlightPart(HumanoidRootPart: HumanoidRootPart): (Part, SpotLi local ToggleSound = Instance.new("Sound") :: Sound ToggleSound.Name = "Flashlight" - ToggleSound.SoundId = "rbxassetid://16454678462" + ToggleSound.SoundId = Flashlight.ToggleSound ToggleSound.Volume = .5 ToggleSound.Parent = FlashlightPart @@ -72,13 +70,14 @@ local function FlashlightPart(HumanoidRootPart: HumanoidRootPart): (Part, SpotLi return FlashlightPart, SpotLight, ToggleSound end -function Flashlight.constructor(LocalPlayer: LocalPlayer, HumanoidRootPart: HumanoidRootPart) +function Flashlight.constructor(CharacterShared, LocalPlayer, HumanoidRootPart) local FlashlightPart, SpotLight, ToggleSound = FlashlightPart(HumanoidRootPart) - if FlashlightUDP_Event then - warn("[Server Flashlight]: UDP event was already created, duplicating...", debug.traceback()) - end - FlashlightUDP_Event = Flashlight_UDP.OnServerEvent:Connect(function(Messenger: Player, CameraEuler: EulerXYZ_struct) + local Flashlight_UDP = Instance.new("UnreliableRemoteEvent") :: UDP + Flashlight_UDP.Name = "Flashlight" + Flashlight_UDP.Parent = CharacterShared + + Flashlight_UDP.OnServerEvent:Connect(function(Messenger: Player, CameraEuler: EulerXYZ_struct) if Messenger.UserId == LocalPlayer.UserId then if CameraEuler[4] and CameraEuler[4] == 3 then local RootPartCFrame = HumanoidRootPart.CFrame diff --git a/src/server/main/Characters/Shadows.lua b/src/server/main/PlayerAdded/Character/Shadows.lua similarity index 73% rename from src/server/main/Characters/Shadows.lua rename to src/server/main/PlayerAdded/Character/Shadows.lua index 4aeba76..621f894 100644 --- a/src/server/main/Characters/Shadows.lua +++ b/src/server/main/PlayerAdded/Character/Shadows.lua @@ -4,12 +4,14 @@ --This really should be only client +type Character = Model + 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) -> (), + PartToggle: (self: ClassConstructor, Instance: Instance, CastingShadow: boolean) -> (), Remove: (self: ClassConstructor, Key: Enum.KeyCode) -> (), on: (self: ClassConstructor) -> (), off: (self: ClassConstructor) -> () @@ -20,27 +22,28 @@ type Constructor_Return_Props = { Character: Character } +export type ShadowsConstructor = ClassConstructor + local Shadows = {} :: Impl_Constructor Shadows.__index = Shadows -type Character = Model - -function Shadows.constructor(Character: Character) +function Shadows.constructor(Character) return setmetatable({ Character = Character }, Shadows) end -function Shadows:PartToggle(Instance: BasePart, CastingShadow: boolean) - if Instance:IsA("BasePart") then --not 100%, but im sure types are only in effect on the editor side +function Shadows:PartToggle(Instance, CastingShadow) + if Instance:IsA("BasePart") then Instance.CastShadow = CastingShadow end end local function CharacterShadows(self: ClassConstructor, enabled: boolean) local CharacterDescendants = self.Character:GetDescendants() - for i = 1, #CharacterDescendants do - self:PartToggle(CharacterDescendants[i] :: BasePart, enabled) + + for n: number = 1, #CharacterDescendants do + self:PartToggle(CharacterDescendants[n] :: BasePart, enabled) end end diff --git a/src/server/main/Characters/SpineKinematics.lua b/src/server/main/PlayerAdded/Character/SpineKinematics.lua similarity index 95% rename from src/server/main/Characters/SpineKinematics.lua rename to src/server/main/PlayerAdded/Character/SpineKinematics.lua index 4b7e750..3f089c6 100644 --- a/src/server/main/Characters/SpineKinematics.lua +++ b/src/server/main/PlayerAdded/Character/SpineKinematics.lua @@ -38,6 +38,8 @@ type Constructor_Return_Props = { WaistC0: WaistC0 } +export type SpineKinematicsConstructor = ClassConstructor + local Spine = {} :: Impl_Constructor Spine.__index = Spine @@ -48,7 +50,7 @@ local Remote = Instance.new("UnreliableRemoteEvent") :: UDP Remote.Name = "SpineStream" Remote.Parent = _G.include(script, "CharacterShared") -function Spine.constructor(Head: Head, UpperTorso: UpperTorso) +function Spine.constructor(Head, UpperTorso) local self = {} self.Head = Head self.UpperTorso = UpperTorso @@ -57,6 +59,7 @@ function Spine.constructor(Head: Head, UpperTorso: UpperTorso) self.Remote = Remote self.NeckC0 = (self.Neck :: Motor6D).C0 self.WaistC0 = (self.Neck :: Motor6D).C0 + return setmetatable(self, Spine) end @@ -92,7 +95,7 @@ local function SpineMovement(self: ClassConstructor, CameraCFrame: CFrame, IsFir } end -function Spine:Move(CameraCFrame: CFrame, IsFirstPerson: boolean) +function Spine:Move(CameraCFrame, IsFirstPerson) local SpineIK = SpineMovement(self, CameraCFrame, IsFirstPerson) self.Neck.C0 = self.Neck.C0:Lerp(self.NeckC0*SpineIK.Neck, .9) diff --git a/src/server/main/PlayerAdded/Character/init.lua b/src/server/main/PlayerAdded/Character/init.lua new file mode 100644 index 0000000..6afac48 --- /dev/null +++ b/src/server/main/PlayerAdded/Character/init.lua @@ -0,0 +1,102 @@ +--!optimize 2 +--!native +--!strict + +local Shadows = require(script:WaitForChild("Shadows")) +local SpineModule = require(script:WaitForChild("SpineKinematics")) +local FlashlightModule = require(script:WaitForChild("Flashlight")) +local ActionsModule = require(script:WaitForChild("Actions")) + +type UDP = UnreliableRemoteEvent +type CharacterSharedFolder = Folder +type Character = Model +type HumanoidRootPart = BasePart + +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 = (Character: Character) -> ClassConstructor +type Impl_Static_Props = { + FlashlightDebounce: boolean, + FlashlightCooldown: number, + KeyBinds: { + Flashlight: Enum.KeyCode + } +} + +type Constructor_Return_Props = { + CharacterShared: CharacterSharedFolder, + CharacterShadows: Shadows.ShadowsConstructor, + Spine: SpineModule.SpineKinematicsConstructor, + Flashlight: FlashlightModule.FlashlightConstructor, + Actions: ActionsModule.ActionsConstructor +} + +local Character = {} :: Impl_Constructor +Character.__index = Character + +local Players = game:GetService("Players") + +Character.FlashlightDebounce = false +Character.FlashlightCooldown = .10 + +Character.KeyBinds = { + Flashlight = Enum.KeyCode.F +} + +function Character.constructor(CharacterModel) + local Player = Players:GetPlayerFromCharacter(CharacterModel) + + local self = {} + self.CharacterShared = Instance.new("Folder") + self.CharacterShared.Name = "shared" + self.CharacterShared.Parent = CharacterModel + + local Head = CharacterModel:WaitForChild("Head") :: BasePart + local UpperTorso = CharacterModel:WaitForChild("UpperTorso") :: BasePart + local HumanoidRootPart = CharacterModel:WaitForChild("HumanoidRootPart") :: HumanoidRootPart + + self.CharacterShadows = Shadows.constructor(CharacterModel) + self.Spine = SpineModule.constructor(Head, UpperTorso) + self.Flashlight = FlashlightModule.constructor(self.CharacterShared, Player, HumanoidRootPart) + self.Actions = ActionsModule.constructor(self.CharacterShared, Player) + + self.CharacterShadows:off() --I plan having 2+ player support and characters block a ton of light + CharacterModel.DescendantAdded:Connect(function(Instance) + task.wait() --Wait for the instance to properly replicate... + self.CharacterShadows:PartToggle(Instance, false) + end) + + self.Actions:Add(Character.KeyBinds.Flashlight, function(_KeyPressed) + if not Character.FlashlightDebounce then + self.Flashlight:Toggle() + + Character.FlashlightDebounce = true + task.wait(Character.FlashlightCooldown) + Character.FlashlightDebounce = false + end + end) + + self.Spine.Remote.OnServerEvent:Connect(function(Messenger: Player, CameraPosition: CFrame, IsFirstPerson: boolean) + if Messenger.UserId == Player.UserId then + if SpineModule.Enabled then + self.Spine:Move(CameraPosition, IsFirstPerson) + else + --reset + print("TODO reached -", script.Name..".lua") + end + else + Messenger:Kick(`"{Messenger.Name}", {Messenger.UserId} r="{self.Spine.Remote.Name}", 1="{tostring(CameraPosition)}", 2="{tostring(IsFirstPerson)}"`) + end + end) + + return setmetatable(self, Character) +end + +return Character \ No newline at end of file diff --git a/src/server/main/PlayerAdded/Users.lua b/src/server/main/PlayerAdded/Users.lua new file mode 100644 index 0000000..6a264a5 --- /dev/null +++ b/src/server/main/PlayerAdded/Users.lua @@ -0,0 +1,15 @@ +--!optimize 2 +--!native +--!strict + +type Users = { + Admin: {number}, + Banned: {number} +} + +local Users = { + Admin = {}, + Banned = {} +} + +return Users \ No newline at end of file diff --git a/src/server/main/PlayerAdded/init.lua b/src/server/main/PlayerAdded/init.lua new file mode 100644 index 0000000..6402b02 --- /dev/null +++ b/src/server/main/PlayerAdded/init.lua @@ -0,0 +1,40 @@ +--!optimize 2 +--!native +--!strict + +type Character = Model + +local Players = game:GetService("Players") + +local Users = require(script:WaitForChild("Users")) +local CharacterModule = require(script:WaitForChild("Character")) + +local function LoadCharacter(Player: Player) + CharacterModule.constructor(Player.Character or Player.CharacterAdded:Wait()) + Player.CharacterAdded:Connect(CharacterModule.constructor) +end + +local function AdminUser(Player: Player) + print(`[Admin] "{Player.Name}" | {tostring(Player.UserId)} has logged`) + + Player.Chatted:Connect(function(Message: string, _: Player?) + + end) +end + +return Players.PlayerAdded:Connect(function(Player: Player) + for n: number = 1, #Users.Banned do + if Player.UserId ~= Users.Banned[n] then + for n2: number = 1, #Users.Admin do + if Player.UserId == Users.Admin[n2] then + AdminUser(Player) + break + end + end + + LoadCharacter(Player) + else + Player:Kick() + end + end +end) \ No newline at end of file diff --git a/src/server/main/init.server.lua b/src/server/main/init.server.lua index e9cbb3b..0bab62d 100644 --- a/src/server/main/init.server.lua +++ b/src/server/main/init.server.lua @@ -2,25 +2,24 @@ --!native --!strict -local ShowEditorEntities = game:GetService("RunService"):IsServer() +local ShowEditorEntities = game:GetService("RunService"):IsStudio() local Storage = game:GetService("ReplicatedStorage") -local Enums = require(Storage:WaitForChild("Enums")) - -local Elevators = script:WaitForChild("Elevators") -local Maps = script:WaitForChild("Map") - -local Interactions = Maps:WaitForChild("Interactions") -local LightSwitches = require(Interactions:WaitForChild("LightSwitches")) - -local Otis1960_Module = require(Elevators:WaitForChild("Otis1960")) +local _PlayerAdded = require(script:WaitForChild("PlayerAdded")) local TagsModule = require(script:WaitForChild("Tags")) local HideEditorEntities = require(script:WaitForChild("EditorEntities")) local Lighting_Stuff = require(script:WaitForChild("Lighting")) local Workspace_Stuff = require(script:WaitForChild("Workspace")) local StarterPlayer_Stuff = require(script:WaitForChild("StarterPlayer")) +local Elevators = script:WaitForChild("Elevators") +local Maps = script:WaitForChild("Map") +local Interactions = Maps:WaitForChild("Interactions") +local Enums = require(Storage:WaitForChild("Enums")) +local LightSwitches = require(Interactions:WaitForChild("LightSwitches")) +local Otis1960_Module = require(Elevators:WaitForChild("Otis1960")) + local TagsConstructor = TagsModule.constructor() print("[DEBUG] Tags=", TagsConstructor.__export)