public void Initialize <TC0>(uint id, TC0 component0) where TC0 : class, IEcsComponent, new() { Id = id; byte index0 = EcsComponentType <TC0> .Index; _archetype = _archetypeManager.FindOrCreateArchetype(index0); _archetype.AddComponent(index0, component0); _archetype.AddEntity(this); }
internal void AddComponent(byte index, IEcsComponent component) { EcsArchetype newArchetype = _archetypeManager.FindOrCreateNextArchetype(_archetype, index); foreach (byte curIndex in _archetype.Indices) { IEcsComponentPool componentPool = _archetype.GetComponentPool(curIndex); newArchetype.AddComponent(curIndex, componentPool.Get(ArchetypeIndex)); } newArchetype.AddComponent(index, component); _archetype.RemoveEntity(this); _archetype = newArchetype; _archetype.AddEntity(this); }
public void Initialize <TC0, TC1, TC2>(uint id, TC0 component0, TC1 component1, TC2 component2) where TC0 : class, IEcsComponent, new() where TC1 : class, IEcsComponent, new() where TC2 : class, IEcsComponent, new() { Id = id; byte index0 = EcsComponentType <TC0> .Index; byte index1 = EcsComponentType <TC1> .Index; byte index2 = EcsComponentType <TC2> .Index; _archetype = _archetypeManager.FindOrCreateArchetype(index0, index1, index2); _archetype.AddComponent(index0, component0); _archetype.AddComponent(index1, component1); _archetype.AddComponent(index2, component2); _archetype.AddEntity(this); }
internal void RemoveComponent(byte index) { EcsArchetype newArchetype = _archetypeManager.FindOrCreatePriorArchetype(_archetype, index); foreach (byte curIndex in _archetype.Indices) { if (curIndex == index) { continue; } IEcsComponentPool componentPool = _archetype.GetComponentPool(curIndex); newArchetype.AddComponent(curIndex, componentPool.Get(ArchetypeIndex)); } _archetype.RemoveEntity(this); _archetype = newArchetype; _archetype.AddEntity(this); }
public void Initialize(uint id) { Id = id; _archetype = _archetypeManager.Empty; _archetype.AddEntity(this); }