2026-05-02 23:53:49 +02:00

56 lines
1.2 KiB
Plaintext

local MapManager = {}
local SynchHandler = require(script.SyncHandler)
local ServerStorage = game:GetService("ServerStorage")
local sAssets = ServerStorage.Assets
local sMaps = sAssets.Maps
local ServerScriptService = game:GetService("ServerScriptService")
local sModules = ServerScriptService.Modules
local DestroyablePlatform = require(sModules.Classes.GameObject.DestroyablePlatform)
MapManager.MAP_LOAD_TIME = 5
MapManager.Structures = {}
type Map = typeof(sMaps.LayoutMap1)
function MapManager.SpawnMap(name : string)
name = name or "LayoutMap1"
local map : Map = sMaps:FindFirstChild(name)
if not map then
map = sMaps:FindFirstChildOfClass("Model")
end
map.ModelStreamingMode = Enum.ModelStreamingMode.Atomic
map = map:Clone()
map.Parent = workspace.Map
map:SetAttribute("MapName",map.Name)
map.Name = "Map"
SynchHandler.AddSyncPart(map)
SetupPlatforms(map)
end
function SetupPlatforms(map : Map)
for _,v : Model in pairs(map.DestroyablePlatforms:GetChildren()) do
task.wait()
local newPlat = DestroyablePlatform.new(nil,v)
newPlat:_Init()
end
end
function MapManager.GetMap()
return workspace.Map:FindFirstChildOfClass("Model")
end
function MapManager.DestroyMap()
workspace.Map:ClearAllChildren()
end
return MapManager