public void RemoveEntity(EngineEntity entity) { _logger.Info("Removing entity `{0}`", entity.Id); var didRemove = false; lock (_removedEntities) { if (!_removedEntities.Contains(entity)) { _removedEntities.Add(entity); didRemove = true; } } if (didRemove) { _eventDispatcher.Post(new EntityRemoved(entity.Id)); } }
/// <summary> /// Returns the writeable component of type <typeparamref name="TWrite" /> for the next tick. /// </summary> /// <exception cref="ComponentAccessException"> /// Thrown if the component does not exist on the entity or has already been /// accessed during this tick. /// </exception> /// <typeparam name="TWrite">The interface type of the component you wish to write too.</typeparam> /// <returns>The writeable component of type <typeparamref name="TWrite" />.</returns> public TWrite Modify <TWrite>() where TWrite : class, IWriteableComponent { var accessor = WriteableComponentMap <TWrite> .Accessor; ComponentContainer c; if (!_components.TryGetValue(accessor, out c)) { throw new ComponentAccessException(Id, typeof(TWrite), ComponentAccessException.Reasons.ComponentDoesNotExist); } if (!_dirtyTracker.TrySetDirty(accessor)) { throw new ComponentAccessException(Id, typeof(TWrite), ComponentAccessException.Reasons.ComponentAlreadyAccessed); } _eventDispatcher.Post(new EntityComponentModified(Id, accessor)); return((TWrite)_components[accessor].Next); }