[Orxonox-commit 1992] r6709 - in code/trunk: . data/levels data/levels/includes data/levels/templates src/modules/pickup src/modules/pickup/items src/orxonox/interfaces src/orxonox/items src/orxonox/worldentities/pawns

dafrick at orxonox.net dafrick at orxonox.net
Tue Apr 13 09:32:08 CEST 2010


Author: dafrick
Date: 2010-04-13 09:32:08 +0200 (Tue, 13 Apr 2010)
New Revision: 6709

Added:
   code/trunk/data/levels/includes/pickups_speed.oxi
   code/trunk/data/levels/pickup_ppstest1.oxw
   code/trunk/data/levels/templates/pickup_representation_templates_speed.oxt
   code/trunk/src/modules/pickup/items/SpeedPickup.cc
   code/trunk/src/modules/pickup/items/SpeedPickup.h
Modified:
   code/trunk/
   code/trunk/src/modules/pickup/Pickup.cc
   code/trunk/src/modules/pickup/Pickup.h
   code/trunk/src/modules/pickup/PickupPrereqs.h
   code/trunk/src/modules/pickup/items/CMakeLists.txt
   code/trunk/src/modules/pickup/items/HealthPickup.cc
   code/trunk/src/modules/pickup/items/HealthPickup.h
   code/trunk/src/modules/pickup/items/MetaPickup.cc
   code/trunk/src/modules/pickup/items/MetaPickup.h
   code/trunk/src/orxonox/interfaces/PickupCarrier.h
   code/trunk/src/orxonox/items/Engine.cc
   code/trunk/src/orxonox/items/Engine.h
   code/trunk/src/orxonox/items/MultiStateEngine.cc
   code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
   code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
Merged ppspickups1 into trunk.



Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/console:5941-6104
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/gamestate:6430-6440
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
   + /code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/console:5941-6104
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/gamestate:6430-6440
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/ppspickups1:6552-6708
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890

Copied: code/trunk/data/levels/includes/pickups_speed.oxi (from rev 6708, code/branches/ppspickups1/data/levels/includes/pickups_speed.oxi)
===================================================================
--- code/trunk/data/levels/includes/pickups_speed.oxi	                        (rev 0)
+++ code/trunk/data/levels/includes/pickups_speed.oxi	2010-04-13 07:32:08 UTC (rev 6709)
@@ -0,0 +1,42 @@
+<PickupRepresentation
+    name = "Small Speed Boost"
+    description = "Multiplies Speed of the Ship with a small
+amount."
+    spawnerTemplate = "smallspeedpickupRepresentation"
+>
+    <pickup>
+        <SpeedPickup template=smallspeedpickup />
+    </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+    name = "Medium Speed Boost"
+    description = "Multiplies Speed of the Ship with a bigger
+amount."
+    spawnerTemplate = "mediumspeedpickupRepresentation"
+>
+    <pickup>
+        <SpeedPickup template=mediumspeedpickup />
+    </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+    name = "Huge Speed Boost"
+    description = "Multiplies Speed of the Ship with a huge
+amount."
+    spawnerTemplate = "hugespeedpickupRepresentation"
+>
+    <pickup>
+        <SpeedPickup template=hugespeedpickup />
+    </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+    name = "Small Jump Boost"
+    description = "Boosts the Ship with a massive amount for a very short time."
+    spawnerTemplate = "smalljumppickupRepresentation"
+>
+    <pickup>
+        <SpeedPickup template=smalljumppickup />
+    </pickup>
+</PickupRepresentation>
\ No newline at end of file

