[Orxonox-commit 1890] r6607 - in code/branches/ppspickups1: data/levels/templates src/modules/pickup src/modules/pickup/items src/orxonox/interfaces src/orxonox/items src/orxonox/worldentities/pawns

ebeier at orxonox.net ebeier at orxonox.net
Mon Mar 22 22:45:09 CET 2010


Author: ebeier
Date: 2010-03-22 22:45:09 +0100 (Mon, 22 Mar 2010)
New Revision: 6607

Modified:
   code/branches/ppspickups1/data/levels/templates/pickup_representation_templates_speed.oxt
   code/branches/ppspickups1/src/modules/pickup/Pickup.cc
   code/branches/ppspickups1/src/modules/pickup/Pickup.h
   code/branches/ppspickups1/src/modules/pickup/PickupPrereqs.h
   code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc
   code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h
   code/branches/ppspickups1/src/orxonox/interfaces/PickupCarrier.h
   code/branches/ppspickups1/src/orxonox/items/Engine.cc
   code/branches/ppspickups1/src/orxonox/items/Engine.h
   code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc
   code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
first working version of the SpeedPickup, needs some more work for "onUse" type. Spaceship trails need to be looked at, because they don't show when a SpeedPickup with SpeedAdd is used.

Modified: code/branches/ppspickups1/data/levels/templates/pickup_representation_templates_speed.oxt
===================================================================
--- code/branches/ppspickups1/data/levels/templates/pickup_representation_templates_speed.oxt	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/data/levels/templates/pickup_representation_templates_speed.oxt	2010-03-22 21:45:09 UTC (rev 6607)
@@ -16,9 +16,9 @@
 
 <Template name=smallspeedpickup>
   <SpeedPickup
-    duration = 10
-    speedAdd = 1
-    SpeedMultiply = 1
+    duration = 10.0
+    speedAdd = 0
+    SpeedMultiply = 10
     activationType = "immediate"
     durationType = "once"
   />

Modified: code/branches/ppspickups1/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/Pickup.cc	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/modules/pickup/Pickup.cc	2010-03-22 21:45:09 UTC (rev 6607)
@@ -36,28 +36,30 @@
 #include "core/CoreIncludes.h"
 #include "util/StringUtils.h"
 #include "pickup/PickupIdentifier.h"
