using System.Collections.Generic; using System.Linq; namespace Encompass { public struct Entity { public readonly uint id; private ComponentManager componentManager; internal Entity(uint id, ComponentManager componentManager) { this.id = id; this.componentManager = componentManager; } public void AddComponent(TComponent component) where TComponent : struct, IComponent { componentManager.AddComponent(id, component); } public IEnumerable GetComponents() where TComponent : struct, IComponent { return componentManager.GetComponentsByEntityAndType(id); } public TComponent GetComponent() where TComponent : struct, IComponent { return GetComponents().First(); } public bool HasComponent() where TComponent : struct, IComponent { return componentManager.EntityHasComponentOfType(id); } internal void RemoveAllComponents() { componentManager.RemoveAllComponentsFromEntity(id); } } }