Copied: code/trunk/data/levels/pickup_ppstest1.oxw (from rev 6708, code/branches/ppspickups1/data/levels/pickup_ppstest1.oxw)
===================================================================
--- code/trunk/data/levels/pickup_ppstest1.oxw	                        (rev 0)
+++ code/trunk/data/levels/pickup_ppstest1.oxw	2010-04-13 07:32:08 UTC (rev 6709)
@@ -0,0 +1,98 @@
+<?lua
+  include("stats.oxo")
+  include("hudtemplates3.oxo")
+?>
+
+<?lua
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_pirate.oxt")
+  include("templates/pickup_representation_templates_speed.oxt")
+?>
+
+<Level
+ name         = "Sample"
+ description  = "Just a few tests"
+>
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/Starbox"
+  >
+
+<?lua
+  include("includes/pickups_speed.oxi")
+?>
+
+    <PickupSpawner position="-25,0,-100" triggerDistance="10" respawnTime="10" maxSpawnedItems="99">
+        <pickup>
+            <SpeedPickup template=smallspeedpickup />
+        </pickup>
+    </PickupSpawner>
+
+    <PickupSpawner position="0,0,-100" triggerDistance="10" respawnTime="10" maxSpawnedItems="99">
+        <pickup>
+            <SpeedPickup template=mediumspeedpickup />
+        </pickup>
+    </PickupSpawner>
+
+    <PickupSpawner position="25,0,-100" triggerDistance="10" respawnTime="10" maxSpawnedItems="99">
+        <pickup>
+            <SpeedPickup template=hugespeedpickup />
+        </pickup>
+    </PickupSpawner>
+
+    <PickupSpawner position="50,0,-100" triggerDistance="10" respawnTime="10" maxSpawnedItems="99">
+        <pickup>
+            <SpeedPickup template=smalljumppickup />
+        </pickup>
+    </PickupSpawner>
+
+
+    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+    <SpawnPoint position="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+
+
+    <MovableEntity scale=1.5 position="0,0,-300" velocity="0,0,0" rotationaxis="0,1,0" rotationrate=90>
+      <events>
+        <activity>
+          <DistanceTrigger position="0,0,-300" distance=50 target="ControllableEntity" invert=1 />
+        </activity>
+      </events>
+      <attached>
+        <Model position="0,0,0" scale=10 mesh="ast1.mesh" />
+        <StaticEntity position="0,0,100">
+          <attached>
+            <Model position="0,0,0" scale=6 mesh="ast1.mesh" />
+            <MovableEntity position="0,0,0" velocity="0,0,0" rotationaxis="0,0,1" rotationrate=500>
+              <attached>
+                <Model position="0,35,0" scale=2 mesh="ast1.mesh" />
+                <Model position="0,-35,0" scale=2 mesh="ast1.mesh" />
+                <Model position="35,0,0" scale=2 mesh="ast1.mesh">
+                  <attached>
+                    <ParticleEmitter position="0,0,0" source="Orxonox/ExplosionComp4" />
+                  </attached>
+                </Model>
+                <Model position="-35,0,0" scale=2 mesh="ast1.mesh">
+                  <attached>
+                    <ParticleEmitter position="0,0,0" source="Orxonox/fire3" />
+                  </attached>
+                </Model>
+              </attached>
+            </MovableEntity>
+          </attached>
+        </StaticEntity>
+        <MovableEntity position="0,0,-100" velocity="0,0,0" rotationaxis="0,1,0" rotationrate=200>
+          <attached>
+            <ParticleEmitter position="0,0,0" source="Orxonox/fire3" />
+            <Model position="0,0,0" scale=6 mesh="ast1.mesh" />
+            <Model position="0,0,-50" scale=3 mesh="ast1.mesh" />
+            <Model position="0,0,50" scale=3 mesh="ast1.mesh" />
+          </attached>
+        </MovableEntity>
+      </attached>
+    </MovableEntity>
+
+    <ExplosionChunk position="-500,0,-200" lifetime=3.0 loop=1/>
+
+  </Scene>
+</Level>

