private void configureEntity(ECSEntity entity, ECSEntityPool pool, bool isNew) { if (entity == null) { throw new ArgumentNullException("entity"); } if (isNew) { var components = entity.GetComponents(); for (int i = 0; i < components.Length; ++i) { components[i].Entity = entity; } entity.Id = _entities.Count; entity.Pool = pool; _entities.Add(entity); } else { entity.Id = reverseEntityId(entity.Id); } this.debugVerifyEntityId(entity); if (_isIterating) { _entitiesCreatedDuringIteration.Add(entity); } else { this.insertComponentsOfEntity(entity); } entity.gameObject.SendMessage("Acquire", null, SendMessageOptions.DontRequireReceiver); }
private void insertComponentsOfEntity(ECSEntity entity) { var components = entity.GetComponents(); for (int i = 0; i < components.Length; ++i) { this.insertComponent(components[i]); } #if UNITY_EDITOR this.debugAssertInvariants(); #endif }
public void Release(ECSEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } this.debugVerifyEntityId(entity); entity.gameObject.SendMessage("Release", null, SendMessageOptions.DontRequireReceiver); ECSBaseComponent[] components = entity.GetComponents(); for (int i = 0; i < components.Length; ++i) { this.deleteComponent(components[i]); } if (entity.Pool == null) { GameObject.Destroy(entity.gameObject); _entities[entity.Id] = null; } else { entity.Pool.Release(entity.gameObject); entity.Id = reverseEntityId(entity.Id); } }