WiP: chunk overdraw fix
This commit is contained in:
@@ -67,29 +67,23 @@ public class Chunk {
|
||||
else RemoveFromChunk(e);
|
||||
}
|
||||
|
||||
public void WritePixel<T>(int x, int y, int size) {
|
||||
int halfsize = size/2;
|
||||
public void WritePixel<T>(int x, int y) {
|
||||
if (x < 0 || x >= sizeX || y < 0 || y >= sizeY) {
|
||||
GD.PrintErr($"Out of bounds for chunk: {x}:{y}");
|
||||
return;
|
||||
}
|
||||
|
||||
Type type = typeof(T);
|
||||
object o = Activator.CreateInstance(type, x, y, this);
|
||||
|
||||
for (int i = -halfsize; i <= halfsize; i++) {
|
||||
for (int j = -halfsize; j <= halfsize; j++) {
|
||||
int X = Mathf.Clamp(x + i, 0, sizeX-1);
|
||||
int Y = Mathf.Clamp(y + j, 0, sizeY-1);
|
||||
object o = Activator.CreateInstance(type, X, Y, this);
|
||||
|
||||
// check if not empty:
|
||||
if (Elements[X,Y].GetType() != typeof(Element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (Elements[X,Y].GetType() != type) {
|
||||
Elements[X, Y].Chunk.RemoveFromChunk(Elements[X, Y]);
|
||||
Elements[X, Y] = o as Element;
|
||||
Elements[X, Y].Active = true;
|
||||
// }
|
||||
}
|
||||
// check if not empty:
|
||||
if (Elements[x,y].GetType() != typeof(Element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Elements[x, y].Chunk.RemoveFromChunk(Elements[x, y]);
|
||||
Elements[x, y] = o as Element;
|
||||
Elements[x, y].Active = true;
|
||||
}
|
||||
|
||||
public int ActiveElementsCount() {
|
||||
|
||||
Reference in New Issue
Block a user