public override void RemoveOccupant(GridOccupant occupant) { if (IdxIsOnGrid(occupant.Position)) { _nodes[occupant.Position.x, occupant.Position.y].RemoveOccupant(occupant); occupant.Position = Vector2IntEx.OffGrid; } }
public override Vector2Int AddOccupant(Vector2 worldPosition, GridOccupant occupant) { var idx = GetNodeIndexAt(worldPosition); if (IdxIsOnGrid(idx)) { occupant.Position = idx; _nodes[idx.x, idx.y].AddOccupant(occupant); } return(idx); }
public override Vector2Int MoveOccupant(Vector2 newWorldPos, GridOccupant occupant) { RemoveOccupant(occupant); return(AddOccupant(newWorldPos, occupant)); }