Copied: code/trunk/data/levels/templates/pickup_representation_templates_speed.oxt (from rev 6708, code/branches/ppspickups1/data/levels/templates/pickup_representation_templates_speed.oxt)
===================================================================
--- code/trunk/data/levels/templates/pickup_representation_templates_speed.oxt	                        (rev 0)
+++ code/trunk/data/levels/templates/pickup_representation_templates_speed.oxt	2010-04-13 07:32:08 UTC (rev 6709)
@@ -0,0 +1,103 @@
+<Template name=smallspeedpickupRepresentation>
+    <PickupRepresentation>
+        <spawner-representation>
+            <StaticEntity>
+                <attached>
+                    <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+                        <attached>
+                            <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.3 />
+                        </attached>
+                    </Billboard>
+                </attached>
+            </StaticEntity>
+        </spawner-representation>
+    </PickupRepresentation>
+</Template>
+
+<Template name=smallspeedpickup>
+  <SpeedPickup
+    duration = 10.0
+    speedAdd = 0.0
+    SpeedMultiply = 10.0
+    activationType = "immediate"
+    durationType = "once"
+  />
+</Template>
+
+<Template name=mediumspeedpickupRepresentation>
+    <PickupRepresentation>
+        <spawner-representation>
+            <StaticEntity>
+                <attached>
+                    <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+                        <attached>
+                            <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.5 />
+                        </attached>
+                    </Billboard>
+                </attached>
+            </StaticEntity>
+        </spawner-representation>
+    </PickupRepresentation>
+</Template>
+
+<Template name=mediumspeedpickup>
+  <SpeedPickup
+    duration = 10.0
+    speedAdd = 0.0
+    SpeedMultiply = 25.0
+    activationType = "immediate"
+    durationType = "once"
+  />
+</Template>
+
+<Template name=hugespeedpickupRepresentation>
+    <PickupRepresentation>
+        <spawner-representation>
+            <StaticEntity>
+                <attached>
+                    <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+                        <attached>
+                            <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.7 />
+                        </attached>
+                    </Billboard>
+                </attached>
+            </StaticEntity>
+        </spawner-representation>
+    </PickupRepresentation>
+</Template>
+
+<Template name=hugespeedpickup>
+  <SpeedPickup
+    duration = 10.0
+    speedAdd = 0.0
+    SpeedMultiply = 50.0
+    activationType = "immediate"
+    durationType = "once"
+  />
+</Template>
+
+<Template name=smalljumppickupRepresentation>
+    <PickupRepresentation>
+        <spawner-representation>
+            <StaticEntity>
+                <attached>
+                    <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+                        <attached>
+                            <Billboard position="0,0,0" colour="1,0,0" material="3arrowsup" scale=0.3 />
+                        </attached>
+                    </Billboard>
+                </attached>
+            </StaticEntity>
+        </spawner-representation>
+    </PickupRepresentation>
+</Template>
+
+<Template name=smalljumppickup>
+  <SpeedPickup
+    duration = 0.7
+    speedAdd = 5000.0
+    SpeedMultiply = 1.0
+    activationType = "immediate"
+    durationType = "once"
+  />
+</Template>
\ No newline at end of file

Modified: code/trunk/src/modules/pickup/Pickup.cc
===================================================================
--- code/trunk/src/modules/pickup/Pickup.cc	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/modules/pickup/Pickup.cc	2010-04-13 07:32:08 UTC (rev 6709)
@@ -38,26 +38,28 @@
 #include "pickup/PickupIdentifier.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.
@@ -230,5 +232,30 @@
         new DroppedPickup(this, this, this->getCarrier());
         return true;
     }
-    
+
+    /**
+    @brief
+        Starts the pickup duration timer.
+        After the specified durationTime has expired the function pickupTimerCallback is called.
+        pickupTimerCallback can be overloaded and thus the desired functionality can be implemented.
+    @param durationTime
+        The duration after which the expires and the callback function is called.
+    @return
+        Returns true if the pickup duration timer was started successfully, false if not.
+    */
+    bool Pickup::startPickupTimer(float durationTime)
+    {
+        if (durationTime<=0)
+        {
+            COUT(1) << "Invalid durationTime in pickup." << std::endl;
+            return false;
+        }
+        if (this->durationTimer_.isActive()) //!< Check if Timer is 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/trunk/src/modules/pickup/Pickup.h
===================================================================
--- code/trunk/src/modules/pickup/Pickup.h	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/modules/pickup/Pickup.h	2010-04-13 07:32:08 UTC (rev 6709)
@@ -41,6 +41,8 @@
 
 #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.
             
+            //TODO: Problems, when there are more Timers needed? Solutions?
+            Timer durationTimer_; //!< Timer at the disposal of each Class implementing Pickup.
+
             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;
-        
     };
