1
This commit is contained in:
commit
a85391509d
211 files changed
+28903
No files matched your search
@@ -0,0 +1,187 @@
|
||||
--!strict
|
||||
-- Run in the Studio Edit command bar before installing ProceduralArena.
|
||||
local MaterialService = game:GetService("MaterialService")
|
||||
local RunService = game:GetService("RunService")
|
||||
local ServerStorage = game:GetService("ServerStorage")
|
||||
|
||||
assert(RunService:IsStudio() and not RunService:IsRunning(), "BuildProceduralKit requires Studio Edit mode")
|
||||
|
||||
local source = ServerStorage:FindFirstChild("HunterMonolithImport") or workspace:FindFirstChild("HunterMonolithImport")
|
||||
assert(source and source:IsA("Model"), "HunterMonolithImport is missing")
|
||||
|
||||
local kitName = "ProceduralArenaKit"
|
||||
local existingKit = ServerStorage:FindFirstChild(kitName)
|
||||
if existingKit then
|
||||
local version = existingKit:GetAttribute("Version")
|
||||
assert(existingKit:IsA("Folder") and typeof(version) == "number" and version >= 1 and version <= 6,
|
||||
"ServerStorage.ProceduralArenaKit is occupied by an unrecognized instance")
|
||||
end
|
||||
|
||||
local arena = workspace:FindFirstChild("ProceduralArena")
|
||||
assert(not arena or arena:IsA("Model"), "Workspace.ProceduralArena must be a Model")
|
||||
local spawns = if arena then arena:FindFirstChild("PlayerSpawns") else nil
|
||||
assert(not spawns or spawns:IsA("Folder"), "ProceduralArena.PlayerSpawns must be a Folder")
|
||||
|
||||
local assetNames = {
|
||||
A0040 = "Foundation",
|
||||
A0083 = "Boundary",
|
||||
A0085 = "Ramp",
|
||||
A0084 = "Terrace",
|
||||
A0002 = "CitadelRamp",
|
||||
A0039 = "DeckPanel",
|
||||
A0071 = "LowCover",
|
||||
A0075 = "TallCover",
|
||||
A0079 = "SquareCover",
|
||||
A0090 = "Crate",
|
||||
A0025 = "Screen",
|
||||
A0023 = "Wall",
|
||||
A0005 = "Parapet",
|
||||
}
|
||||
local assets: {[string]: MeshPart} = {}
|
||||
for _, child in source:GetDescendants() do
|
||||
if child:IsA("MeshPart") then
|
||||
local id = child.Name:match("^([AL]%d%d%d%d)_")
|
||||
if id and (assetNames[id] or id == "A0105") then
|
||||
assert(not assets[id], "Duplicate source mesh " .. id)
|
||||
assets[id] = child
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for id in assetNames do
|
||||
local asset = assets[id]
|
||||
assert(asset and asset.Archivable and asset.MeshId ~= "", "Missing or unclonable source mesh " .. id)
|
||||
assert(asset.CollisionFidelity == Enum.CollisionFidelity.Hull, "Expected solid hull for " .. id)
|
||||
end
|
||||
|
||||
local kit = Instance.new("Folder")
|
||||
kit.Name = kitName
|
||||
kit:SetAttribute("Version", 6)
|
||||
|
||||
-- The source floor spans 896 Blender studs with one texture repeat every 32 studs (four cells).
|
||||
local textureRepeat = assets.A0040.Size.X / (896 / 32)
|
||||
local cell = textureRepeat / 4
|
||||
kit:SetAttribute("GridCell", cell)
|
||||
local materialNames: {[string]: string} = {}
|
||||
for _, spec in {
|
||||
{name = "HunterArenaGridFloor", source = assets.A0040},
|
||||
{name = "HunterArenaGridNavy", source = assets.A0023},
|
||||
{name = "HunterArenaGridAmber", source = assets.A0002},
|
||||
} do
|
||||
local image = spec.source.TextureID
|
||||
assert(image ~= "" and not materialNames[image], "Missing or duplicate source grid image: " .. spec.name)
|
||||
local existing = MaterialService:FindFirstChild(spec.name)
|
||||
assert(not existing or existing:IsA("MaterialVariant"), "Grid material name is occupied: " .. spec.name)
|
||||
local material = existing :: MaterialVariant? or Instance.new("MaterialVariant")
|
||||
material.Name = spec.name
|
||||
material.BaseMaterial = Enum.Material.Plastic
|
||||
material.ColorMap = image
|
||||
material.MaterialPattern = Enum.MaterialPattern.Regular
|
||||
material.StudsPerTile = textureRepeat
|
||||
material.Parent = MaterialService
|
||||
materialNames[image] = spec.name
|
||||
end
|
||||
|
||||
local function box(size: Vector3, color: Color3, variant: string): Part
|
||||
local part = Instance.new("Part")
|
||||
part.Size, part.Color = size, color
|
||||
part.Material, part.MaterialVariant = Enum.Material.Plastic, variant
|
||||
part.TopSurface, part.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth
|
||||
part.Anchored, part.CanCollide, part.CanQuery, part.CanTouch = true, true, true, false
|
||||
return part
|
||||
end
|
||||
|
||||
local function strip(part: BasePart)
|
||||
-- Keep mesh appearance, without copying scene attachments, lights, tags, or behavior.
|
||||
for _, child in part:GetChildren() do
|
||||
if not child:IsA("SurfaceAppearance") and not child:IsA("Texture") and not child:IsA("Decal") then
|
||||
child:Destroy()
|
||||
end
|
||||
end
|
||||
for _, tag in part:GetTags() do
|
||||
part:RemoveTag(tag)
|
||||
end
|
||||
for key in part:GetAttributes() do
|
||||
part:SetAttribute(key, nil)
|
||||
end
|
||||
part.PivotOffset = CFrame.identity
|
||||
part.Anchored = true
|
||||
part.CanTouch = false
|
||||
part.CollisionGroup = "Default"
|
||||
end
|
||||
|
||||
for id, name in assetNames do
|
||||
local asset = assets[id]
|
||||
local material = materialNames[asset.TextureID]
|
||||
assert(material, "Unexpected arena texture on " .. asset.Name)
|
||||
local part: BasePart
|
||||
if name == "Ramp" or name == "CitadelRamp" then
|
||||
local slope = asset:Clone()
|
||||
strip(slope)
|
||||
slope.TextureID = ""
|
||||
slope.Material = Enum.Material.Plastic
|
||||
slope.MaterialVariant = materialNames[assets.A0002.TextureID]
|
||||
slope.CanCollide, slope.CanQuery = true, true
|
||||
part = slope
|
||||
else
|
||||
-- Box materials start at the face edge on native parts. Imported meshes can start half a cell in.
|
||||
part = box(asset.Size, asset.Color, material)
|
||||
end
|
||||
part.Name = name
|
||||
part:SetAttribute("SourceMesh", id)
|
||||
part.CFrame = CFrame.identity
|
||||
part.Parent = kit
|
||||
end
|
||||
|
||||
local gateAsset = assets.A0105
|
||||
assert(gateAsset and gateAsset.Archivable, "Missing flank gate mesh")
|
||||
local proxies = source:WaitForChild("HunterImportSetup"):WaitForChild("PassageCollisions")
|
||||
local lintel: BasePart? = nil
|
||||
for _, body in proxies:GetChildren() do
|
||||
if body:IsA("BasePart") and body.Name == "A0105_Collision" and math.abs(body.Position.X - gateAsset.Position.X) < .1 then
|
||||
lintel = body
|
||||
break
|
||||
end
|
||||
end
|
||||
assert(lintel, "Missing flank gate opening")
|
||||
local function grid(value: number): number
|
||||
return math.round(value / cell) * cell
|
||||
end
|
||||
local width, height, depth = grid(gateAsset.Size.X), grid(gateAsset.Size.Y), grid(gateAsset.Size.Z)
|
||||
local opening = grid(lintel.Size.X)
|
||||
local clearHeight = height - grid(lintel.Size.Y)
|
||||
assert(opening > 0 and opening < width and clearHeight > 0 and clearHeight < height, "Invalid flank gate opening")
|
||||
local stone = materialNames[gateAsset.TextureID]
|
||||
assert(stone, "Missing flank gate material")
|
||||
local gate = Instance.new("Model")
|
||||
gate.Name = "Gate"
|
||||
gate.WorldPivot = CFrame.identity
|
||||
local roof = box(Vector3.new(width, height - clearHeight, depth), gateAsset.Color, stone)
|
||||
roof.Name = "GateRoof"
|
||||
roof.Position = Vector3.new(0, (height + clearHeight) / 2, 0)
|
||||
roof.Parent = gate
|
||||
for _, side in {-1, 1} do
|
||||
local pier = box(Vector3.new((width - opening) / 2, clearHeight, depth), gateAsset.Color, stone)
|
||||
pier.Name = if side < 0 then "WestPier" else "EastPier"
|
||||
pier.Position = Vector3.new(side * (width + opening) / 4, clearHeight / 2, 0)
|
||||
pier.Parent = gate
|
||||
end
|
||||
gate.Parent = kit
|
||||
|
||||
if not arena then
|
||||
local model = Instance.new("Model")
|
||||
model.Name = "ProceduralArena"
|
||||
model.WorldPivot = CFrame.new(6500, 8, 0)
|
||||
arena = model
|
||||
end
|
||||
if not spawns then
|
||||
local folder = Instance.new("Folder")
|
||||
folder.Name = "PlayerSpawns"
|
||||
folder.Parent = arena
|
||||
end
|
||||
if existingKit then
|
||||
existingKit:Destroy()
|
||||
end
|
||||
kit.Parent = ServerStorage
|
||||
arena.Parent = workspace
|
||||
return kit
|
||||
Reference in new issue
Block a user