[Orxonox-commit 398] r2986 - in branches/gametypes/src/orxonox/objects: gametypes quest worldentities worldentities/triggers

Aurelian at orxonox.net Aurelian at orxonox.net
Mon May 18 18:00:13 CEST 2009


Author: Aurelian
Date: 2009-05-18 18:00:13 +0200 (Mon, 18 May 2009)
New Revision: 2986

Modified:
   branches/gametypes/src/orxonox/objects/gametypes/Asteroids.cc
   branches/gametypes/src/orxonox/objects/gametypes/Asteroids.h
   branches/gametypes/src/orxonox/objects/quest/QuestEffectBeacon.cc
   branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.cc
   branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.h
   branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
   branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.h
   branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
   branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
   branches/gametypes/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
Log:
Respawning changed, not possible anymore, not completely working. Movable Entity is now able to cause damage.

Modified: branches/gametypes/src/orxonox/objects/gametypes/Asteroids.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/Asteroids.cc	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/gametypes/Asteroids.cc	2009-05-18 16:00:13 UTC (rev 2986)
@@ -43,6 +43,7 @@
     {
         RegisterObject(Asteroids);
         this->firstCheckpointReached_ = false;
+        this->firstTimeSpawned_ = false;
     }
 
     void Asteroids::tick(float dt)
@@ -58,10 +59,20 @@
         {
             this->end();
         }
-        
     }
 
+    void Asteroids::spawnPlayer(PlayerInfo* player)
+    {
+        if (this->timerIsActive_ && this->firstTimeSpawned_)
+        {
+            this->end();
+            return;
+        }
 
+        this->firstTimeSpawned_ = true;
+        Gametype::spawnPlayer(player);
+    }
+
     void Asteroids::start()
     {
         Gametype::start();

Modified: branches/gametypes/src/orxonox/objects/gametypes/Asteroids.h
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/Asteroids.h	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/gametypes/Asteroids.h	2009-05-18 16:00:13 UTC (rev 2986)
@@ -49,9 +49,13 @@
             inline void firstCheckpointReached(bool reached)
               { this->firstCheckpointReached_ = reached; }
 
+        protected:
+            virtual void spawnPlayer(PlayerInfo* player);
+
         private:
             bool firstCheckpointReached_;
             bool gameEnded_;
+            bool firstTimeSpawned_;
 
     };
 }

Modified: branches/gametypes/src/orxonox/objects/quest/QuestEffectBeacon.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/quest/QuestEffectBeacon.cc	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/quest/QuestEffectBeacon.cc	2009-05-18 16:00:13 UTC (rev 2986)
@@ -40,7 +40,7 @@
 #include "core/EventIncludes.h"
 
 #include "orxonox/objects/infos/PlayerInfo.h"
-#include "orxonox/objects/worldentities/ControllableEntity.h"
+#include "orxonox/objects/worldentities/pawns/Pawn.h"
 #include "orxonox/objects/worldentities/triggers/PlayerTrigger.h"
 #include "QuestEffect.h"
 
@@ -119,16 +119,16 @@
         }
 
         //! Extracting the ControllableEntity form the PlayerTrigger.
-        ControllableEntity* entity = trigger->getTriggeringPlayer();
+        Pawn* pawn = trigger->getTriggeringPlayer();
 
-        if(entity == NULL)
+        if(pawn == NULL)
         {
-            COUT(2) << "The QuestEffectBeacon was triggered by an entity other than a ControllableEntity." << std::endl;
+            COUT(2) << "The QuestEffectBeacon was triggered by an entity other than a Pawn." << std::endl;
             return false;
         }
         
         //! Extract the PlayerInfo from the ControllableEntity.
-        PlayerInfo* player = entity->getPlayer();
+        PlayerInfo* player = pawn->getPlayer();
         
         if(player == NULL)
         {

Modified: branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.cc	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.cc	2009-05-18 16:00:13 UTC (rev 2986)
@@ -34,6 +34,7 @@
 #include "core/XMLPort.h"
 #include "core/Executor.h"
 #include "core/Core.h"
+#include "objects/worldentities/pawns/Pawn.h"
 
 namespace orxonox
 {
@@ -66,8 +67,28 @@
     void MovableEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(MovableEntity, XMLPort, xmlelement, mode);
+
+        XMLPortParam(MovableEntity, "enablecollisiondamage", setEnableCollisionDamage, getEnableCollisionDamage, xmlelement, mode).defaultValues(false);
+        XMLPortParam(MovableEntity, "collisiondamage", setCollisionDamage, getCollisionDamage, xmlelement, mode).defaultValues(1);
     }
 
+    bool MovableEntity::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+    {
+            if (Core::isMaster() && enableCollisionDamage_)
+            {
+                Pawn* victim = dynamic_cast<Pawn*>(otherObject);
+                if (victim)
+		{
+COUT(0) << "colission";
+                    
+                    victim->damage(this->collisionDamage_ * victim->getVelocity().dotProduct(this->getVelocity()));
+}
+            }
+
+        return false;
+    }
+
+
     void MovableEntity::registerVariables()
     {
         registerVariable(this->linearVelocity_,        variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));

Modified: branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.h
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.h	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/worldentities/MovableEntity.h	2009-05-18 16:00:13 UTC (rev 2986)
@@ -45,6 +45,7 @@
             virtual ~MovableEntity();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
             void registerVariables();
 
             using WorldEntity::setPosition;
@@ -55,6 +56,26 @@
             inline void setOrientation(const Quaternion& orientation)
                 { MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); }
 
