mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
New game file structure
Scratch making the framework/engine open source for now until i figure out a better file structure that will work with Rojo
This commit is contained in:
@@ -2,16 +2,21 @@
|
||||
"name": "ElevatorGame",
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
|
||||
"ReplicatedStorage": {
|
||||
"$path": "src/shared"
|
||||
},
|
||||
"ServerScriptService": {
|
||||
"$path": "src/server"
|
||||
},
|
||||
|
||||
"StarterPlayer": {
|
||||
"StarterPlayerScripts": {
|
||||
"Player": {
|
||||
"$path": "src/client/Player"
|
||||
}
|
||||
},
|
||||
|
||||
"StarterCharacterScripts": {
|
||||
"$path": "src/client/Character"
|
||||
}
|
||||
|
||||
21
src/client/Character/Client/HumanoidRootPart.lua
Normal file
21
src/client/Character/Client/HumanoidRootPart.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
local HumanoidRPSettings = {}
|
||||
HumanoidRPSettings.__index = HumanoidRPSettings
|
||||
|
||||
function HumanoidRPSettings.constructor(HumanoidRootPart: BasePart)
|
||||
return setmetatable({
|
||||
HumanoidRootPart = HumanoidRootPart
|
||||
}, HumanoidRPSettings)
|
||||
end
|
||||
|
||||
function HumanoidRPSettings:DisableRobloxSounds()
|
||||
local HRP_objects = self.HumanoidRootPart:GetChildren()
|
||||
for i = 1, #HRP_objects do
|
||||
local Object = HRP_objects[i]
|
||||
|
||||
if Object:IsA("Sound") then
|
||||
Object.SoundId = "rbxassetid://0"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return HumanoidRPSettings
|
||||
8
src/client/Character/Client/init.client.lua
Normal file
8
src/client/Character/Client/init.client.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
|
||||
|
||||
local Character = script.Parent
|
||||
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
|
||||
|
||||
local HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart)
|
||||
|
||||
HRPSettings:DisableRobloxSounds()
|
||||
16
src/client/Character/Server/Humanoid.lua
Normal file
16
src/client/Character/Server/Humanoid.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
local HumanoidModule = {}
|
||||
HumanoidModule.__index = HumanoidModule
|
||||
|
||||
type WalkSpeed = number | nil
|
||||
|
||||
function HumanoidModule.constructor(Humanoid: Humanoid)
|
||||
return setmetatable({
|
||||
Humanoid = Humanoid
|
||||
}, HumanoidModule)
|
||||
end
|
||||
|
||||
function HumanoidModule:SetWalkSpeed(Speed: WalkSpeed)
|
||||
self.Humanoid.WalkSpeed = Speed or 16
|
||||
end
|
||||
|
||||
return HumanoidModule
|
||||
36
src/client/Character/Server/Shadows.lua
Normal file
36
src/client/Character/Server/Shadows.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
--This really should be only client
|
||||
|
||||
local Shadows = {}
|
||||
Shadows.__index = Shadows
|
||||
|
||||
type Character = Model
|
||||
|
||||
function Shadows.constructor(Character: 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
|
||||
Instance.CastShadow = CastingShadow
|
||||
end
|
||||
end
|
||||
|
||||
local function CharacterShadows(self, enabled: boolean)
|
||||
local CharacterDescendants = self.Character:GetDescendants()
|
||||
for i = 1, #CharacterDescendants do
|
||||
self:PartToggle(CharacterDescendants[i], enabled)
|
||||
end
|
||||
end
|
||||
|
||||
function Shadows:on()
|
||||
CharacterShadows(self, true)
|
||||
end
|
||||
|
||||
function Shadows:off()
|
||||
CharacterShadows(self, false)
|
||||
end
|
||||
|
||||
|
||||
return Shadows
|
||||
17
src/client/Character/Server/init.server.lua
Normal file
17
src/client/Character/Server/init.server.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local Character = script.Parent
|
||||
|
||||
local Shadows = require(script:WaitForChild("Shadows"))
|
||||
local HumanoidModule = require(script:WaitForChild("Humanoid"))
|
||||
|
||||
local Humanoid = Character:WaitForChild("Humanoid")
|
||||
|
||||
local CharacterShadows = Shadows.constructor(Character)
|
||||
local HumanoidSettings = HumanoidModule.constructor(Humanoid)
|
||||
|
||||
CharacterShadows:off() --I plan to have 2 player support and characters block a ton of light
|
||||
HumanoidSettings:SetWalkSpeed(12)
|
||||
|
||||
Character.DescendantAdded:Connect(function(Instance)
|
||||
task.wait() --Wait for the instance to properly replicate?
|
||||
CharacterShadows:PartToggle(Instance, false)
|
||||
end)
|
||||
19
src/client/Player/Camera/init.lua
Normal file
19
src/client/Player/Camera/init.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
local Camera = {
|
||||
FOV = {
|
||||
Default = 70,
|
||||
Zoomed = 50
|
||||
}
|
||||
}
|
||||
Camera.__index = Camera
|
||||
|
||||
function Camera.constructor(Player: Player)
|
||||
return setmetatable({
|
||||
Player = Player
|
||||
}, Camera)
|
||||
end
|
||||
|
||||
function Camera:LockFirstPerson()
|
||||
self.Player.CameraMode = Enum.CameraMode.LockFirstPerson
|
||||
end
|
||||
|
||||
return Camera
|
||||
30
src/client/Player/CoreGuis.lua
Normal file
30
src/client/Player/CoreGuis.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local CoreGuis = {
|
||||
IncludeReset = true --disable the reset button?
|
||||
}
|
||||
CoreGuis.__index = CoreGuis
|
||||
|
||||
local SG = game:GetService("StarterGui")
|
||||
|
||||
local function DisableReset(enabled: boolean)
|
||||
--Roblox actually doesn't register this fast enough so we gotta resort to cringe tactics
|
||||
repeat
|
||||
local PossibleMemoryLeak = pcall(SG.SetCore, SG, "ResetButtonCallback", enabled)
|
||||
task.wait()
|
||||
until PossibleMemoryLeak
|
||||
end
|
||||
|
||||
function CoreGuis:on()
|
||||
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
|
||||
if CoreGuis.IncludeReset then
|
||||
DisableReset(true)
|
||||
end
|
||||
end
|
||||
|
||||
function CoreGuis:off()
|
||||
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
|
||||
if CoreGuis.IncludeReset then
|
||||
DisableReset(false)
|
||||
end
|
||||
end
|
||||
|
||||
return CoreGuis
|
||||
33
src/client/Player/Crosshair.lua
Normal file
33
src/client/Player/Crosshair.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
local Crosshair = {
|
||||
Icon = "rbxassetid://12643750723"
|
||||
}
|
||||
Crosshair.__index = Crosshair
|
||||
|
||||
--Use a custom crosshair so we can do effects to it
|
||||
|
||||
function Crosshair.constructor(Player: Player)
|
||||
local ScreenGui = Instance.new("ScreenGui")
|
||||
ScreenGui.ResetOnSpawn = false
|
||||
ScreenGui.Name = "Crosshair"
|
||||
|
||||
local CrosshairIcon = Instance.new("ImageLabel")
|
||||
CrosshairIcon.AnchorPoint = Vector2.new(.5,.5)
|
||||
CrosshairIcon.Position = UDim2.fromScale(.5,.5)
|
||||
CrosshairIcon.Size = UDim2.fromScale(.4,.4)
|
||||
CrosshairIcon.Image = Crosshair.Icon
|
||||
CrosshairIcon.BackgroundTransparency = 1
|
||||
CrosshairIcon.ScaleType = Enum.ScaleType.Fit
|
||||
CrosshairIcon.Parent = ScreenGui
|
||||
|
||||
return setmetatable({
|
||||
Player = Player,
|
||||
ScreenGui = ScreenGui,
|
||||
CrosshairIcon = CrosshairIcon
|
||||
}, Crosshair)
|
||||
end
|
||||
|
||||
function Crosshair:Spawn()
|
||||
self.ScreenGui.Parent = self.Player:WaitForChild("PlayerGui")
|
||||
end
|
||||
|
||||
return Crosshair
|
||||
13
src/client/Player/Mouse.lua
Normal file
13
src/client/Player/Mouse.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
local Mouse = {}
|
||||
|
||||
local UIS = game:GetService("UserInputService")
|
||||
|
||||
function Mouse:DisablePointer()
|
||||
UIS.MouseIconEnabled = false
|
||||
end
|
||||
|
||||
function Mouse:EnablePointer()
|
||||
UIS.MouseIconEnabled = true
|
||||
end
|
||||
|
||||
return Mouse
|
||||
15
src/client/Player/init.client.lua
Normal file
15
src/client/Player/init.client.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
||||
local Mouse = require(script:WaitForChild("Mouse"))
|
||||
local CameraSettings = require(script:WaitForChild("Camera"))
|
||||
local Crosshair = require(script:WaitForChild("Crosshair"))
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local Player = Players.LocalPlayer
|
||||
|
||||
local Camera = CameraSettings.constructor(Player)
|
||||
local CrosshairObject = Crosshair.constructor(Player)
|
||||
|
||||
CoreGuis:off()
|
||||
Mouse:DisablePointer()
|
||||
Camera:LockFirstPerson()
|
||||
CrosshairObject:Spawn()
|
||||
0
src/server/Elevators/Otis1960/main.server.lua
Normal file
0
src/server/Elevators/Otis1960/main.server.lua
Normal file
33
src/server/StudioEntities.server.lua
Normal file
33
src/server/StudioEntities.server.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
--All debugging objects such as light source indicating objects will be turned invisible
|
||||
|
||||
local EntityDebug = game:GetService("RunService"):IsStudio()
|
||||
-- local EntityDebug = false
|
||||
|
||||
local WorkspaceEnt = workspace:GetDescendants()
|
||||
|
||||
local function DisablePart(Part: BasePart)
|
||||
Part.Transparency = 1
|
||||
Part.CanCollide = false
|
||||
Part.CastShadow = false
|
||||
end
|
||||
|
||||
local SwitchEntities = {
|
||||
["LightSource"] = function(Part: BasePart)
|
||||
DisablePart(Part)
|
||||
end,
|
||||
["PulleyRopeContact"] = function(Part: BasePart)
|
||||
DisablePart(Part)
|
||||
end
|
||||
}
|
||||
|
||||
if not EntityDebug then
|
||||
for i = 1, #WorkspaceEnt do
|
||||
local Item = WorkspaceEnt[i]
|
||||
local Case = SwitchEntities[Item.Name]
|
||||
if Case then
|
||||
Case(Item)
|
||||
else
|
||||
-- SwitchEntities.default()
|
||||
end
|
||||
end
|
||||
end
|
||||
34
src/shared/Client/KeyBinds.lua
Normal file
34
src/shared/Client/KeyBinds.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
local Binds = {}
|
||||
Binds.__index = Binds
|
||||
|
||||
local BindsMap = {
|
||||
Keys = {}
|
||||
}
|
||||
BindsMap.__index = BindsMap
|
||||
|
||||
local UIS = game:GetService("UserInputService")
|
||||
|
||||
function Binds.constructor() --Allow multiple bindings of the same keys, no overwrites
|
||||
return setmetatable({}, BindsMap)
|
||||
end
|
||||
|
||||
function BindsMap.new()
|
||||
local InputBegan = UIS.InputBegan:Connect(function(input, gameProcessedEvent)
|
||||
if not gameProcessedEvent then
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
local InputEnded = UIS.InputEnded:Connect(function(input, gameProcessedEvent)
|
||||
if not gameProcessedEvent then
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
return setmetatable({
|
||||
InputBegan = InputBegan,
|
||||
InputEnded = InputEnded
|
||||
}, BindsMap)
|
||||
end
|
||||
|
||||
return Binds
|
||||
Reference in New Issue
Block a user