-#include "DroppedPickup.h"
+#include "DroppedPickup.h"
+
+#include "tools/Timer.h"
 
 namespace orxonox
 {
-    
+
     /*static*/ const std::string Pickup::activationTypeImmediate_s = "immediate";
     /*static*/ const std::string Pickup::activationTypeOnUse_s = "onUse";
     /*static*/ const std::string Pickup::durationTypeOnce_s = "once";
     /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous";
-    
+
     Pickup::Pickup(BaseObject* creator) : BaseObject(creator)
     {
         RegisterObject(Pickup);
-        
+
         this->initialize();
     }
-    
+
     Pickup::~Pickup()
     {
-        
+
     }
-    
+
     /**
     @brief
         Initializes the member variables.
@@ -67,22 +69,22 @@
         this->activationType_ = pickupActivationType::immediate;
         this->durationType_ = pickupDurationType::once;
     }
-    
+
     /**
     @brief
         Initializes the PickupIdentififer of this Pickup.
     */
     void Pickup::initializeIdentifier(void)
-    {        
+    {
         std::string val1 = this->getActivationType();
         std::string type1 = "activationType";
         this->pickupIdentifier_->addParameter(type1, val1);
-        
+
         std::string val2 = this->getDurationType();
         std::string type2 = "durationType";
         this->pickupIdentifier_->addParameter(type2, val2);
     }
-    
+
     /**
     @brief
         Method for creating a Pickup object through XML.
@@ -93,10 +95,10 @@
 
         XMLPortParam(Pickup, "activationType", setActivationType, getActivationType, xmlelement, mode);
         XMLPortParam(Pickup, "durationType", setDurationType, getDurationType, xmlelement, mode);
-        
+
         this->initializeIdentifier();
     }
-    
+
     /**
     @brief
         Get the activation type of the pickup.
@@ -115,7 +117,7 @@
                 return BLANKSTRING;
         }
     }
-        
+
     /**
     @brief
         Get the duration type of the pickup.
@@ -134,7 +136,7 @@
                 return BLANKSTRING;
         }
     }
-    
+
     /**
     @brief
         Set the activation type of the Pickup.
@@ -156,7 +158,7 @@
             COUT(1) << "Invalid activationType in pickup." << std::endl;
         }
     }
-        
+
     /**
     @brief
         Set the duration type of the Pickup.
@@ -178,7 +180,7 @@
             COUT(1) << "Invalid durationType in pickup." << std::endl;
         }
     }
-    
+
     /**
     @brief
         Should be called when the pickup has transited from picked up to dropped or the other way around.
@@ -187,14 +189,14 @@
     void Pickup::changedPickedUp(void)
     {
         SUPER(Pickup, changedPickedUp);
-        
+
         //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
         if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate())
         {
             this->setUsed(true);
         }
     }
-    
+
     /**
     @brief
         Creates a duplicate of the Pickup.
@@ -205,16 +207,16 @@
     {
         if(item == NULL)
             item = new Pickup(this);
-        
+
         SUPER(Pickup, clone, item);
-        
+
         Pickup* pickup = dynamic_cast<Pickup*>(item);
         pickup->setActivationTypeDirect(this->getActivationTypeDirect());
         pickup->setDurationTypeDirect(this->getDurationTypeDirect());
-        
+
         pickup->initializeIdentifier();
     }
-        
+
     /**
     @brief
         Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
@@ -229,6 +231,25 @@
     {
         new DroppedPickup(this, this, this->getCarrier());
         return true;
+    }
+
+    /**
+    @brief
+        Starts the Pickup duration Timer.
+    */
+    bool Pickup::startPickupTimer(float durationTime)
+    {
+        if (durationTime<=0)
+        {
+            COUT(1) << "Invalid durationTime in pickup." << std::endl;
+            return false;
+        }
+        if (false) /* How to check if Timer already running? */
+        {
+            COUT(1) << "Pickup durationTimer already in use." << std::endl;
+            return false;
+        }
+        this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::PickupTimerCallBack, this)));
+        return true;
     }
-    
 }

Modified: code/branches/ppspickups1/src/modules/pickup/Pickup.h
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/Pickup.h	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/modules/pickup/Pickup.h	2010-03-22 21:45:09 UTC (rev 6607)
@@ -37,9 +37,11 @@
 #include "pickup/PickupPrereqs.h"
 
 #include "core/BaseObject.h"
-#include "core/XMLPort.h"
+#include "core/XMLPort.h"
 
 #include "interfaces/Pickupable.h"
+
+#include "tools/Timer.h"
 
 namespace orxonox
 {
@@ -53,7 +55,7 @@
             onUse,
         };
     }
-    
+
     //! Enum for the duration tyoe.
     namespace pickupDurationType
     {
@@ -63,7 +65,7 @@
             continuous,
         };
     }
