core: improved building system

This commit is contained in:
2026-01-06 23:44:07 +02:00
parent 0ac6d6e214
commit 97e142d3b2
6 changed files with 286 additions and 18 deletions

View File

@@ -9,6 +9,7 @@ local objects = script.Parent.Parent.Parent.Objects
local RunService = game:GetService("RunService")
local ChunkBorderFolder = game:GetService("Workspace"):FindFirstChildOfClass("Terrain")
local DEBUG_GHOST = true
local NEIGHBOR_OFFSETS = {
{-1, 0, 0}, {1, 0, 0},
@@ -108,10 +109,28 @@ function ChunkBuilder:BuildChunk(c: typeof(Chunk.new(0,0,0)),parent: Instance?)
local blockName = `{x},{y},{z}`
local existing = ch:FindFirstChild(blockName)
if d == 0 then
if c.delayedRemoval and c.delayedRemoval[blockName] then
c.delayedRemoval[blockName] = nil
if existing then
task.defer(function()
task.synchronize()
RunService.RenderStepped:Wait()
if existing.Parent then
existing:Destroy()
end
task.desynchronize()
end)
elseif DEBUG_GHOST then
print("[CHUNKBUILDER][GHOST] Delayed remove missing instance", c.pos, blockName)
end
return
end
if existing then
task.synchronize()
existing:Destroy()
task.desynchronize()
elseif DEBUG_GHOST then
print("[CHUNKBUILDER][GHOST] Remove missing instance", c.pos, blockName)
end
return
end