public virtual Entity CreateEntity()
{
var entity = _reusableEntities.Count > 0
? _reusableEntities.Pop()
: new Entity( _totalComponents, _componentPools, _contextInfo);
entity._isEnabled = true;
entity._creationIndex = _creationIndex++;
entity.Retain(this);
_entities.Add(entity);
_entitiesCache = null;
entity.OnComponentAdded +=_cachedEntityChanged;
entity.OnComponentRemoved += _cachedEntityChanged;
entity.OnComponentReplaced += _cachedComponentReplaced;
entity.OnEntityReleased += _cachedEntityReleased;
if(OnEntityCreated != null) {
OnEntityCreated(this, entity);
}
return entity;
}