continuing to switch to MapCell orientation

This commit is contained in:
2026-07-03 02:16:29 -04:00
parent e6355167e3
commit 336b72e4cb
13 changed files with 81 additions and 82 deletions
+15 -9
View File
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
public partial class Map : TileMapLayer
{
@@ -109,6 +110,11 @@ public partial class Map : TileMapLayer
}
return new Vector2I((int)Math.Floor(POSITION.X / _cellSize.X), (int)Math.Floor(POSITION.Y / _cellSize.Y));
}
public Vector2 GetCellPosition(MapCell CELL)
{
return CELL.GlobalPosition;
}
public Vector2 GetCellPositionFromAddress(Vector2I CELL_ADDRESS)
{
return GlobalPosition + CELL_ADDRESS * _cellSize + _cellSize / 2;
@@ -147,24 +153,24 @@ public partial class Map : TileMapLayer
return rowCells.All(_astar.IsPointSolid);
}
public void SetCellPeg(Vector2I ADDRESS, Peg PEG)
public void SetCellPeg(MapCell CELL, Peg PEG)
{
if (PEG != null)
{
if (PEG._address != -Vector2I.One)
{
_cells[PEG._address]._occupant = null;
SetCellSolid(PEG._address);
CELL._occupant = null;
SetCellSolid(_cells[PEG._address]);
}
PEG._address = ADDRESS;
PEG._address = CELL._address;
}
_cells[ADDRESS]._occupant = PEG;
SetCellSolid(ADDRESS);
CELL._occupant = PEG;
SetCellSolid(CELL);
}
public void SetCellSolid(Vector2I ADDRESS)
public void SetCellSolid(MapCell CELL)
{
_astar.SetPointSolid(ADDRESS, IsCellSolid(ADDRESS));
_astar.SetPointSolid(CELL._address, IsCellSolid(CELL._address));
// _astar.SetPointWeightScale(ADDRESS, IsCellSolid(ADDRESS) ? 1000 : 1);
}
@@ -200,7 +206,7 @@ public partial class Map : TileMapLayer
{
for (int i = 0; i < _cells.Count; i++)
{
SetCellSolid(_cells.ElementAt(i).Value._address);
SetCellSolid(_cells.ElementAt(i).Value);
}
}