Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2013, 4:06:38 PM (11 years ago)
Author:
thiweber
Message:

A few changes..

Location:
code/branches/sfxThilo/src/orxonox/worldentities/pawns
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sfxThilo/src/orxonox/worldentities/pawns/Pawn.cc

    r9667 r9889  
    4646#include "weaponsystem/WeaponPack.h"
    4747#include "weaponsystem/WeaponSet.h"
     48#include "sound/WorldSound.h"
    4849
    4950#include "controllers/FormationController.h"
     
    100101
    101102        this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition
     103
     104        if (GameMode::isMaster())
     105        {
     106            this->explosionSound_ = new WorldSound(this->getContext());
     107            this->explosionSound_->setVolume(1.0f);
     108        }
     109        else
     110        {
     111            this->explosionSound_ = 0;
     112        }
    102113    }
    103114
     
    109120                this->weaponSystem_->destroy();
    110121        }
     122
    111123    }
    112124
     
    135147        XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
    136148
     149        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
     150
    137151        XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
    138152    }
     153
    139154
    140155    void Pawn::registerVariables()
     
    290305    void Pawn::kill()
    291306    {
    292         this->damage(this->health_);
     307        this->damage(this->health_);
    293308        this->death();
    294309    }
     
    314329        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
    315330        {
    316             // Set bAlive_ to false and wait for PawnManager to do the destruction
     331            explosionSound_->play();
     332                // Set bAlive_ to false and wait for PawnManager to do the destruction
    317333            this->bAlive_ = false;
    318334
     
    527543
    528544
     545    void Pawn::setExplosionSound(const std::string &explosionSound)
     546    {
     547        if(explosionSound_ )
     548            explosionSound_->setSource(explosionSound);
     549        else
     550            assert(0); // This should never happen, because soundpointer is only available on master
     551    }
     552
     553    const std::string& Pawn::getExplosionSound()
     554    {
     555        if( explosionSound_ )
     556            return explosionSound_->getSource();
     557        else
     558            assert(0);
     559        return BLANKSTRING;
     560    }
     561
    529562
    530563}
  • code/branches/sfxThilo/src/orxonox/worldentities/pawns/Pawn.h

    r9667 r9889  
    3636#include "interfaces/RadarViewable.h"
    3737#include "worldentities/ControllableEntity.h"
     38
    3839
    3940namespace orxonox // tolua_export
     
    178179            virtual void changedVisibility();
    179180
     181            void setExplosionSound(const std::string& engineSound);
     182            const std::string& getExplosionSound();
     183
    180184        protected:
    181185            virtual void preDestroy();
     
    231235
    232236            Vector3 aimPosition_;
     237
     238            WorldSound* explosionSound_;
     239
    233240    }; // tolua_export
    234241} // tolua_export
Note: See TracChangeset for help on using the changeset viewer.