protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);

            squarePlayground.Draw(sb);

            if (startPosition.HasValue)
            {
                sb.Begin();
                sb.Draw(WhitePixel, new Vector2(startPosition.Value.X - 2, startPosition.Value.Y - 2), null, Color.Gray, 0, Vector2.Zero, 5, 0, 0);
                sb.Draw(WhitePixel, new Vector2(startPosition.Value.X - 1, startPosition.Value.Y - 1), null, Color.White, 0, Vector2.Zero, 3, 0, 0);
                sb.End();
            }

            bool noFade = Input.Shift && Input.Control;

            console.Draw(sb, DefaultFont, WhitePixel, noFade);

            simpleNetworkMenu.Draw(dt);

            if (showRollbackDebugInfo)
            {
                RollbackDebugDisplay.Draw(dt, rollbackDriver);
            }

            base.Draw(gameTime);
        }
Exemple #2
0
        private void LateUpdate()
        {
            // Must be called manually once per frame
            _console.Update();

            // Must be called manually if you want to use "screen" effects in the console
            // (Like screenburn and scanlines). Not required for normal text rendering.
            //RenderUtility.UpdatePixelEffectProperties(_console);

            // Must be called manually once per frame.
            _console.Draw();
        }
        protected override void OnUpdate()
        {
            var mapEntity = _mapQuery.GetSingletonEntity();

            var mapData = _mapQuery.GetSingleton <MapData>();

            if (mapData.width != _console.Width || mapData.height != _console.Height)
            {
                _console.Resize(mapData.width, mapData.height);
                RenderUtility.AdjustCameraToConsole(_console);
                return;
            }

            RenderUtility.AdjustCameraToConsole(_console);

            var map = EntityManager.GetBuffer <MapTiles>(mapEntity);

            // The map has been resized but not yet updated
            if ((mapData.width * mapData.height) != map.Length)
            {
                return;
            }

            if (_playerQuery.IsEmptyIgnoreFilter)
            {
                return;
            }

            // Since we're iterating all tiles in the map we can probably benefit from using burst.
            // We can't use the console in a job since it's a managed object, so we'll work directly with tiles
            var tiles = new NativeArray <Tile>(_console.CellCount, Allocator.Temp, NativeArrayOptions.ClearMemory);

            var playerEntity = _playerQuery.GetSingletonEntity();

            bool hasView   = EntityManager.HasComponent <TilesInView>(playerEntity);
            bool hasMemory = EntityManager.HasComponent <TilesInMemory>(playerEntity);

            _console.ClearScreen();

            if (!hasMemory && !hasView)
            {
                RenderEverything(map, tiles, mapData.Size);
            }
            else
            {
                if (hasMemory)
                {
                    var memory = EntityManager.GetBuffer <TilesInMemory>(playerEntity);
                    RenderMemory(map, memory, tiles, mapData.Size);
                }

                if (hasView)
                {
                    var view = EntityManager.GetBuffer <TilesInView>(playerEntity);
                    RenderView(map, view, tiles, mapData.Size);
                }
            }

            _console.WriteAllTiles(tiles);

            _console.Update();
            _console.Draw();
        }