Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 22, 2006, 1:16:23 PM (19 years ago)
Author:
bensch
Message:

adapted many classes to the new ClassID System, now comes the hard part… Scripting… then Network… wow this will be so bad :/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/effects/atmospheric_engine.cc

    r9406 r9685  
    2222#include "util/loading/load_param.h"
    2323#include "util/loading/factory.h"
    24 #include "class_list.h"
    2524
    26 
    27 
     25NewObjectListDefinition(AtmosphericEngine);
    2826
    2927/**
    3028 * @param root The XML-element to load the AtmosphericEngine from
    3129 */
    32 AtmosphericEngine::AtmosphericEngine() {
    33     this->setClassID(CL_ATMOSPHERIC_ENGINE, "AtmosphericEngine");
     30AtmosphericEngine::AtmosphericEngine()
     31{
     32  this->registerObject(this, AtmosphericEngine::_objectList);
    3433}
    3534
     
    4342 *  destroys a AtmosphericEngine
    4443 */
    45 AtmosphericEngine::~AtmosphericEngine() {
    46     AtmosphericEngine::singletonRef = NULL;
     44AtmosphericEngine::~AtmosphericEngine()
     45{
     46  AtmosphericEngine::singletonRef = NULL;
    4747
    48     const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
    49 
    50     if (weatherEffects != NULL) {
    51         while(!weatherEffects->empty())
    52             delete weatherEffects->front();
    53     }
     48  while(!WeatherEffect::objectList().empty())
     49    delete WeatherEffect::objectList().front();
    5450}
    5551
     
    5753 * @param root The XML-element to load the AtmosphericEngine from
    5854 */
    59 void AtmosphericEngine::loadParams(const TiXmlElement* root) {
    60     LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect);
    61     LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect);
     55void AtmosphericEngine::loadParams(const TiXmlElement* root)
     56{
     57  LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect);
     58  LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect);
    6259}
    6360
     
    6562 * @param root The XML-element to load WeatherEffects from
    6663 */
    67 void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root) {
    68     LOAD_PARAM_START_CYCLE(root, element);
    69     {
    70         PRINTF(4)("element is: %s\n", element->Value());
    71         // Factory::fabricate(element);
     64void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root)
     65{
     66  LOAD_PARAM_START_CYCLE(root, element);
     67  {
     68    PRINTF(4)("element is: %s\n", element->Value());
     69    // Factory::fabricate(element);
    7270
    73         BaseObject* bo = Factory::fabricate(element);
    74         if( bo == NULL)
    75             PRINTF(0)(" Could not create Element %s\n", element->Value());
    76     }
    77     LOAD_PARAM_END_CYCLE(element);
     71    BaseObject* bo = Factory::fabricate(element);
     72    if( bo == NULL)
     73      PRINTF(0)(" Could not create Element %s\n", element->Value());
     74  }
     75  LOAD_PARAM_END_CYCLE(element);
    7876}
    7977
     
    8179 * @param root The XML-element to load SunEffects from
    8280 */
    83 void AtmosphericEngine::loadSunEffect(const TiXmlElement* root) {
    84     LOAD_PARAM_START_CYCLE(root, element);
    85     {
    86         PRINTF(4)("element is: %s\n", element->Value());
    87     }
    88     LOAD_PARAM_END_CYCLE(element);
     81void AtmosphericEngine::loadSunEffect(const TiXmlElement* root)
     82{
     83  LOAD_PARAM_START_CYCLE(root, element);
     84  {
     85    PRINTF(4)("element is: %s\n", element->Value());
     86  }
     87  LOAD_PARAM_END_CYCLE(element);
    8988}
    9089
     
    9392 * draws the effect, if needed
    9493 */
    95 void AtmosphericEngine::draw() const {
    96     const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
    97 
    98     // draw the weather effects
    99     if (weatherEffects != NULL) {
    100         std::list<BaseObject*>::const_iterator it;
    101         for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
    102             dynamic_cast<WeatherEffect*>(*it)->draw();
    103     }
     94void AtmosphericEngine::draw() const
     95{
     96  for (NewObjectList<WeatherEffect>::const_iterator it = WeatherEffect::objectList().begin();
     97       it != WeatherEffect::objectList().end();
     98       ++it)
     99    (*it)->draw();
    104100}
    105101
     
    109105 * ticks the effect if there is any time dependancy
    110106 */
    111 void AtmosphericEngine::tick(float dt) {
    112     const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
     107void AtmosphericEngine::tick(float dt)
     108{
    113109
    114     // tick the weather effects
    115     if (weatherEffects != NULL) {
    116         std::list<BaseObject*>::const_iterator it;
    117         for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) {
    118             /*      printf("%s::%s \n", (*it)->getClassCName(), (*it)->getName());*/
    119             dynamic_cast<WeatherEffect*>(*it)->tick(dt);
    120         }
    121     }
     110  for (NewObjectList<WeatherEffect>::const_iterator it = WeatherEffect::objectList().begin();
     111       it != WeatherEffect::objectList().end();
     112       ++it)
     113    (*it)->tick(dt);
    122114}
Note: See TracChangeset for help on using the changeset viewer.