public bool HasFloorCover(IMapGrid grid, Vector2i position) { // TODO Redo this function. Currently wires on an asteroid are always "below the floor" var tileDef = (ContentTileDefinition)_tileDefinitionManager[grid.GetTileRef(position).Tile.TypeId]; return(!tileDef.IsSubFloor); }
/// <inheritdoc /> public void PryTile(MapIndices indices) { if (IsSpace(indices) || IsAirBlocked(indices)) { return; } var tile = _grid.GetTileRef(indices).Tile; var tileDefinitionManager = IoCManager.Resolve <ITileDefinitionManager>(); var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.TypeId]; var underplating = tileDefinitionManager["underplating"]; _grid.SetTile(indices, new Tile(underplating.TileId)); //Actually spawn the relevant tile item at the right position and give it some offset to the corner. var tileItem = IoCManager.Resolve <IServerEntityManager>().SpawnEntity(tileDef.ItemDropPrototypeName, new GridCoordinates(indices.X, indices.Y, _grid)); tileItem.Transform.WorldPosition += (0.2f, 0.2f); }
public void Initialize(IMapGrid mapGrid) { for (var x = 0; x < ChunkSize; x++) { for (var y = 0; y < ChunkSize; y++) { var tileRef = mapGrid.GetTileRef(new MapIndices(x + _indices.X, y + _indices.Y)); CreateNode(tileRef); } } Dirty(); }
private void UpdateTile(IMapGrid grid, MapIndices position) { var tile = grid.GetTileRef(position); var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId]; foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center)) { var entity = snapGridComponent.Owner; if (!entity.TryGetComponent(out SubFloorHideComponent subFloorComponent) || !entity.TryGetComponent(out ISpriteComponent spriteComponent)) { continue; } spriteComponent.Visible = !subFloorComponent.Running || tileDef.IsSubFloor; } }
private bool IsSpace(MapIndices pos) { // TODO use ContentTileDefinition to define in YAML whether or not a tile is considered space return(_grid.GetTileRef(pos).Tile.IsEmpty); }