[Orxonox-commit 177] r2852 - in branches/weaponsystem/src/orxonox: . objects/weaponSystem objects/weaponSystem/munitions

polakma at orxonox.net polakma at orxonox.net
Thu Mar 26 14:56:39 CET 2009


Author: polakma
Date: 2009-03-26 13:56:39 +0000 (Thu, 26 Mar 2009)
New Revision: 2852

Modified:
   branches/weaponsystem/src/orxonox/OrxonoxPrereqs.h
   branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.cc
   branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.h
   branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.cc
   branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.h
   branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
   branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
Log:
added unlimited munition, reverted shared munition and fixed some bugs

Modified: branches/weaponsystem/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/weaponsystem/src/orxonox/OrxonoxPrereqs.h	2009-03-26 10:59:39 UTC (rev 2851)
+++ branches/weaponsystem/src/orxonox/OrxonoxPrereqs.h	2009-03-26 13:56:39 UTC (rev 2852)
@@ -174,6 +174,7 @@
     class Munition;
     class LaserGun;
     class LaserGunMunition;
+    class FusionMunition;
 
     class EventListener;
     class EventDispatcher;

Modified: branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.cc
===================================================================
--- branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.cc	2009-03-26 10:59:39 UTC (rev 2851)
+++ branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.cc	2009-03-26 13:56:39 UTC (rev 2852)
@@ -67,7 +67,6 @@
         XMLPortParam(Weapon, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);
         XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
         XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
-        XMLPortParam(Weapon, "bSharedMunition", setSharedMunition, getSharedMunition, xmlelement, mode);
         XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);
         XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);
         XMLPortParam(Weapon, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);
