Ejemplo n.º 1
0
        protected override TileSet GenerateComponentData(Entity entity, ChunkComponent component)
        {
            var chunk        = new Chunk(component.OriginPosition.ToPosition());
            var tilesRequest = new GetTilesQuery(chunk.GetPositions().ToArray());

            return(_mediator.Send(tilesRequest).GetAwaiter().GetResult());
        }
Ejemplo n.º 2
0
        public async void SetFullVisibilityOnSingleTile()
        {
            var repo = new TilesRepositoryBuilder()
                       .WithTiles(GroundType.Dirt, TilePosition.Zero)
                       .Build();

            var qry     = new GetTilesQuery(TilePosition.Zero);
            var handler = new GetTilesHandler(repo);
            var result  = await handler.Handle(qry, CancellationToken.None);

            result.Single().Visibility.Should().HaveFlag(Direction.All);
        }
Ejemplo n.º 3
0
        public async void ReturnInformationForEachPosition()
        {
            var positions = new[] { TilePosition.Zero };
            var repo      = new TilesRepositoryBuilder()
                            .WithTiles(GroundType.Dirt, positions)
                            .Build();

            var qry     = new GetTilesQuery(positions);
            var handler = new GetTilesHandler(repo);
            var result  = await handler.Handle(qry, CancellationToken.None);

            var actualPositions = result.Select(item => item.Position);

            actualPositions.Should().BeEquivalentTo(positions);
        }
Ejemplo n.º 4
0
        public async void OccludeInvisibleSides()
        {
            var left  = TilePosition.Zero;
            var right = TilePosition.Zero.Right();

            var repo = new TilesRepositoryBuilder()
                       .WithTiles(GroundType.Dirt, left, right)
                       .Build();

            var qry     = new GetTilesQuery(left, right);
            var handler = new GetTilesHandler(repo);
            var result  = await handler.Handle(qry, CancellationToken.None);

            var leftInfo  = result.Single(item => item.Position == left);
            var rightInfo = result.Single(item => item.Position == right);

            leftInfo.Visibility.Should().NotHaveFlag(Direction.Right);
            rightInfo.Visibility.Should().NotHaveFlag(Direction.Left);
        }