fixed elements crossing chunk borders
This commit is contained in:
@@ -111,21 +111,19 @@ public class Chunk {
|
||||
}
|
||||
|
||||
private void Swap(Element what, Element swapTo) {
|
||||
Element swap = new Element(what);
|
||||
|
||||
GD.Print($"Swap: {what} -> {swapTo}");
|
||||
if (swapTo.Position.Y == 0) GD.Print($"");
|
||||
|
||||
if (what == null || swapTo == null) return;
|
||||
if (what == null || swapTo == null) {
|
||||
GD.PrintErr("Trying to swap null");
|
||||
return;
|
||||
}
|
||||
Element temp = new Element(what);
|
||||
|
||||
what.Position = swapTo.Position;
|
||||
what.Chunk = swapTo.Chunk;
|
||||
Elements[swapTo.Position.X, swapTo.Position.Y] = what;
|
||||
|
||||
swapTo.Position = swap.Position;
|
||||
swapTo.Chunk = swap.Chunk;
|
||||
Elements[swap.Position.X, swap.Position.Y] = swapTo;
|
||||
what.Chunk.Elements[what.Position.X, what.Position.Y] = what;
|
||||
|
||||
swapTo.Position = temp.Position;
|
||||
swapTo.Chunk = temp.Chunk;
|
||||
swapTo.Chunk.Elements[swapTo.Position.X, swapTo.Position.Y] = swapTo;
|
||||
|
||||
what.Active = true;
|
||||
swapTo.Active = true;
|
||||
|
||||
Reference in New Issue
Block a user