protected override void Draw(GameTime gameTime)
{
if (!IsActive) return;
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
var viewmap = _mapEntity.GetComponent<MapComponent>().Map;
viewmap.Draw(_camera);
var ents = _gameServer.EntityManager.GetEntities(Aspect.All(typeof(RenderData)));
var viewMatrix = _camera.GetViewMatrix();
spriteBatch.Begin(transformMatrix: viewMatrix);
foreach(var ent in ents)
{
var renderData = ent.GetComponent<RenderData>();
if (renderData != null)
{
renderData.UpdateFromPhysics();
renderData.Draw(spriteBatch);
}
}
spriteBatch.End();
// var midgard = _gameServer.LookupSystem<Midgard>();
// var world = midgard.GetWorld();
// var bodies = world.BodyList;
//
// spriteBatch.Begin(transformMatrix: viewMatrix);
//
// foreach (var body in bodies)
// {
// foreach(var fix in body.FixtureList)
// {
// var poly = fix.Shape as PolygonShape;
// Transform xf;
// body.GetTransform(out xf);
//
// Vector2[] data = new Vector2[4];
// for (int i = 0; i < poly.Vertices.Count; i++)
// {
// Farseer.Framework.Vector2 tmp = MathUtils.Mul(ref xf, poly.Vertices[i]);
// data[i] = new Vector2(tmp.X * 10f, tmp.Y * 10f);
// }
//
// DrawLine(spriteBatch, data[0], data[1]);
// DrawLine(spriteBatch, data[1], data[2]);
// DrawLine(spriteBatch, data[2], data[3]);
// DrawLine(spriteBatch, data[3], data[0]);
// }
// }
// spriteBatch.End();
DrawStats(spriteBatch, gameTime);
base.Draw(gameTime);
}