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