-    
+
 }
 #endif // _Pickup_H__

Modified: code/trunk/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/trunk/src/modules/pickup/PickupPrereqs.h	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/modules/pickup/PickupPrereqs.h	2010-04-13 07:32:08 UTC (rev 6709)
@@ -72,11 +72,12 @@
     class PickupManager;
     class PickupRepresentation;
     class PickupSpawner;
-    
+
     //items
     class HealthPickup;
     class MetaPickup;
-    
+    class SpeedPickup;
+
 }
 
 #endif /* _PickupPrereqs_H__ */

Modified: code/trunk/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/pickup/items/CMakeLists.txt	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/modules/pickup/items/CMakeLists.txt	2010-04-13 07:32:08 UTC (rev 6709)
@@ -1,4 +1,8 @@
 ADD_SOURCE_FILES(PICKUP_SRC_FILES
+
   HealthPickup.cc
+
+  SpeedPickup.cc
   MetaPickup.cc
+
 )


Property changes on: code/trunk/src/modules/pickup/items/HealthPickup.cc
___________________________________________________________________
Added: svn:eol-style
   + native


Property changes on: code/trunk/src/modules/pickup/items/HealthPickup.h
___________________________________________________________________
Added: svn:eol-style
   + native


Property changes on: code/trunk/src/modules/pickup/items/MetaPickup.cc
___________________________________________________________________
Added: svn:eol-style
   + native


