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/items
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.