void OnClick() { Directory.CreateDirectory("Chunks"); IsometricLighting lighting = new IsometricLighting(); MouseOverList mouseOverNull = new MouseOverList(new MousePicking()); SpriteBatch3D spritebatch = Service.Get<SpriteBatch3D>(); RenderTarget2D render = new RenderTarget2D(spritebatch.GraphicsDevice, Width + WidthExtra * 2, Height + HeightExtra * 2 + HeightExtra2); Map map = new Map(0); for (int chunky = 0; chunky < 10; chunky++) { for (int chunkx = 0; chunkx < 10; chunkx++) { spritebatch.GraphicsDevice.SetRenderTarget(render); spritebatch.Reset(); uint cx = (uint)chunkx + 200; uint cy = (uint)chunky + 200; map.CenterPosition = new Point((int)(cx << 3), (int)(cy << 3)); MapChunk chunk = map.GetMapChunk(cx, cy); chunk.LoadStatics(map.MapData, map); int z = 0; for (int i = 0; i < 64; i++) { int y = (i / 8); int x = (i % 8); int sy = y * 22 + x * 22 + HeightExtra + HeightExtra2; int sx = 22 * 8 - y * 22 + x * 22 + WidthExtra; MapTile tile = chunk.Tiles[i]; tile.ForceSort(); for (int j = 0; j < tile.Entities.Count; j++) { AEntity e = tile.Entities[j]; AEntityView view = e.GetView(); view.Draw(spritebatch, new Vector3(sx, sy, 0), mouseOverNull, map, false); } } spritebatch.SetLightIntensity(lighting.IsometricLightLevel); spritebatch.SetLightDirection(lighting.IsometricLightDirection); spritebatch.GraphicsDevice.Clear(Color.Transparent); spritebatch.FlushSprites(true); spritebatch.GraphicsDevice.SetRenderTarget(null); render.SaveAsPng(new FileStream($"Chunks/{cy}-{cx}.png", FileMode.Create), render.Width, render.Height); } } }
public IsometricRenderer() { m_SpriteBatch = Service.Get<SpriteBatch3D>(); Lighting = new IsometricLighting(); }
public IsometricRenderer() { m_SpriteBatch = ServiceRegistry.GetService <SpriteBatch3D>(); Lighting = new IsometricLighting(); }