+            inline void setOwner(Pawn* owner)
+                { this->owner_ = owner; }
+            inline Pawn* getOwner() const
+                { return this->owner_; }
+
+            inline void setCollisionDamage(float c)
+                { this->collisionDamage_ = c; }
+
+            inline float getCollisionDamage()
+                { return this->collisionDamage_; }
+
+            inline void setEnableCollisionDamage(bool c)
+            { 
+                this->enableCollisionDamage_ = c; 
+                this->enableCollisionCallback();
+            } 
+
+            inline bool getEnableCollisionDamage()
+                { return this->enableCollisionDamage_; }
+
         private:
             void clientConnected(unsigned int clientID);
             void clientDisconnected(unsigned int clientID);
@@ -75,6 +96,10 @@
 
             Timer<MovableEntity> resynchronizeTimer_;
             Timer<MovableEntity>* continuousResynchroTimer_;
+
+            Pawn* owner_;
+            float collisionDamage_;
+            bool enableCollisionDamage_;
     };
 }
 

Modified: branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.cc	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.cc	2009-05-18 16:00:13 UTC (rev 2986)
@@ -36,6 +36,7 @@
 #include "core/XMLPort.h"
 
 #include "orxonox/objects/worldentities/ControllableEntity.h"
+#include "orxonox/objects/worldentities/pawns/Pawn.h"
 
 namespace orxonox
 {
@@ -50,6 +51,8 @@
     this->bIsFirst_ = false;
     this->bIsDestination_ = false;
     //this->setVisible(true);
+
+    this->notifyMaskUpdate();
   }
 
   CheckPoint::~CheckPoint()
@@ -86,4 +89,10 @@
         }
      }
   }
+
+  void CheckPoint::notifyMaskUpdate()
+  {
+      this->targetMask_.exclude(Class(BaseObject));
+      this->targetMask_.include(Class(Pawn));
+  }
 }

Modified: branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.h
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.h	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.h	2009-05-18 16:00:13 UTC (rev 2986)
@@ -56,6 +56,7 @@
 
     private:
       virtual void triggered(bool bIsTriggered); 
+      virtual void notifyMaskUpdate();
 
       inline void setDestination(bool isDestination)
         { bIsDestination_ = isDestination; }

Modified: branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc	2009-05-18 16:00:13 UTC (rev 2986)
@@ -34,7 +34,7 @@
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 
-#include "orxonox/objects/worldentities/ControllableEntity.h"
+#include "orxonox/objects/worldentities/pawns/Pawn.h"
 
 namespace orxonox
 {
@@ -108,6 +108,8 @@
     ClassTreeMask WEMask;
     WEMask.include(Class(WorldEntity));
     this->targetMask_ *= WEMask;
+
+    this->notifyMaskUpdate();
   }
 
   void DistanceTrigger::removeTargets(const std::string& targets)
@@ -132,7 +134,7 @@
         //! If the target is a player (resp. is a, or is derived from a, ControllableEntity) the triggeringPlayer is set to the target entity.
         if(this->isForPlayer())
 	{
-          ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity);
+          Pawn* player = dynamic_cast<Pawn*>(entity);
 	  this->setTriggeringPlayer(player);
 	}
         

Modified: branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h	2009-05-18 16:00:13 UTC (rev 2986)
@@ -62,9 +62,11 @@
 
     protected:
       virtual bool isTriggered(TriggerMode mode);
+      virtual void notifyMaskUpdate() {}
 
+      ClassTreeMask targetMask_;
+
     private:
-      ClassTreeMask targetMask_;
       std::set<Ogre::Node*> targetSet_;
       float distance_;
       

Modified: branches/gametypes/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h	2009-05-18 15:01:45 UTC (rev 2985)
+++ branches/gametypes/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h	2009-05-18 16:00:13 UTC (rev 2986)
@@ -59,7 +59,7 @@
         @brief Returns the player that triggered the PlayerTrigger.
         @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger.
         */
-        inline ControllableEntity* getTriggeringPlayer(void) const
+        inline Pawn* getTriggeringPlayer(void) const
             { return this->player_; }
         
         /**
@@ -76,7 +76,7 @@
         @brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger.
         @param player A pointer to the ControllableEntity that triggered the PlayerTrigger.
         */
-        inline void setTriggeringPlayer(ControllableEntity* player)
+        inline void setTriggeringPlayer(Pawn* player)
            { this->player_ = player; }
 
             /**
@@ -87,7 +87,7 @@
            { this->isForPlayer_ = isForPlayer; }
         
     private:
-        ControllableEntity* player_; //!< The player that triggered the PlayerTrigger.
+        Pawn* player_; //!< The player that triggered the PlayerTrigger.
         bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities.
     
     };




More information about the Orxonox-commit mailing list