protected int CreateEntityInternal() { int entity; if (_reservedEntitiesCount > 0) { _reservedEntitiesCount--; entity = _reservedEntities[_reservedEntitiesCount]; var entityData = _entities[entity]; entityData.ComponentsCount = 0; } else { entity = _entitiesCount; if (_entitiesCount == _entities.Length) { Array.Resize(ref _entities, _entitiesCount << 1); } _entities[_entitiesCount++] = new EcsEntityInternal(); } #if DEBUG for (var ii = 0; ii < _debugListeners.Count; ii++) { _debugListeners[ii].OnEntityCreated(entity); } #endif #if LEOECS_ENABLE_WORLD_EVENTS for (var ii = 0; ii < _eventListeners.Count; ii++) { _eventListeners[ii].OnEntityCreated(entity); } #endif return(entity); }
protected void ReserveEntity(int entity, EcsEntityInternal entityData) { entityData.ComponentsCount = -1; if (_reservedEntitiesCount == _reservedEntities.Length) { Array.Resize(ref _reservedEntities, _reservedEntitiesCount << 1); } _reservedEntities[_reservedEntitiesCount++] = entity; #if DEBUG for (var ii = 0; ii < _debugListeners.Count; ii++) { _debugListeners[ii].OnEntityRemoved(entity); } #endif #if LEOECS_ENABLE_WORLD_EVENTS for (var ii = 0; ii < _eventListeners.Count; ii++) { _eventListeners[ii].OnEntityRemoved(entity); } #endif }