Change folder structure, add solution to the root.
This commit is contained in:
58
DaggerFramework/Source/SceneGraph/EntityLayer.cs
Executable file
58
DaggerFramework/Source/SceneGraph/EntityLayer.cs
Executable file
@@ -0,0 +1,58 @@
|
||||
using DaggerFramework.Rendering;
|
||||
|
||||
namespace DaggerFramework.SceneGraph
|
||||
{
|
||||
public class EntityLayer : Layer
|
||||
{
|
||||
public List<Entity> Entities { get => _entities; }
|
||||
public EntityLayer(List<Entity> entities)
|
||||
{
|
||||
_entities = entities;
|
||||
}
|
||||
|
||||
public EntityLayer()
|
||||
{
|
||||
_entities = new List<Entity>();
|
||||
}
|
||||
|
||||
public bool AddEntity(Entity entity)
|
||||
{
|
||||
entity.Id = Entities.Count;
|
||||
entity.Layer = this;
|
||||
Entities.Add(entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DestroyEntity(int at)
|
||||
{
|
||||
_entities.RemoveAt(at);
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
foreach (var entity in _entities)
|
||||
{
|
||||
entity.Layer = this;
|
||||
entity.Start();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate(double dt)
|
||||
{
|
||||
foreach (var entity in _entities)
|
||||
{
|
||||
entity.Update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDraw(Renderer renderer)
|
||||
{
|
||||
foreach (IDrawable drawable in _entities)
|
||||
{
|
||||
drawable.Draw(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Entity> _entities;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user