using System; using System.Collections.Generic; using System.Linq; namespace Encompass { public struct Entity { public readonly Guid id; private ComponentManager componentManager; internal Entity(Guid id, ComponentManager componentManager) { this.id = id; this.componentManager = componentManager; } public Guid AddComponent(TComponent component) where TComponent : struct, IComponent { return componentManager.AddComponent(id, component); } public IEnumerable> GetComponents() where TComponent : struct, IComponent { return componentManager.GetComponentsByEntityAndType(id); } public KeyValuePair 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); } } }