public void AddOccupant(IntVector3 position, ITileOccupant occupant) { if (!IsWithinMap(position)) { CustomLogger.Error(nameof(LevelDataManager), $"Position {position} is out of bounds!"); return; } ITileInfo tileInfo = _tiles[position.x][position.y]; tileInfo.AddOccupant(occupant); }
protected virtual void UpdateMapSpacePosition(IntVector3 position) { ITileInfo oldTileInfo = LevelDataManager.Instance.GetTileAt(_mapPosition.x, _mapPosition.y); if (oldTileInfo != null) { oldTileInfo.RemoveOccupant(_unit); } _mapPosition = position; ITileInfo newTileInfo = LevelDataManager.Instance.GetTileAt(_mapPosition.x, _mapPosition.y); if (newTileInfo != null) { newTileInfo.AddOccupant(_unit); } OnMapPositionUpdated?.Invoke(MapPosition); }