core: improved building system
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user