mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-15 21:31:54 +00:00
Tag removal and new serverside structure
This commit is contained in:
114
src/server/main/EditorEntities.lua
Normal file
114
src/server/main/EditorEntities.lua
Normal file
@@ -0,0 +1,114 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
--All debugging objects such as light source indicating objects will be turned invisible
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local CS = game:GetService("CollectionService")
|
||||
|
||||
export type Entities = {
|
||||
IndexedEntities: {Instance}
|
||||
}
|
||||
local StudioEntities = {
|
||||
IndexedEntities = {}
|
||||
}
|
||||
|
||||
local function HidePart(Part: BasePart, enabled: boolean)
|
||||
Part.Transparency = enabled and 1 or .9
|
||||
Part.CanCollide = false
|
||||
Part.CastShadow = false
|
||||
end
|
||||
|
||||
local function HideBarrierCollision(Part: BasePart, enabled: boolean)
|
||||
Part.Transparency = enabled and 1 or .9
|
||||
Part.CastShadow = false
|
||||
Part.CanCollide = true
|
||||
end
|
||||
|
||||
local function HideRaycastContainers(Folder: Folder, enabled: boolean)
|
||||
local End = Folder:WaitForChild("End") :: BasePart
|
||||
local Start = Folder:WaitForChild("Start") :: BasePart
|
||||
|
||||
End.CanCollide = false
|
||||
End.CastShadow = false
|
||||
End.Transparency = enabled and 1 or .9
|
||||
Start.CanCollide = false
|
||||
Start.CastShadow = false
|
||||
Start.Transparency = enabled and 1 or .9
|
||||
end
|
||||
|
||||
local function HideLadderContact(Part: BasePart, enabled: boolean)
|
||||
Part.Transparency = enabled and 1 or .9
|
||||
Part.CanCollide = true
|
||||
Part.CastShadow = false
|
||||
end
|
||||
|
||||
local EditorEntities = {
|
||||
["LightSource"] = HidePart,
|
||||
["PulleyRopeContact"] = HidePart,
|
||||
["BarrierCollision"] = HideBarrierCollision,
|
||||
["StairSource"] = HideBarrierCollision,
|
||||
["RaycastContainer"] = HideRaycastContainers,
|
||||
["LadderContact"] = HideLadderContact
|
||||
}
|
||||
|
||||
type HideEditor = (a1: BasePart | Folder, a2: boolean) -> ()
|
||||
type LuaChangeableContainer = Script | LocalScript
|
||||
|
||||
function StudioEntities.indexAll(enabled: boolean): Entities
|
||||
if #StudioEntities.IndexedEntities == 0 then
|
||||
--Run when the server starts
|
||||
local WorkspaceEnt = workspace:GetDescendants()
|
||||
|
||||
for i = 1, #WorkspaceEnt do
|
||||
local Item: Instance = WorkspaceEnt[i]
|
||||
local Case: HideEditor = EditorEntities[Item.Name]
|
||||
if Case then
|
||||
table.insert(StudioEntities.IndexedEntities, Item)
|
||||
Case(Item, enabled)
|
||||
end
|
||||
|
||||
if Item:IsA("BasePart") then
|
||||
Item.CanTouch = false --Do micro optimizations
|
||||
Item.Locked = true
|
||||
|
||||
--Security from exploiters
|
||||
if not Item.Anchored and table.find(CS:GetTags(Item), "ServerGuard_Physics") then
|
||||
local succ, err = pcall(Item.SetNetworkOwner, Item, nil)
|
||||
if succ then
|
||||
CS:RemoveTag(Item, "ServerGuard_Physics")
|
||||
print(`[Server Physics Guard]: "{Item}" Networking -> "{Item:GetNetworkOwner()}", {Item:GetFullName()}`)
|
||||
else
|
||||
warn(err)
|
||||
end
|
||||
end
|
||||
elseif Item:IsA("LuaSourceContainer") then --Cant allow scripts outside of the framework
|
||||
--mini algorthim to see if the script is part of the rhpid-framework character or not
|
||||
local Model = Item:FindFirstAncestorOfClass("Model")
|
||||
|
||||
if not Players:GetPlayerFromCharacter(Model) then
|
||||
pcall(function()
|
||||
(Item :: LuaChangeableContainer).Enabled = false
|
||||
end)
|
||||
Item:Destroy()
|
||||
warn(`Script: "{Item.Name}" ({Item.ClassName}) was removed because it was outside of the rhpid-framework boundries,`, Item:GetFullName())
|
||||
end
|
||||
end
|
||||
|
||||
if table.find(CS:GetTags(Item), "ServerGuard_Physics") then
|
||||
warn(`[Server Physics Guard]: present on a non BasePart, "{Item}", {Item:GetFullName()}`)
|
||||
CS:RemoveTag(Item, "ServerGuard_Physics")
|
||||
end
|
||||
end
|
||||
else
|
||||
for i = 1, #StudioEntities.IndexedEntities do
|
||||
local Entity: Instance = EditorEntities[i]
|
||||
EditorEntities[Entity.Name](Entity, enabled)
|
||||
end
|
||||
end
|
||||
|
||||
return StudioEntities.IndexedEntities
|
||||
end
|
||||
|
||||
return StudioEntities
|
||||
Reference in New Issue
Block a user