public override void Initialize() { base.Initialize(); _sprite = Owner.GetComponent <ISpriteComponent>(); _snapGrid = Owner.GetComponent <SnapGridComponent>(); }
private static LowWallComponent?FindLowWall(SnapGridComponent snapGrid) { foreach (var entity in snapGrid.GetLocal()) { if (entity.TryGetComponent(out LowWallComponent? lowWall)) { return(lowWall); } } return(null); }
public void AddSnapGridCellEdge() { var chunk = MapChunkFactory(7, 9); var snapGridComponent = new SnapGridComponent(); chunk.AddToSnapGridCell(3, 5, SnapGridOffset.Edge, snapGridComponent); chunk.AddToSnapGridCell(3, 5, SnapGridOffset.Center, new SnapGridComponent()); chunk.AddToSnapGridCell(3, 6, SnapGridOffset.Edge, new SnapGridComponent()); var result = chunk.GetSnapGridCell(3, 5, SnapGridOffset.Edge).ToList(); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result[0], Is.EqualTo(snapGridComponent)); }
public void RemoveSnapGridCellCenter() { var chunk = MapChunkFactory(7, 9); var snapGridComponent = new SnapGridComponent(); chunk.AddToSnapGridCell(3, 5, SnapGridOffset.Center, snapGridComponent); chunk.AddToSnapGridCell(3, 5, SnapGridOffset.Edge, new SnapGridComponent()); chunk.AddToSnapGridCell(3, 6, SnapGridOffset.Center, new SnapGridComponent()); chunk.RemoveFromSnapGridCell(3, 5, SnapGridOffset.Center, snapGridComponent); var result = chunk.GetSnapGridCell(3, 5, SnapGridOffset.Center).ToList(); Assert.That(result.Count, Is.EqualTo(0)); }
public override void Initialize() { base.Initialize(); var state0 = $"{StateBase}0"; SnapGrid = Owner.GetComponent <SnapGridComponent>(); Sprite = Owner.GetComponent <ISpriteComponent>(); Sprite.LayerMapSet(CornerLayers.SE, Sprite.AddLayerState(state0)); Sprite.LayerSetDirOffset(CornerLayers.SE, DirectionOffset.None); Sprite.LayerMapSet(CornerLayers.NE, Sprite.AddLayerState(state0)); Sprite.LayerSetDirOffset(CornerLayers.NE, DirectionOffset.CounterClockwise); Sprite.LayerMapSet(CornerLayers.NW, Sprite.AddLayerState(state0)); Sprite.LayerSetDirOffset(CornerLayers.NW, DirectionOffset.Flip); Sprite.LayerMapSet(CornerLayers.SW, Sprite.AddLayerState(state0)); Sprite.LayerSetDirOffset(CornerLayers.SW, DirectionOffset.Clockwise); }
public void AddToSnapGridCell(ushort xCell, ushort yCell, SnapGridOffset offset, SnapGridComponent snap) { ref var cell = ref _snapGrid[xCell, yCell];
public void RemoveFromSnapGridCell(GridLocalCoordinates worldPos, SnapGridOffset offset, SnapGridComponent snap) { RemoveFromSnapGridCell(SnapGridCellFor(worldPos, offset), offset, snap); }
public void RemoveFromSnapGridCell(MapIndices pos, SnapGridOffset offset, SnapGridComponent snap) { var(chunk, chunkTile) = ChunkAndOffsetForTile(pos); chunk.RemoveFromSnapGridCell((ushort)chunkTile.X, (ushort)chunkTile.Y, offset, snap); }
public void AddToSnapGridCell(GridLocalCoordinates worldPos, SnapGridOffset offset, SnapGridComponent snap) { AddToSnapGridCell(SnapGridCellFor(worldPos, offset), offset, snap); }
/// <inheritdoc /> public void AddToSnapGridCell(ushort xCell, ushort yCell, SnapGridOffset offset, SnapGridComponent snap) { if (xCell >= ChunkSize) { throw new ArgumentOutOfRangeException(nameof(xCell), "Tile indices out of bounds."); } if (yCell >= ChunkSize) { throw new ArgumentOutOfRangeException(nameof(yCell), "Tile indices out of bounds."); } ref var cell = ref _snapGrid[xCell, yCell];