-    
+
     /**
     @brief
         Pickup class. Offers base functionality for a wide range of pickups.
@@ -73,15 +75,15 @@
     */
     class _PickupExport Pickup : public Pickupable, public BaseObject
     {
-        
+
         protected:
             Pickup(BaseObject* creator); //!< Constructor.
-        
+
         public:
             virtual ~Pickup(); //!< Destructor.
-            
+
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            
+
             /**
             @brief Get the activation type of the pickup.
             @return Returns the activation type of the pickup.
@@ -94,10 +96,10 @@
             */
             inline pickupDurationType::Value getDurationTypeDirect(void)
                 { return this->durationType_; }
-            
+
             const std::string& getActivationType(void); //!< Get the activation type of the pickup.
             const std::string& getDurationType(void); //!< Get the duration type of the pickup.
-            
+
             /**
             @brief Get whether the activation type is 'immediate'.
             @return Returns true if the activation type is 'immediate'.
@@ -122,16 +124,20 @@
             */
             inline bool isContinuous(void)
                 { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
-            
+
             virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
-                                    
+
             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.
-                
+
         protected:
             void initializeIdentifier(void);
-            
+
             virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
-            
+
+            bool startPickupTimer(float durationTime);
+
+            virtual void PickupTimerCallBack(void) {}
+
             /**
             @brief Set the activation type of the pickup.
             @param type The activation type of the pickup.
@@ -144,22 +150,24 @@
             */
             inline void setDurationTypeDirect(pickupDurationType::Value type)
                 { this->durationType_ = type; }
-                
+
             void setActivationType(const std::string& type); //!< Set the activation type of the pickup.
             void setDurationType(const std::string& type); //!< Set the duration type of the pickup
-                
+
         private:
             void initialize(void); //!< Initializes the member variables.
-            
+
             pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
             pickupDurationType::Value durationType_; //!< The duration type of the pickup.
-            
+
             static const std::string activationTypeImmediate_s;
             static const std::string activationTypeOnUse_s;
             static const std::string durationTypeOnce_s;
             static const std::string durationTypeContinuous_s;
-        
+
+            float durationTime_;
+            Timer durationTimer_;
     };
-    
+
 }
 #endif // _Pickup_H__

Modified: code/branches/ppspickups1/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/PickupPrereqs.h	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/modules/pickup/PickupPrereqs.h	2010-03-22 21:45:09 UTC (rev 6607)
@@ -72,11 +72,12 @@
     class PickupManager;
     class PickupRepresentation;
     class PickupSpawner;
-    
+
     //items
     class HealthPickup;
     class MetaPickup;
-    
+    class SpeedPickup;
+
 }
 
 #endif /* _PickupPrereqs_H__ */

Modified: code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc	2010-03-22 21:45:09 UTC (rev 6607)
@@ -37,7 +37,8 @@
 #include "core/XMLPort.h"
 #include "util/StringUtils.h"
 
-#include "worldentities/pawns/Pawn.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "items/Engine.h"
 #include "pickup/PickupIdentifier.h"
 
 #include <sstream>
@@ -122,33 +123,6 @@
 
     /**
     @brief
-        Is called every tick.
-        Does count down the duration of the SpeedPickup.
-    @param dt
-        The duration of the last tick.
-    */
-    void SpeedPickup::tick(float dt)
-    {
-        if(this->isUsed())
-        {
-            Pawn* pawn = this->carrierToPawnHelper();
-            if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
-                this->destroy();
-
-             //! Calculate the remaining duration of the Pickup
-            float duration=this->getDuration()-dt;
-            this->setDuration(duration);
-
-            //! If duration is over
-            if(this->getDuration() < 0)
-            {
-                this->setUsed(false);
-            }
-        }
-    }
-
-    /**
-    @brief
         Is called when the pickup has transited from used to unused or the other way around.
     */
     void SpeedPickup::changedUsed(void)
@@ -162,43 +136,39 @@
         //! If the pickup has transited to used.
         if(this->isUsed())
         {
-            if(this->isOnce())
-            {
-                Pawn* pawn = this->carrierToPawnHelper();
-                if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
-                    this->destroy();
+            this->startPickupTimer(this->getDuration());
 
-                //! The pickup has been used up.
-                this->setUsed(false);
-            }
-        }
-        else
-        {
-            //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
-            if(this->isOnce() || (this->isContinuous() && this->getDuration() < 0))
-            {
+            Engine* engine = this->carrierToEngineHelper();
+            if(engine == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
                 this->destroy();
-            }
+            engine->setSpeedAdd(this->getSpeedAdd());
+            engine->setSpeedMultiply(this->getSpeedMultiply());
         }
     }
 
