+#include "entityManager.h"
+#include "Entities/Entity.h"
+#include "Entities/Particle.h"
+#include "Entities/PhysicsEntity.h"
+
+#include <set>
+using std::set;
+
+#include <iostream>
+
+/// ***** Private Method Headers *****
+void updateParticles(float);
+void updatePhysics(float);
+
+/// ***** Private Variables *****
+typedef set<Particle*> setPart;
+setPart particles_To_Add;
+setPart active_Particles;
+setPart particles_To_Remove;
+bool clearParticles;
+
+typedef set<PhysicsEntity*> setPhys;
+setPhys physics_To_Add;
+setPhys active_Physics;
+setPhys physics_To_Remove;
+bool clearPhysics;
+
+/// ***** Public Methods *****
+
+void entityMInit()
+{
+}
+void entityMClean()
+{
+}
+
+void addEntity(Entity* e)
+{
+ {
+ Particle* p = dynamic_cast<Particle*>(e);
+ if( p != 0 )
+ {
+ particles_To_Add.insert(p);
+ return;
+ }
+ }
+
+ {
+ PhysicsEntity* p = dynamic_cast<PhysicsEntity*>(e);
+ if( p != 0 )
+ {
+ physics_To_Add.insert(p);
+ return;
+ }
+ }
+
+ std::cerr << "ENTITY TYPE NOT SUPPORTED BY addEntity()!!";
+ std::cerr << std::endl;
+}
+void deleteEntity(Entity* e)
+{
+ {
+ Particle* p = dynamic_cast<Particle*>(e);
+ if( p != 0 )
+ {
+ particles_To_Remove.insert(p);
+ return;
+ }
+ }
+
+ {
+ PhysicsEntity* p = dynamic_cast<PhysicsEntity*>(e);
+ if( p != 0 )
+ {
+ physics_To_Remove.insert(p);
+ return;
+ }
+ }
+
+ std::cerr << "ENTITY TYPE NOT SUPPORTED BY deleteEntity()!!";
+ std::cerr << std::endl;
+}
+
+void clear()
+{
+ clearParticles = true;
+ clearPhysics = true;
+}
+
+void handleInput()
+{
+ // TODO
+}
+void updateEntities(float time_step)
+{
+ updateParticles(time_step);
+ updatePhysics(time_step);
+}
+void drawEntities()
+{
+ // update active Particle*s
+ for( setPart::iterator it = active_Particles.begin();
+ it != active_Particles.end();
+ it++ )
+ {
+ (*it)->draw();
+ }
+
+ // update active PhysicsEntity*s
+ for( setPhys::iterator it = active_Physics.begin();
+ it != active_Physics.end();
+ it++ )
+ {
+ (*it)->draw();
+ }
+}
+
+/// ***** Private Methods *****
+void updateParticles(float time_step)
+{
+ // add new Particle*s to Active
+ for( setPart::iterator it = particles_To_Add.begin();
+ it != particles_To_Add.end();
+ it++ )
+ {
+ active_Particles.insert(*it);
+ }
+ particles_To_Add.clear();
+
+ // remove dead Particle*s from Active
+ for( setPart::iterator it = particles_To_Remove.begin();
+ it != particles_To_Remove.end();
+ it++ )
+ {
+ active_Particles.erase(*it);
+ }
+ particles_To_Remove.clear();
+
+ // update active Particle*s
+ for( setPart::iterator it = active_Particles.begin();
+ it != active_Particles.end();
+ it++ )
+ {
+ (*it)->update(time_step);
+ }
+}
+void updatePhysics(float time_step)
+{
+ // add new PhysicsEntity*s to Active
+ for( setPhys::iterator it = physics_To_Add.begin();
+ it != physics_To_Add.end();
+ it++ )
+ {
+ active_Physics.insert(*it);
+ }
+ physics_To_Add.clear();
+
+ // remove dead PhysicsEntity*s from Active
+ for( setPhys::iterator it = physics_To_Remove.begin();
+ it != physics_To_Remove.end();
+ it++ )
+ {
+ active_Physics.erase(*it);
+ }
+ physics_To_Remove.clear();
+
+ // update active PhysicsEntity*s
+ for( setPhys::iterator it = active_Physics.begin();
+ it != active_Physics.end();
+ it++ )
+ {
+ (*it)->update(time_step);
+ }
+}