private EntityAdapterComponent GetOrAddGameEntityComponent(TEntity entity) { int index = indexLookUp.EntityAdapterComponentIndex; EntityAdapterComponent comp = (EntityAdapterComponent)EntitasGameEntity <TEntity> .DoGetComponent(entity, index); if (comp == null) { comp = EntitasGameEntity <TEntity> .DoAddComponent <EntityAdapterComponent>(entity, index); comp.SelfAdapter = null; } return(comp); }
private void ContextOnOnEntityDestroyed(IContext context, IEntity entity1) { var entity = (TEntity)entity1; entity.RemoveOnComponentAdded(onOnComponentAddedCache); entity.RemoveOnComponentRemoved(onOnComponentRemovedCache); entity.RemoveOnComponentReplaced(onOnComponentReplacedCache); if (EntityRemoved != null) { var entityKeyComp = EntitasGameEntity <TEntity> .DoGetComponent(entity, indexLookUp.EntityKeyComponentIndex); if (entityKeyComp != null) { EntityRemoved(GetGameEntity(entity)); } var posComp = EntitasGameEntity <TEntity> .DoGetComponent(entity, indexLookUp.PositionComponentIndex); if (posComp != null) { NotifyComponentChanged(entity1, indexLookUp.PositionComponentIndex, posComp, null); } } }