-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestObjectRenderSystem.cs
More file actions
41 lines (36 loc) · 1.56 KB
/
TestObjectRenderSystem.cs
File metadata and controls
41 lines (36 loc) · 1.56 KB
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
using Leopotam.EcsLite;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
public class TestObjectRenderSystem : IEcsRunSystem
{
private EcsWorld _world;
private EcsFilter _objectFilter;
private EcsPool<GameObject> _gameObjectPool;
private EcsPool<Bounds> _boundsPool;
private EcsPool<ColorComponent> _colorPool;
private EcsPool<Selected> _selectedPool;
private SpriteBatch _spriteBatch;
public TestObjectRenderSystem(EcsWorld world, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch)
{
_world = world;
_objectFilter = _world.Filter<GameObject>().Inc<Bounds>().Inc<ColorComponent>().End();
_gameObjectPool = _world.GetPool<GameObject>();
_boundsPool = _world.GetPool<Bounds>();
_colorPool = _world.GetPool<ColorComponent>();
_selectedPool = _world.GetPool<Selected>();
_spriteBatch = spriteBatch;
}
public void Run(IEcsSystems systems)
{
foreach (int entity in _objectFilter)
{
ref GameObject gameObject = ref _gameObjectPool.Get(entity);
ref Bounds bounds = ref _boundsPool.Get(entity);
ref ColorComponent color = ref _colorPool.Get(entity);
// Меняем цвет, если объект выделен
// color.Value = _selectedPool.Has(entity) ? Color.Red : Color.White;
// Рисуем прямоугольник (квадрат) с помощью pixel texture
//_spriteBatch.Draw(_pixelTexture, bounds.Rectangle, drawColor);
}
}
}