Exemplo n.º 1
0
        public void Run(Image gridCanvas, IMapGrid grid)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var bounds   = grid.LocalBounds;
            var xOffset  = Math.Abs(bounds.Left);
            var yOffset  = Math.Abs(bounds.Bottom);
            var tileSize = grid.TileSize * TileImageSize;

            var images = GetTileImages(_sTileDefinitionManager, _cResourceCache, tileSize);
            var i      = 0;

            grid.GetAllTiles().AsParallel().ForAll(tile =>
            {
                var x      = (int)(tile.X + xOffset);
                var y      = (int)(tile.Y + yOffset);
                var sprite = _sTileDefinitionManager[tile.Tile.TypeId].SpriteName;
                var image  = images[sprite];

                gridCanvas.Mutate(o => o.DrawImage(image, new Point(x * tileSize, y * tileSize), 1));

                i++;
            });

            Console.WriteLine($"{nameof(TilePainter)} painted {i} tiles on grid {grid.Index} in {(int) stopwatch.Elapsed.TotalMilliseconds} ms");
        }
Exemplo n.º 2
0
        public async Task SpaceNoPuddleTest()
        {
            var server = StartServer();

            await server.WaitIdleAsync();

            var mapManager          = server.ResolveDependency <IMapManager>();
            var entitySystemManager = server.ResolveDependency <IEntitySystemManager>();
            var spillSystem         = entitySystemManager.GetEntitySystem <SpillableSystem>();

            IMapGrid grid = null;

            // Remove all tiles
            server.Post(() =>
            {
                grid = GetMainGrid(mapManager);

                foreach (var tile in grid.GetAllTiles())
                {
                    grid.SetTile(tile.GridIndices, Tile.Empty);
                }
            });

            await server.WaitIdleAsync();

            server.Assert(() =>
            {
                var coordinates = grid.ToCoordinates();
                var solution    = new Solution("Water", FixedPoint2.New(20));
                var puddle      = spillSystem.SpillAt(solution, coordinates, "PuddleSmear");
                Assert.Null(puddle);
            });

            await server.WaitIdleAsync();
        }
Exemplo n.º 3
0
        public void RepopulateTiles()
        {
            foreach (var tile in _grid.GetAllTiles())
            {
                if (!_tiles.ContainsKey(tile.GridIndices))
                {
                    _tiles.Add(tile.GridIndices, new TileAtmosphere(this, tile.GridIndex, tile.GridIndices, new GasMixture(GetVolumeForCells(1))
                    {
                        Temperature = Atmospherics.T20C
                    }));
                }
            }

            foreach (var(_, tile) in _tiles.ToArray())
            {
                tile.UpdateAdjacent();
                tile.UpdateVisuals();
            }
        }
Exemplo n.º 4
0
        public async Task SpaceNoPuddleTest()
        {
            await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });

            var server = pairTracker.Pair.Server;

            var testMap = await PoolManager.CreateTestMap(pairTracker);

            var entitySystemManager = server.ResolveDependency <IEntitySystemManager>();
            var spillSystem         = entitySystemManager.GetEntitySystem <SpillableSystem>();

            IMapGrid grid = null;

            // Remove all tiles
            await server.WaitPost(() =>
            {
                grid = testMap.MapGrid;

                foreach (var tile in grid.GetAllTiles())
                {
                    grid.SetTile(tile.GridIndices, Tile.Empty);
                }
            });

            await PoolManager.RunTicksSync(pairTracker.Pair, 5);

            await server.WaitAssertion(() =>
            {
                var coordinates = grid.ToCoordinates();
                var solution    = new Solution("Water", FixedPoint2.New(20));
                var puddle      = spillSystem.SpillAt(solution, coordinates, "PuddleSmear");
                Assert.Null(puddle);
            });

            await pairTracker.CleanReturnAsync();
        }
Exemplo n.º 5
0
 private bool GridEmpty(IMapGrid grid)
 {
     return(!(grid.GetAllTiles().Any()));
 }