diff --git a/README.md b/README.md index 9d767ca..6223b8d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # EntityX - A fast, type-safe C++ Entity Component System [![Build Status](https://travis-ci.org/alecthomas/entityx.png)](https://travis-ci.org/alecthomas/entityx) -***NOTE: The current version 1.0.0alpha1 breaks backwards compataibility. See the [change log](CHANGES.md) for details.*** +***NOTE: The current stable release 1.0.0 breaks backwards compataibility with < 1.0.0. See the [change log](CHANGES.md) for details.*** Entity Component Systems (ECS) are a form of decomposition that completely decouples entity logic and data from the entity "objects" themselves. The [Evolve your Hierarchy](http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/) article provides a solid overview of EC systems and why you should use them. diff --git a/entityx/Entity.h b/entityx/Entity.h index 6c452ac..2810615 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -514,11 +514,16 @@ class EntityManager : entityx::help::NonCopyable { ComponentHandle assign(Entity::Id id, Args && ... args) { assert_valid(id); const BaseComponent::Family family = C::family(); + // Placement new into the component pool. Pool *pool = accomodate_component(); new(pool->get(id.index())) C(std::forward(args) ...); - ComponentHandle component(this, id); + + // Set the bit for this component. entity_component_mask_[id.index()].set(family); + + // Create and return handle. + ComponentHandle component(this, id); event_manager_.emit>(Entity(this, id), component); return component; } @@ -533,10 +538,16 @@ class EntityManager : entityx::help::NonCopyable { assert_valid(id); const BaseComponent::Family family = C::family(); const uint32_t index = id.index(); - ComponentHandle component(this, id); + + // Find the pool for this component family. BasePool *pool = component_pools_[family]; + ComponentHandle component(this, id); event_manager_.emit>(Entity(this, id), component); + + // Remove component bit. entity_component_mask_[id.index()].reset(family); + + // Call destructor. pool->destroy(index); }