00001 #include "element.hh" 00002 #include "abstractworld.hh" 00003 #include <iostream> 00004 00005 namespace anoid { 00006 namespace base { 00007 00008 Object *Element::add(Object* o) { 00009 Shape *s = dynamic_cast<Shape *>(o); 00010 if (s) { 00011 theShape = s; 00013 } 00014 00015 Ability *a = dynamic_cast<Ability *>(o); 00016 if (a) 00017 childrenA.push_back(a); 00018 00019 return Object::add(o); 00020 } 00021 00022 Ability *Element::lookupAbility(const char *c) { 00023 return abilities[c]; 00024 } 00025 00026 void Element::redraw() { 00027 getWorld()->getContext()->pushMatrix(); 00028 vector<Ability*>::iterator i; 00029 for (i = childrenA.begin(); i != childrenA.end(); ++i) { 00030 (*i)->redraw(); 00031 } 00032 if (theShape) theShape->redraw(); 00033 getWorld()->getContext()->popMatrix(); 00034 } 00035 00036 }; 00037 };