studio entities

This commit is contained in:
2023-12-26 00:31:28 -05:00
parent fbc72eb8cb
commit a3e8bdf35c
5 changed files with 95 additions and 38 deletions

View File

@@ -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

View 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

View 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

View 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

View File

@@ -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