mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
studio entities
This commit is contained in:
@@ -44,10 +44,15 @@ function Animations.Idle(t: tick, dt: deltatime)
|
||||
end
|
||||
|
||||
function Animations.Walk(t: tick, dt: deltatime)
|
||||
-- return ANG(
|
||||
-- math.rad(-10*math.cos(t)/2),
|
||||
-- 0,
|
||||
-- math.rad(5*math.cos(t)/2)
|
||||
-- )
|
||||
return ANG(
|
||||
math.rad(-10*math.cos(t)/2),
|
||||
0,
|
||||
math.rad(5*math.cos(t)/2)
|
||||
0,
|
||||
0
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
55
src/server/Studio/EditorEntities.lua
Normal file
55
src/server/Studio/EditorEntities.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
--All debugging objects such as light source indicating objects will be turned invisible
|
||||
|
||||
local StudioEntities = {
|
||||
IndexedEntities = {}
|
||||
}
|
||||
|
||||
local function HidePart(Part: BasePart, enabled: boolean)
|
||||
Part.Transparency = enabled and 1 or .9
|
||||
Part.CanCollide = enabled
|
||||
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 EditorEntities = {
|
||||
["LightSource"] = HidePart,
|
||||
["PulleyRopeContact"] = HidePart,
|
||||
["BarrierCollision"] = HideBarrierCollision
|
||||
}
|
||||
|
||||
type IndexedEntities = {Instance}
|
||||
|
||||
function StudioEntities.indexAll(enabled: boolean): IndexedEntities
|
||||
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: Instance = EditorEntities[Item.Name]
|
||||
if Case then
|
||||
table.insert(StudioEntities.IndexedEntities, Item)
|
||||
Case(Item, enabled)
|
||||
end
|
||||
|
||||
--Do micro optimizations here
|
||||
if Item:IsA("BasePart") then
|
||||
Item.CanTouch = false
|
||||
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
|
||||
16
src/server/Studio/Lighting.lua
Normal file
16
src/server/Studio/Lighting.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
local Lighting = game:GetService("Lighting")
|
||||
|
||||
local PropsTree = {
|
||||
|
||||
}
|
||||
|
||||
return function()
|
||||
for Light_Prop, Light_Value in PropsTree do
|
||||
local changed, err = pcall(function()
|
||||
Lighting[Light_Prop] = Light_Value
|
||||
end)
|
||||
if not changed then
|
||||
warn("Server Lighting:", err, debug.traceback())
|
||||
end
|
||||
end
|
||||
end
|
||||
17
src/server/Studio/init.server.lua
Normal file
17
src/server/Studio/init.server.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local HideEditorEntities = require(script:WaitForChild("EditorEntities"))
|
||||
local Lighting = require(script:WaitForChild("Lighting"))
|
||||
|
||||
local RS = game:GetService("RunService")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local ServerStorage = Storage:WaitForChild("Server")
|
||||
|
||||
local Bind = Instance.new("BindableFunction")
|
||||
Bind.Name = "StudioIndexedEntities"
|
||||
Bind.Parent = ServerStorage
|
||||
|
||||
HideEditorEntities.indexAll(not RS:IsStudio())
|
||||
|
||||
Bind.OnInvoke = function()
|
||||
return HideEditorEntities.IndexedEntities
|
||||
end
|
||||
@@ -1,36 +0,0 @@
|
||||
--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 HidePart(Part: BasePart)
|
||||
Part.Transparency = 1
|
||||
Part.CanCollide = false
|
||||
Part.CastShadow = false
|
||||
end
|
||||
|
||||
local function HideBarrierCollision(Part: BasePart)
|
||||
Part.Transparency = 1
|
||||
Part.CanCollide = true
|
||||
Part.CastShadow = false
|
||||
end
|
||||
|
||||
local SwitchEntities = {
|
||||
["LightSource"] = HidePart,
|
||||
["PulleyRopeContact"] = HidePart,
|
||||
["BarrierCollision"] = HideBarrierCollision
|
||||
}
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user