Skip to content

Instantly share code, notes, and snippets.

@catchouli
Created January 4, 2015 03:32
Show Gist options
  • Save catchouli/65ad17845ef503e45197 to your computer and use it in GitHub Desktop.
Save catchouli/65ad17845ef503e45197 to your computer and use it in GitHub Desktop.
coment_rewrite interface example
World world;
EntityManager& em = *world.getManager<EntityManager>();
ComponentManager& cm = *world.getManager<ComponentManager>();
Entity e = em.createEntity();
auto positionMap = cm.getEntityMap<Position>();
auto velocityMap = cm.getEntityMap<Velocity>();
auto radiusMap = cm.getEntityMap<Radius>();
auto moverMap = cm.getEntityMap<Position, Velocity>();
auto circleMap = cm.getEntityMap<Position, Radius>();
cm.addComponent<Position>(e); // positionMap now contains entity
cm.addComponent<Velocity>(e); // positionMap, velocityMap, moverMap now contain entity
cm.removeComponent<Position>(e); // now only velocityMap contains entity
cm.addComponent<Radius>(e); // now positionMap, radiusMap, and circleMap contain entity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment