blob: ada6a777a21bc4912bf0f6023aab2e94012cebff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
using Celesteia.Graphics;
using Celesteia.Resources.Sprites;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Entities.Systems;
namespace Celesteia.Game.Systems.MainMenu {
public class MainMenuRenderSystem : EntityDrawSystem
{
private ComponentMapper<Transform2> transformMapper;
private ComponentMapper<SkyboxPortionFrames> framesMapper;
private Camera2D _camera;
private SpriteBatch _spriteBatch;
public MainMenuRenderSystem(Camera2D camera, SpriteBatch spriteBatch) : base(Aspect.All(typeof(Transform2), typeof(SkyboxPortionFrames))) {
_camera = camera;
_spriteBatch = spriteBatch;
}
public override void Initialize(IComponentMapperService mapperService)
{
transformMapper = mapperService.GetMapper<Transform2>();
framesMapper = mapperService.GetMapper<SkyboxPortionFrames>();
}
public override void Draw(GameTime gameTime)
{
_spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.PointClamp, null, RasterizerState.CullNone, null, _camera.GetViewMatrix());
foreach (int entityId in ActiveEntities) {
SkyboxPortionFrames frames = framesMapper.Get(entityId);
Transform2 transform = transformMapper.Get(entityId);
frames.Draw(0, _spriteBatch, transform.Position, transform.Rotation, transform.Scale);
}
_spriteBatch.End();
}
}
}
|