Created
January 4, 2015 03:32
-
-
Save catchouli/65ad17845ef503e45197 to your computer and use it in GitHub Desktop.
coment_rewrite interface example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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