Property changes on: code/trunk/src/modules/pickup/items/MetaPickup.h
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: code/trunk/src/modules/pickup/items/SpeedPickup.cc (from rev 6708, code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc)
===================================================================
--- code/trunk/src/modules/pickup/items/SpeedPickup.cc	                        (rev 0)
+++ code/trunk/src/modules/pickup/items/SpeedPickup.cc	2010-04-13 07:32:08 UTC (rev 6709)
@@ -0,0 +1,264 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Eric Beier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file SpeedPickup.cc
+    @brief Implementation of the SpeedPickup class.
+*/
+
+#include "SpeedPickup.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/StringUtils.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+#include "items/Engine.h"
+#include "pickup/PickupIdentifier.h"
+
+#include <sstream>
+
+
+namespace orxonox
+{
+    CreateFactory(SpeedPickup);
+
+    /**
+    @brief
+        Constructor. Registers the object and initializes the member variables.
+    */
+    SpeedPickup::SpeedPickup(BaseObject* creator) : Pickup(creator)
+    {
+        RegisterObject(SpeedPickup);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    SpeedPickup::~SpeedPickup()
+    {
+
+    }
+
+    /**
+    @brief
+        Initializes the member variables.
+    */
+    void SpeedPickup::initialize(void)
+    {
+        this->duration_ = 0.0f;
+        this->speedAdd_ = 0.0f;
+        this->speedMultiply_ = 1.0f;
+
+        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
+    }
+
+    /**
+    @brief
+        Initializes the PickupIdentifier of this pickup.
+    */
+    void SpeedPickup::initializeIdentifier(void)
+    {
+        std::stringstream stream;
+        stream << this->getDuration();
+        std::string type1 = "duration";
+        std::string val1 = stream.str();
+        this->pickupIdentifier_->addParameter(type1, val1);
+
+        stream.clear();
+        stream << this->getSpeedAdd();
+        std::string type2 = "speedAdd";
+        std::string val2 = stream.str();
+        this->pickupIdentifier_->addParameter(type2, val2);
+
+        stream.clear();
+        stream << this->getSpeedMultiply();
+        std::string type3 = "speedMultiply";
+        std::string val3 = stream.str();
+        this->pickupIdentifier_->addParameter(type3, val3);
+    }
+
+    /**
+    @brief
+        Method for creating a SpeedPickup object through XML.
+    */
+    void SpeedPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+    {
+        SUPER(SpeedPickup, XMLPort, xmlelement, mode);
+
+        XMLPortParam(SpeedPickup, "duration", setDuration, getDuration, xmlelement, mode);
+        XMLPortParam(SpeedPickup, "speedAdd", setSpeedAdd, getSpeedAdd, xmlelement, mode);
+        XMLPortParam(SpeedPickup, "speedMultiply", setSpeedMultiply, getSpeedMultiply, xmlelement, mode);
+
+        this->initializeIdentifier();
+    }
+
+    /**
+    @brief
+        Is called when the pickup has transited from used to unused or the other way around.
+    */
+    void SpeedPickup::changedUsed(void)
+    {
+        SUPER(SpeedPickup, changedUsed);
+
+        //! If the pickup is not picked up nothing must be done.
+        if(!this->isPickedUp())
+            return;
+
+        Engine* engine = this->carrierToEngineHelper();
+        if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
+            this->destroy();
+        
+        //! If the pickup has transited to used.
+        if(this->isUsed())
+        {
+            this->startPickupTimer(this->getDuration());
+            engine->setSpeedAdd(this->getSpeedAdd());
+            engine->setSpeedMultiply(this->getSpeedMultiply());
+        }
+        else
+        {
+            engine->setSpeedAdd(0.0f);
+            engine->setSpeedMultiply(1.0f);
+            
+            if(this->isOnce())
+            {
+                this->destroy();
+            }
+        }
+    }
+
+    /**
+    @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.
+    */
+    Engine* SpeedPickup::carrierToEngineHelper(void)
+    {
+        PickupCarrier* carrier = this->getCarrier();
+        SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier);
+
+        if(ship == NULL)
+        {
+            COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl;
+        }
+        else
+        {
+            return ship->getEngine();
+        }
+
+        return 0;
+    }
+
+    /**
+    @brief
+        Creates a duplicate of the input OrxonoxClass.
+    @param item
+        A pointer to the Orxonox class.
+    */
+    void SpeedPickup::clone(OrxonoxClass*& item)
+    {
+        if(item == NULL)
+            item = new SpeedPickup(this);
+
+        SUPER(SpeedPickup, clone, item);
+
+        SpeedPickup* pickup = dynamic_cast<SpeedPickup*>(item);
+        pickup->setDuration(this->getDuration());
+        pickup->setSpeedAdd(this->getSpeedAdd());
+        pickup->setSpeedMultiply(this->getSpeedMultiply());
+
+        pickup->initializeIdentifier();
+    }
+
+    /**
+    @brief
+        Sets the duration.
+    @param duration
+        The duration
+    */
+    void SpeedPickup::setDuration(float duration)
+    {
+        if(duration >= 0.0f)
+        {
+            this->duration_ = duration;
+        }
+        else
+        {
+            COUT(1) << "Invalid duration in SpeedPickup." << std::endl;
+            this->duration_ = 0.0f;
+        }
+    }
+
+    /**
+    @brief
+        Sets the SpeedAdd
+    @param speedAdd
+        The added Speed
+    */
+    void SpeedPickup::setSpeedAdd(float speedAdd)
+    {
+        if(speedAdd >= 0.0f)
+        {
+            this->speedAdd_ = speedAdd;
+        }
+        else
+        {
+            COUT(1) << "Invalid speedAdd in SpeedPickup." << std::endl;
+            this->speedAdd_ = 0.0f;
+        }
+    }
+
+    /**
+    @brief
+        Sets the SpeedMultiply
+    @param speedAdd
+        The multiplied Speed
+    */
+    void SpeedPickup::setSpeedMultiply(float speedMultiply)
+    {
+        if(speedMultiply != 0)
+        {
+            this->speedMultiply_ = speedMultiply;
+        }
+        else
+        {
+            COUT(1) << "Invalid speedMultiply in SpeedPickup." << std::endl;
+            this->speedMultiply_ = 1.0f;
+        }
+    }
+
+    void SpeedPickup::pickupTimerCallback(void)
+    {       
+        this->setUsed(false);
+    }
+}