@@ -87,25 +86,20 @@
 
     void Weapon::fire()
     {
-COUT(0) << "Weapon::fire" << std::endl;
         if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
         {
-COUT(0) << "Weapon::fire 2" << std::endl;
             this->bulletReadyToShoot_ = false;
             if ( this->unlimitedMunition_== true )
             {
-COUT(0) << "Weapon::fire 3" << std::endl;
                 //shoot
                 this->reloadBullet();
                 this->createProjectile();
             }
             else
             {
-COUT(0) << "Weapon::fire 4" << std::endl;
                 if ( this->munition_->bullets() > 0)
                 {
-COUT(0) << "Weapon::fire 5" << std::endl;
-                    //shoot
+                    //shoot and reload
                     this->takeBullets();
                     this->reloadBullet();
                     this->createProjectile();
@@ -113,7 +107,7 @@
                 //if there are no bullets, but magazines
                 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
                 {
-COUT(0) << "Weapon::fire 6" << std::endl;
+                    //reload magazine
                     this->takeMagazines();
                     this->reloadMagazine();
                 }
@@ -125,15 +119,13 @@
         }
         else
         {
-COUT(0) << "Weapon::fire not reloaded" << std::endl;
             //weapon not reloaded
         }
 
     }
 
-    /*
-    * weapon reloading
-    */
+
+    //weapon reloading
     void Weapon::bulletTimer(float bulletLoadingTime)
     {
         this->bReloading_ = true;
@@ -155,39 +147,31 @@
     {
         this->bReloading_ = false;
         this->munition_->fillBullets();
-        this->magazineReadyToShoot_ = true;
-        this->bulletReadyToShoot_ = true;
     }
 
 
+
     void Weapon::attachNeededMunition(std::string munitionName)
     {
         /*  if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
-        *   if the weapon shares one munitionType put it into sharedMunitionSet else to munitionSet
         */
         if (this->parentWeaponSystem_)
         {
-            if (this->bSharedMunition_ == false)
+            //getMunitionType returns 0 if there is no such munitionType
+            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
+            if ( munition )
             {
+                this->munition_ = munition;
+                this->setMunition();
+            }
+            else
+            {
+                //create new munition with identifier because there is no such munitionType
                 this->munitionIdentifier_ = ClassByString(munitionName);
                 this->munition_ = this->munitionIdentifier_.fabricate(this);
                 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
+                this->setMunition();
             }
-            else
-            {
-                //getMunitionType returns 0 if there is no such munitionType
-                Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
-                if ( munition )
-                    this->munition_ = munition;
-                else
-                {
-                    //create new munition with identifier because there is no such munitionType
-                    this->munitionIdentifier_ = ClassByString(munitionName);
-                    this->munition_ = this->munitionIdentifier_.fabricate(this);
-                    this->parentWeaponSystem_->setNewSharedMunition(munitionName, this->munition_);
-                }
-            }
-            this->setMunition();
         }
     }
 
@@ -207,9 +191,7 @@
     void Weapon::reloadMagazine() { };
 
 
-     /*get and set functions
-     *
-     */
+    //get and set functions for XMLPort
     void Weapon::setMunitionType(std::string munitionType)
     {   this->munitionType_ = munitionType; }
 
@@ -228,12 +210,6 @@
     const float Weapon::getMagazineLoadingTime()
     {   return this->magazineLoadingTime_;  }
 
-    void Weapon::setSharedMunition(bool bSharedMunition)
-    {   this->bSharedMunition_ = bSharedMunition; }
-
-    const bool Weapon::getSharedMunition()
-    {   return this->bSharedMunition_;  }
-
     void Weapon::setBulletAmount(unsigned int amount)
     {   this->bulletAmount_ = amount; }
 
@@ -244,7 +220,7 @@
     {   this->magazineAmount_ = amount; }
 
     const unsigned int Weapon::getMagazineAmount()
-    {   return this->magazineAmount_;  }
+    {   return this->magazineAmount_;   }
 
     void Weapon::setUnlimitedMunition(bool unlimitedMunition)
     {   this->unlimitedMunition_ = unlimitedMunition;   }

Modified: branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.h
===================================================================
--- branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.h	2009-03-26 10:59:39 UTC (rev 2851)
+++ branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.h	2009-03-26 13:56:39 UTC (rev 2852)
@@ -68,8 +68,6 @@
             virtual const float getBulletLoadingTime();
             virtual void setMagazineLoadingTime(float loadingTime);
             virtual const float getMagazineLoadingTime();
-            virtual void setSharedMunition(bool bSharedMunition);
-            virtual const bool getSharedMunition();
             virtual void setBulletAmount(unsigned int amount);
             virtual const unsigned int getBulletAmount();
             virtual void setMagazineAmount(unsigned int amount);
@@ -105,7 +103,6 @@
             bool bReloading_;
             bool bulletReadyToShoot_;
             bool magazineReadyToShoot_;
-            bool bSharedMunition_;
             bool unlimitedMunition_;
             float bulletLoadingTime_;
             float magazineLoadingTime_;

Modified: branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.cc
===================================================================
--- branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.cc	2009-03-26 10:59:39 UTC (rev 2851)
+++ branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.cc	2009-03-26 13:56:39 UTC (rev 2852)
@@ -81,25 +81,18 @@
         this->munitionSet_[munitionType] = munitionToAdd;
     }
 
-    void WeaponSystem::setNewSharedMunition(std::string munitionType, Munition * munitionToAdd)
-    {
-        this->munitionSharedSet_[munitionType] = munitionToAdd;
-    }
 
     //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition
     Munition * WeaponSystem::getMunitionType(std::string munitionType)
     {
-        std::map<std::string, Munition *>::const_iterator it = this->munitionSharedSet_.find(munitionType);
-        if (it != this->munitionSharedSet_.end())
+        std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
+        if (it != this->munitionSet_.end())
             return it->second;
         else
             return 0;
     }
 
 
-
-
-
     //n is the n'th weaponSet, starting with zero
     //SpaceShip.cc only needs to have the keybinding to a specific Set-number n (=firemode)
     //in future this could be well defined and not only for 3 different WeaponModes

Modified: branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.h
===================================================================
--- branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.h	2009-03-26 10:59:39 UTC (rev 2851)
+++ branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.h	2009-03-26 13:56:39 UTC (rev 2852)
@@ -72,7 +72,6 @@
             std::vector<WeaponSet *> weaponSets_;
             std::vector<WeaponSlot *> weaponSlots_;
             std::vector<WeaponPack *> weaponPacks_;
-            std::map<std::string, Munition *> munitionSharedSet_;
             std::map<std::string, Munition *> munitionSet_;
             Pawn *parentPawn_;
     };

Modified: branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
===================================================================
--- branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	2009-03-26 10:59:39 UTC (rev 2851)
+++ branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	2009-03-26 13:56:39 UTC (rev 2852)
@@ -1,3 +1,4 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   LaserGunMunition.cc
+  FusionMunition.cc
 )

Modified: branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
===================================================================
--- branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	2009-03-26 10:59:39 UTC (rev 2851)
+++ branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	2009-03-26 13:56:39 UTC (rev 2852)
@@ -42,6 +42,7 @@
     {
         RegisterObject(LaserGunMunition);
 
+        //default if not defined in XML
         this->maxBullets_ = 40;
         this->maxMagazines_ = 100;
     }




More information about the Orxonox-commit mailing list