+
+
     /**
     @brief
         Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
     @return
         A pointer to the Pawn, or NULL if the conversion failed.
     */
-    Pawn* SpeedPickup::carrierToPawnHelper(void)
+    Engine* SpeedPickup::carrierToEngineHelper(void)
     {
         PickupCarrier* carrier = this->getCarrier();
-        Pawn* pawn = dynamic_cast<Pawn*>(carrier);
+        SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier);
 
-        if(pawn == NULL)
+        if(ship == NULL)
         {
             COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl;
         }
+        else
+        {
+            return ship->getEngine();
+        }
 
-        return pawn;
+        return 0;
     }
 
     /**
@@ -237,7 +207,7 @@
         else
         {
             COUT(1) << "Invalid duration in SpeedPickup." << std::endl;
-            this->duration_ = 0.0;
+            this->duration_ = 0;
         }
     }
 
@@ -249,7 +219,7 @@
     */
     void SpeedPickup::setSpeedAdd(float speedAdd)
     {
-        if(speedAdd > 0.0f)
+        if(speedAdd >= 0.0f)
         {
             this->speedAdd_ = speedAdd;
         }
@@ -268,7 +238,7 @@
     */
     void SpeedPickup::setSpeedMultiply(float speedMultiply)
     {
-        if(speedMultiply != 0.0f)
+        if(speedMultiply != 0)
         {
             this->speedMultiply_ = speedMultiply;
         }
@@ -278,4 +248,8 @@
             this->speedMultiply_ = 1.0;
         }
     }
+
+    void SpeedPickup::PickupTimerCallBack(void) {
+        COUT(2) << "Timer ended!" << std::endl;
+    }
 }

Modified: code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h	2010-03-22 21:45:09 UTC (rev 6607)
@@ -56,7 +56,7 @@
     @author
         Eric Beier
     */
