-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entity.cs
41 lines (34 loc) · 832 Bytes
/
Entity.cs
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 SFML.Graphics;
using SFML.System;
namespace Tiler
{
public enum EntityComponents
{
Null = 0,
PhysicsBody,
GraphicsBody,
}
public abstract class Entity : ECS.Entity
{
public void Remove()
{
components.Clear();
foreach (var system in systems.ToArray())
{
system.UnregisterEntity(this);
}
World.Entities.Remove(this);
}
public virtual void Draw(RenderTarget target, RenderStates states)
{
if (!HasComponentEnabled<ECS.Components.GraphicsBody>())
return;
if (HasComponentEnabled<ECS.Components.PhysicsBody>())
{
var physicsBody = GetComponent<ECS.Components.PhysicsBody>().Value;
states.Transform.Translate(new Vector2f(physicsBody.Position.X, physicsBody.Position.Y));
}
target.Draw(GetComponent<ECS.Components.GraphicsBody>().Value, states);
}
}
}