almost finished this beast

This commit is contained in:
Dylan Wilson
2018-06-13 23:03:22 +10:00
parent ac14c9e1be
commit 9b2d3670e5
18 changed files with 313 additions and 146 deletions
@@ -0,0 +1,43 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Entities.Systems;
namespace Sandbox.Systems
{
public class RenderSystem : EntityDrawSystem
{
private readonly GraphicsDevice _graphicsDevice;
private readonly SpriteBatch _spriteBatch;
private ComponentMapper<Transform2> _transformMapper;
public RenderSystem(GraphicsDevice graphicsDevice)
: base(Aspect.All(typeof(Transform2)))
{
_graphicsDevice = graphicsDevice;
_spriteBatch = new SpriteBatch(graphicsDevice);
}
public override void Initialize(IComponentMapperService mapperService)
{
_transformMapper = mapperService.GetMapper<Transform2>();
}
public override void Draw(GameTime gameTime)
{
_graphicsDevice.Clear(Color.Black);
_spriteBatch.Begin(samplerState: SamplerState.PointClamp);
foreach (var entity in ActiveEntities)
{
var transform = _transformMapper.Get(entity);
_spriteBatch.FillRectangle(transform.Position, new Size2(3, 3), Color.LightBlue);
}
_spriteBatch.End();
}
}
}