-    class _PickupExport SpeedPickup : public Pickup, public Tickable
+    class _PickupExport SpeedPickup : public Pickup
     {
         public:
 
@@ -64,7 +64,6 @@
             virtual ~SpeedPickup(); //!< Destructor.
 
             virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
-            virtual void tick(float dt); //!< Is called every tick.
 
             virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
@@ -79,14 +78,14 @@
         protected:
             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
 
-            void setDuration(float duration); //!< Sets the duration
+            void setDuration(float duration);
             void setSpeedAdd(float speedAdd);
             void setSpeedMultiply(float speedMultiply);
 
-
         private:
             void initialize(void); //!< Initializes the member variables.
-            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+            void PickupTimerCallBack(void); //!< Function that gets called when timer ends.
+            Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
 
             float duration_; //!< The health that is transferred to the Pawn.
             float speedAdd_;

Modified: code/branches/ppspickups1/src/orxonox/interfaces/PickupCarrier.h
===================================================================
--- code/branches/ppspickups1/src/orxonox/interfaces/PickupCarrier.h	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/orxonox/interfaces/PickupCarrier.h	2010-03-22 21:45:09 UTC (rev 6607)
@@ -47,11 +47,6 @@
 namespace orxonox
 {
 
-    //! Pre-declarations.
-    class Pickup;
-    class HealthPickup;
-    class MetaPickup;
-
     /**
     @brief
         The PickupCarrier interface provides the means, for any class implementing it, to possess Pickupables.
@@ -64,12 +59,13 @@
         friend class Pickupable;
         friend class Pickup;
         friend class HealthPickup;
-        friend class MetaPickup;
-        
+        friend class MetaPickup;
+        friend class SpeedPickup;
+
         public:
             PickupCarrier(); //!< Constructor.
             virtual ~PickupCarrier(); //!< Destructor.
-            
+
             /**
             @brief Can be called to pick up a Pickupable.
             @param pickup A pointer to the Pickupable.
@@ -85,7 +81,7 @@
                     }
                     return pickedUp;
                 }
-                
+
             /**
             @brief Can be called to drop a Pickupable.
             @param pickup A pointer to the Pickupable.
@@ -93,7 +89,7 @@
             @return Returns true if the Pickupable has been dropped, false if not.
             */
             bool drop(Pickupable* pickup, bool drop = true)
-                { 
+                {
                     bool dropped = this->pickups_.erase(pickup) == 1;
                     if(dropped && drop)
                     {
@@ -102,7 +98,7 @@
                     }
                     return dropped;
                 }
-                
+
             /**
             @brief Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
             @param pickup A pointer to the Pickupable.
@@ -112,7 +108,7 @@
                 {
                     if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
                         return true;
-                    
+
                     //! Go recursively through all children to check whether they are a target.
                     std::list<PickupCarrier*>* children = this->getCarrierChildren();
                     for(std::list<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)
@@ -120,13 +116,13 @@
                         if((*it)->isTarget(pickup))
                             return true;
                     }
-                    
+
                     children->clear();
                     delete children;
-                    
+
                     return false;
                 }
-                
+
             /**
             @brief Get the carrier that is both a child of the PickupCarrier (or the PickupCarrier itself) and a target of the input Pickupable.
             @param pickup A pounter to the Pickupable.
@@ -136,10 +132,10 @@
                 {
                     if(!this->isTarget(pickup))
                         return NULL;
-                    
+
                     if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
                         return this;
-                    
+
                     //! Go recursively through all children to check whether they are the target.
                     std::list<PickupCarrier*>* children = this->getCarrierChildren();
                     for(std::list<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
@@ -147,26 +143,26 @@
                         if(pickup->isTarget(*it))
                             return *it;
                     }
-                    
+
                     children->clear();
                     delete children;
-                    
+
                     return NULL;
                 }
-                
+
             /**
             @brief Get the (absolute) position of the PickupCarrier.
                    This method needs to be implemented by any direct derivative class of PickupCarrier.
             @return Returns the position as a Vector3.
             */
             virtual const Vector3& getCarrierPosition(void) = 0;
-            
-        protected:        
+
+        protected:
             /**
             @brief Get all direct children of this PickupSpawner.
                    This method needs to be implemented by any direct derivative class of PickupCarrier.
                    The returned list will be deleted by the methods calling this function.
-            @return Returns a pointer to a list of all direct children. 
+            @return Returns a pointer to a list of all direct children.
             */
             virtual std::list<PickupCarrier*>* getCarrierChildren(void) = 0;
             /**
@@ -175,17 +171,17 @@
             @return Returns a pointer to the parent.
             */
             virtual PickupCarrier* getCarrierParent(void) = 0;
-                            
+
             /**
             @brief Get all Pickupables this PickupCarrier has.
             @return  Returns the set of all Pickupables this PickupCarrier has.
             */
             std::set<Pickupable*>& getPickups(void)
                 { return this->pickups_; }
-        
+
         private:
             std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
-            
+
     };
 }
 

Modified: code/branches/ppspickups1/src/orxonox/items/Engine.cc
===================================================================
--- code/branches/ppspickups1/src/orxonox/items/Engine.cc	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/orxonox/items/Engine.cc	2010-03-22 21:45:09 UTC (rev 6607)
@@ -63,6 +63,9 @@
 
         this->boostBlur_ = 0;
 
+        this->speedAdd_ = 0.0;
+        this->speedMultiply_ = 1.0;
+
         this->setConfigValues();
         this->registerVariables();
     }
@@ -118,6 +121,9 @@
         registerVariable(this->accelerationBack_,      VariableDirection::ToClient);
         registerVariable(this->accelerationLeftRight_, VariableDirection::ToClient);
         registerVariable(this->accelerationUpDown_,    VariableDirection::ToClient);
