Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 21, 2008, 4:56:41 PM (16 years ago)
Author:
landauf
Message:
  • added ControllableEntity, the baseclass of all players, vehicles and ships.
  • moved Template to core
  • some changes in Camera
  • added 6 constants to WorldEntity to identify relative directions
  • changed vom Radian to Degree as default angle unit
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/BaseObject.cc

    r1625 r1989  
    3737#include "XMLPort.h"
    3838#include "Level.h"
     39#include "Template.h"
    3940
    4041namespace orxonox
     
    7677        XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);
    7778        XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);
     79
     80        XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, const std::string&);
    7881    }
    7982
     
    8689        return this->level_->getFile();
    8790    }
     91
     92    /**
     93        @brief Adds a Template to the object.
     94        @param name The name of the Template
     95    */
     96    void BaseObject::addTemplate(const std::string& name)
     97    {
     98        Template* temp = Template::getTemplate(name);
     99        if (temp)
     100            this->addTemplate(temp);
     101        else
     102            COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl;
     103    }
     104
     105    /**
     106        @brief Adds a Template to the object.
     107        @param temp The Template
     108    */
     109    void BaseObject::addTemplate(Template* temp)
     110    {
     111        this->templates_.insert(temp);
     112        temp->applyOn(this);
     113    }
     114
     115    /**
     116        @brief Returns the Template with the given index.
     117        @param index The index
     118    */
     119    Template* BaseObject::getTemplate(unsigned int index) const
     120    {
     121        unsigned int i = 0;
     122        for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)
     123        {
     124            if (i == index)
     125                return (*it);
     126            i++;
     127        }
     128        return 0;
     129    }
    88130}
Note: See TracChangeset for help on using the changeset viewer.