Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 8, 2014, 4:20:26 PM (11 years ago)
Author:
noep
Message:

Added PartDestructionEvent, possibly fixed one out of two runtimeerrors

Location:
code/branches/modularships/src/orxonox
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/src/orxonox/OrxonoxPrereqs.h

    r10023 r10052  
    143143    // items
    144144    class ShipPart;
     145    class PartDestructionEvent;
    145146    class Engine;
    146147    class Item;
  • code/branches/modularships/src/orxonox/items/CMakeLists.txt

    r10019 r10052  
    44  MultiStateEngine.cc
    55  ShipPart.cc
     6  PartDestructionEvent.cc
    67)
  • code/branches/modularships/src/orxonox/items/ShipPart.cc

    r10033 r10052  
    4040#include "gametypes/Gametype.h"
    4141#include "worldentities/StaticEntity.h"
     42#include "items/PartDestructionEvent.h"
    4243
    4344
     
    6667
    6768        XMLPortParam(ShipPart, "damageabsorption", setDamageAbsorption, getDamageAbsorption, xmlelement, mode).defaultValues(0.5);
     69
     70        XMLPortObject(ShipPart, PartDestructionEvent, "destructionevents", addDestructionEvent, getDestructionEvent, xmlelement, mode);
    6871
    6972        /*
     
    142145            orxout() << "  " << this->entityList_[j]->getName() << endl;
    143146        }
     147    }
     148
     149    /**
     150    @brief
     151        Add a PartDestructionEvent to the ShipPart.
     152    @param engine
     153        A pointer to the PartDestructionEvent to be added.
     154    */
     155    void ShipPart::addDestructionEvent(PartDestructionEvent* part)
     156    {
     157        OrxAssert(part != NULL, "The PartDestructionEvent cannot be NULL.");
     158        this->eventList_.push_back(part);
     159        //part->setParent(this);
     160    }
     161
     162    /**
     163    @brief
     164        Get the i-th PartDestructionEvent of the ShipPart.
     165    @return
     166        Returns a pointer to the i-the PartDestructionEvent. NULL if there is no PartDestructionEvent with that index.
     167    */
     168    PartDestructionEvent* ShipPart::getDestructionEvent(unsigned int index)
     169    {
     170        if(this->eventList_.size() >= index)
     171            return NULL;
     172        else
     173            return this->eventList_[index];
    144174    }
    145175
  • code/branches/modularships/src/orxonox/items/ShipPart.h

    r10023 r10052  
    3232#include "OrxonoxPrereqs.h"
    3333#include "Item.h"
     34#include "items/PartDestructionEvent.h"
    3435
    3536#include <string>
     
    5859            StaticEntity* getEntity(unsigned int index);
    5960            bool hasEntity(StaticEntity* entity) const;
     61
     62            void addDestructionEvent(PartDestructionEvent* event);
     63            PartDestructionEvent* getDestructionEvent(unsigned int index);
    6064
    6165            void printEntities(); // FIXME: (noep) remove debug
     
    102106        private:
    103107            std::vector<StaticEntity*> entityList_; // list of all entities which belong to this part
     108            std::vector<PartDestructionEvent*> eventList_;  // The list of all PartDestructionEvent assigned to this ShipPart.
     109
    104110
    105111    }; // tolua_export
  • code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc

    r10033 r10052  
    119119    WorldEntity::~WorldEntity()
    120120    {
     121        orxout() << "destroying " << this->getIdentifier()->getName() << endl;
    121122        if (this->isInitialized())
    122123        {
  • code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc

    r10036 r10052  
    303303        }
    304304        // Remove the part-entity assignment and detach the Entity of this ShipPart
    305         for (std::map<StaticEntity*, ShipPart*>::iterator itt = this->partMap_.begin(); itt != this->partMap_.end(); ++itt)
     305        for (std::map<StaticEntity*, ShipPart*>::iterator itt = this->partMap_.begin(); itt != this->partMap_.end(); )
    306306        {
    307307            if (itt->second == part)
     
    314314                //itt->first->setCollisionType(None);
    315315                //itt->first->deactivatePhysics();
    316                 this->partMap_.erase(itt);
     316                this->partMap_.erase(itt++);
     317            } else {
     318                ++itt;
    317319            }
    318320        }
Note: See TracChangeset for help on using the changeset viewer.