+
+        registerVariable(this->speedAdd_, VariableDirection::ToClient);
+        registerVariable(this->speedMultiply_, VariableDirection::ToClient);
     }
 
     void Engine::networkcallback_shipID()
@@ -191,7 +197,7 @@
                 acceleration.y = direction.y * this->accelerationUpDown_ * clamp((this->maxSpeedUpDown_ - velocity.y) / this->maxSpeedUpDown_, 0.0f, 1.0f);
         }
 
-        this->ship_->setAcceleration(this->ship_->getOrientation() * acceleration);
+        this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
 
         if (!this->ship_->getPermanentBoost())
             this->ship_->setBoost(false);
@@ -240,4 +246,14 @@
         else
             return Vector3::ZERO;
     }
+
+    PickupCarrier* Engine::getCarrierParent(void)
+    {
+        return this->ship_;
+    }
+
+    const Vector3& Engine::getCarrierPosition(void)
+    {
+        return this->ship_->getWorldPosition();
+    }
 }

Modified: code/branches/ppspickups1/src/orxonox/items/Engine.h
===================================================================
--- code/branches/ppspickups1/src/orxonox/items/Engine.h	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/orxonox/items/Engine.h	2010-03-22 21:45:09 UTC (rev 6607)
@@ -34,9 +34,11 @@
 #include "tools/interfaces/Tickable.h"
 #include "Item.h"
 
+#include "interfaces/PickupCarrier.h"
+
 namespace orxonox
 {
-    class _OrxonoxExport Engine : public Item, public Tickable
+    class _OrxonoxExport Engine : public Item, public Tickable, public PickupCarrier
     {
         public:
             Engine(BaseObject* creator);
@@ -103,8 +105,26 @@
             inline float getAccelerationUpDown() const
                 { return this->accelerationUpDown_; }
 
+            inline float getSpeedAdd(void)
+                { return this->speedAdd_; }
+            inline float getSpeedMultiply(void)
+                { return this->speedMultiply_; }
+
             virtual const Vector3& getDirection() const;
 
+            virtual const Vector3& getCarrierPosition(void);
+
+            /* not in protected ?? */
+            inline void setSpeedAdd(float speedAdd)
+                { this->speedAdd_=speedAdd; }
+            inline void setSpeedMultiply(float speedMultiply)
+                { this->speedMultiply_=speedMultiply; }
+
+        protected:
+            virtual std::list<PickupCarrier*>* getCarrierChildren(void)
+                { return new std::list<PickupCarrier*>(); }
+            virtual PickupCarrier* getCarrierParent(void);
+
         private:
             void networkcallback_shipID();
 
@@ -114,6 +134,9 @@
             float boostFactor_;
             float speedFactor_;
 
+            float speedAdd_;
+            float speedMultiply_;
+
             float maxSpeedFront_;
             float maxSpeedBack_;
             float maxSpeedLeftRight_;

Modified: code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc	2010-03-22 21:45:09 UTC (rev 6607)
@@ -219,4 +219,11 @@
         if (engine && engine->getShip() != this)
             engine->addToSpaceShip(this);
     }
+
+    std::list<PickupCarrier*>* SpaceShip::getCarrierChildren(void)
+    {
+        std::list<PickupCarrier*>* list = new std::list<PickupCarrier*>();
+        list->push_front(engine_);
+        return list;
+    }
 }

Modified: code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.h	2010-03-22 19:00:37 UTC (rev 6606)
+++ code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.h	2010-03-22 21:45:09 UTC (rev 6607)
@@ -85,6 +85,7 @@
                 { return this->bPermanentBoost_; }
 
         protected:
+            virtual std::list<PickupCarrier*>* getCarrierChildren(void);
             bool bInvertYAxis_;
 
             bool bBoost_;




More information about the Orxonox-commit mailing list