fixed chunk neighbor orientation
This commit is contained in:
@@ -77,21 +77,20 @@ public class Chunk {
|
||||
}
|
||||
|
||||
public Element Get(Vector2I pos) {
|
||||
// North
|
||||
if (pos.X < 0)
|
||||
if (NeighborN != null) return NeighborN.Get(NeighborN.sizeX + pos.X, pos.Y);
|
||||
if (pos.Y == 54)
|
||||
GD.Print("magic number");
|
||||
|
||||
// South
|
||||
if (pos.X >= sizeX)
|
||||
if (NeighborS != null) return NeighborS.Get(sizeX - pos.X, pos.Y);
|
||||
|
||||
// West
|
||||
if (pos.Y < 0)
|
||||
if (NeighborW != null) return NeighborW.Get(pos.X, NeighborW.sizeY + pos.Y);
|
||||
if (NeighborN != null) return NeighborN.Get(pos.X, NeighborN.sizeY + pos.Y);
|
||||
|
||||
// East
|
||||
if (pos.Y >= sizeY)
|
||||
if (NeighborE != null) return NeighborE.Get(pos.X, sizeY - pos.Y);
|
||||
if (NeighborS != null) return NeighborS.Get(pos.X, sizeY - pos.Y);
|
||||
|
||||
if (pos.X < 0)
|
||||
if (NeighborE != null) return NeighborE.Get(NeighborE.sizeX + pos.X, pos.Y);
|
||||
|
||||
if (pos.X >= sizeX)
|
||||
if (NeighborW != null) return NeighborW.Get(sizeX - pos.X, pos.Y);
|
||||
|
||||
return Get(pos.X, pos.Y);
|
||||
}
|
||||
@@ -110,6 +109,9 @@ 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;
|
||||
|
||||
what.Position = swapTo.Position;
|
||||
@@ -120,6 +122,7 @@ public class Chunk {
|
||||
swapTo.Chunk = swap.Chunk;
|
||||
Elements[swap.Position.X, swap.Position.Y] = swapTo;
|
||||
|
||||
|
||||
what.Active = true;
|
||||
swapTo.Active = true;
|
||||
what.LastMove = frame;
|
||||
|
||||
Reference in New Issue
Block a user