Copied: code/trunk/src/modules/pickup/items/SpeedPickup.h (from rev 6708, code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h)
===================================================================
--- code/trunk/src/modules/pickup/items/SpeedPickup.h	                        (rev 0)
+++ code/trunk/src/modules/pickup/items/SpeedPickup.h	2010-04-13 07:32:08 UTC (rev 6709)
@@ -0,0 +1,97 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Eric Beier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file SpeedPickup.h
+    @brief Declaration of the SpeedPickup class.
+*/
+
+#ifndef _SpeedPickup_H__
+#define _SpeedPickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+#include "worldentities/pawns/Pawn.h"
+#include "worldentities/StaticEntity.h"
+
+#include "pickup/Pickup.h"
+
+namespace orxonox {
+
+    /**
+    @brief
+        A Pickup which can manipulate the Speed of a Pawn.
+
+        1) The speed multiplier:
+           The additional (forward) speed:
+        2) The activation type: 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
+        4) The duration: the activation time of the pickup.
+
+    @author
+        Eric Beier
+    */
+    class _PickupExport SpeedPickup : public Pickup
+    {
+        public:
+
+            SpeedPickup(BaseObject* creator); //!< Constructor.
+            virtual ~SpeedPickup(); //!< Destructor.
+
+            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
+
+            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.
+
+            inline float getDuration(void)
+                { return this->duration_; }
+            inline float getSpeedAdd(void)
+                { return this->speedAdd_; }
+            inline float getSpeedMultiply(void)
+                { return this->speedMultiply_; }
+
+        protected:
+            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+            
+            virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
+
+            void setDuration(float duration);
+            void setSpeedAdd(float speedAdd);
+            void setSpeedMultiply(float speedMultiply);
+
+        private:
+            void initialize(void); //!< Initializes the member variables.
+            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_;
+            float speedMultiply_;
+    };
+}
+
+#endif // _SpeedPickup_H__

Modified: code/trunk/src/orxonox/interfaces/PickupCarrier.h
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupCarrier.h	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/orxonox/interfaces/PickupCarrier.h	2010-04-13 07:32:08 UTC (rev 6709)
@@ -45,13 +45,13 @@
 #include "core/OrxonoxClass.h"
 
 namespace orxonox
-{
+{
+    class Pickupable;
+    class Pickup;
+    class HealthPickup;
+    class MetaPickup;
+    class SpeedPickup;
 
-    //! Pre-declarations.
-    class Pickup;
-    class HealthPickup;
-    class MetaPickup;
-
     /**
     @brief
         The PickupCarrier interface provides the means, for any class implementing it, to possess Pickupables.
@@ -65,12 +65,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.
@@ -86,7 +87,7 @@
                     }
                     return pickedUp;
                 }
-                
+
             /**
             @brief Can be called to drop a Pickupable.
             @param pickup A pointer to the Pickupable.
@@ -94,7 +95,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)
                     {
@@ -103,7 +104,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.
@@ -113,7 +114,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++)
@@ -121,13 +122,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.
@@ -137,10 +138,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++)
@@ -148,26 +149,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;
             /**
@@ -176,17 +177,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/trunk/src/orxonox/items/Engine.cc
===================================================================
--- code/trunk/src/orxonox/items/Engine.cc	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/orxonox/items/Engine.cc	2010-04-13 07:32:08 UTC (rev 6709)
@@ -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/trunk/src/orxonox/items/Engine.h
===================================================================
--- code/trunk/src/orxonox/items/Engine.h	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/orxonox/items/Engine.h	2010-04-13 07:32:08 UTC (rev 6709)
@@ -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);
+
+            //TODO: Move to protected or private. How?
+            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/trunk/src/orxonox/items/MultiStateEngine.cc
===================================================================
--- code/trunk/src/orxonox/items/MultiStateEngine.cc	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/orxonox/items/MultiStateEngine.cc	2010-04-13 07:32:08 UTC (rev 6709)
@@ -128,6 +128,9 @@
                     this->state_ = Brake;
                 else
                     this->state_ = Idle;
+
+                if (this->state_ == Idle && this->getSpeedAdd() > 0)
+                    this->state_ = Normal;
             }
 
             if (GameMode::isMaster())

Modified: code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc	2010-04-13 07:32:08 UTC (rev 6709)
@@ -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(this->engine_);
+        return list;
+    }
 }

Modified: code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h	2010-04-13 07:07:08 UTC (rev 6708)
+++ code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h	2010-04-13 07:32:08 UTC (rev 6709)
@@ -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