diff --git a/Scripts/Chunk.cs b/Scripts/Chunk.cs index a9c0a17..9ad5a32 100644 --- a/Scripts/Chunk.cs +++ b/Scripts/Chunk.cs @@ -70,14 +70,15 @@ public class Chunk { } // check if not empty and overwrite not allowed: - if (!Elements[x,y].IsEmpty() && !Main.Instance.AllowOverwrite) { + if (!Elements[x,y].IsEmpty() && !Main.Instance.AllowOverwrite) return; + else if (!Elements[x,y].IsEmpty()) { + Elements[x, y].Chunk.RemoveFromChunk(Elements[x, y]); } Type type = typeof(T); object o = Activator.CreateInstance(type, x, y, this); - Elements[x, y].Chunk.RemoveFromChunk(Elements[x, y]); Elements[x, y] = o as Element; Elements[x, y].Active = true; }