public WorldRenderer(World world, ViewportManager viewportManager, GraphicsDevice graphicsDevice) { this.world = world; this.viewportManager = viewportManager; spriteBatch = new SpriteBatch(graphicsDevice); ShapeManager.Setup(graphicsDevice); lightTexture = AssetManager.GetAsset <Texture2D>("lightmask"); lightEffect = AssetManager.GetAsset <Effect>("fx_world"); lightsTarget = new RenderTarget2D(spriteBatch.GraphicsDevice, viewportManager.Viewport.Width, viewportManager.Viewport.Height); mainTarget = new RenderTarget2D(spriteBatch.GraphicsDevice, viewportManager.Viewport.Width, viewportManager.Viewport.Height); }
public void Draw() { spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, viewportManager.Camera.Transform); if (currentTask != null && currentTask.Preview != null) { if (isDragging) { for (int x = dragAreaCells.Left; x <= dragAreaCells.Right; x++) { for (int y = dragAreaCells.Top; y <= dragAreaCells.Bottom; y++) { Cell cell = world.GetCellAt(x, y); if (cell != null) { currentTask.Preview(cell, spriteBatch); } } } } else if (CellUnderMouse != null) { currentTask.Preview(CellUnderMouse, spriteBatch); } } if (isDraggingRight) { ShapeManager.DrawRectangle(spriteBatch, dragAreaRight, Color.Transparent, Color.Red); for (int x = dragAreaCellsRight.Left; x <= dragAreaCellsRight.Right; x++) { for (int y = dragAreaCellsRight.Top; y <= dragAreaCellsRight.Bottom; y++) { Cell cell = world.GetCellAt(x, y); if (cell != null && (currentTask != null && currentTask.CanCancel != null && currentTask.CanCancel(cell))) { Blueprint preview = new Blueprint(cell.World, new Floor(cell, FloorType.Concrete)); preview.Draw(spriteBatch, cell.X, cell.Y, Blueprint.BlueprintState.Invalid); } } } } if (isDragging && currentTask == null) { ShapeManager.DrawRectangle(spriteBatch, dragArea, Color.Transparent, Color.GreenYellow); } spriteBatch.End(); }