still working out movement

This commit is contained in:
2026-07-04 03:04:56 -04:00
parent 336b72e4cb
commit dbafefd660
16 changed files with 136 additions and 71 deletions
+8 -9
View File
@@ -72,6 +72,7 @@ public partial class Map : TileMapLayer
public override void _Ready()
{
base._Ready();
// GD.Print(GlobalPosition);
List<Vector2I> usedCells = [.. GetUsedCells()];
_cellSize = TileSet.TileSize;
for (int i = 0; i < usedCells.Count; i++)
@@ -79,7 +80,8 @@ public partial class Map : TileMapLayer
MapCell newMapCell = _mapCellScene.Instantiate<MapCell>();
Vector2I usedCell = usedCells[i];
newMapCell._address = usedCell;
newMapCell.GlobalPosition = GetCellPositionFromAddress(newMapCell._address);
newMapCell.GlobalPosition = newMapCell._address * _cellSize + _cellSize / 2;
// GD.Print(GlobalPosition, newMapCell.GlobalPosition);
newMapCell._occupant = null;
_cells[usedCell] = newMapCell;
AddChild(newMapCell);
@@ -110,14 +112,10 @@ 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)
public int GetCellDisposition(Vector2I ADDRESS)
{
return GlobalPosition + CELL_ADDRESS * _cellSize + _cellSize / 2;
return (int)GetCellTileData(ADDRESS).GetCustomData("disposition");
}
public MapCellOccupant GetOccupant(Vector2I CELL_TO_CHECK)
@@ -157,11 +155,12 @@ public partial class Map : TileMapLayer
{
if (PEG != null)
{
if (PEG._address != -Vector2I.One)
if (PEG._cell != null)
{
CELL._occupant = null;
PEG._cell._occupant = null;
SetCellSolid(_cells[PEG._address]);
}
PEG._cell = CELL;
PEG._address = CELL._address;
}
CELL._occupant = PEG;