Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5861


Ignore:
Timestamp:
Oct 2, 2009, 8:58:27 PM (15 years ago)
Author:
landauf
Message:

un-PawnListener-ized ArtificialController

Location:
code/branches/core5/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/WeakPtr.h

    r5825 r5861  
    168168            }
    169169           
    170             inline void addCallback(Functor* callback)
     170            inline void setCallback(Functor* callback)
    171171            {
    172172                this->callback_ = callback;
  • code/branches/core5/src/orxonox/controllers/ArtificialController.cc

    r5738 r5861  
    4646        this->bHasTargetPosition_ = false;
    4747        this->targetPosition_ = Vector3::ZERO;
     48       
     49        this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this));
    4850    }
    4951
     
    162164    }
    163165
    164     void ArtificialController::destroyedPawn(Pawn* ship)
    165     {
    166         if (ship == this->target_)
    167         {
    168             this->forgetTarget();
    169             this->searchRandomTargetPosition();
    170         }
     166    void ArtificialController::abandonTarget(Pawn* target)
     167    {
     168        if (target == this->target_)
     169            this->targetDied();
     170    }
     171
     172    void ArtificialController::targetDied()
     173    {
     174        this->forgetTarget();
     175        this->searchRandomTargetPosition();
    171176    }
    172177
  • code/branches/core5/src/orxonox/controllers/ArtificialController.h

    r5738 r5861  
    3333
    3434#include "util/Math.h"
    35 #include "interfaces/PawnListener.h"
    3635#include "Controller.h"
    3736
    3837namespace orxonox
    3938{
    40     class _OrxonoxExport ArtificialController : public Controller, public PawnListener
     39    class _OrxonoxExport ArtificialController : public Controller
    4140    {
    4241        public:
    4342            ArtificialController(BaseObject* creator);
    4443            virtual ~ArtificialController();
    45 
    46             virtual void destroyedPawn(Pawn* pawn);
     44           
     45            void abandonTarget(Pawn* target);
    4746
    4847        protected:
     48            void targetDied();
     49
    4950            void moveToPosition(const Vector3& target);
    5051            void moveToTargetPosition();
     
    6566            bool bHasTargetPosition_;
    6667            Vector3 targetPosition_;
    67             Pawn* target_;
     68            WeakPtr<Pawn> target_;
    6869            bool bShooting_;
    6970
  • code/branches/core5/src/orxonox/gametypes/UnderAttack.cc

    r5829 r5861  
    4646        this->teams_ = 2;
    4747        this->destroyer_ = 0;
    48         this->destroyer_.addCallback(createFunctor(&UnderAttack::killedDestroyer, this));
     48        this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this));
    4949        this->gameEnded_ = false;
    5050
  • code/branches/core5/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc

    r5806 r5861  
    3131
    3232#include "core/CoreIncludes.h"
    33 #include "interfaces/PawnListener.h"
     33#include "controllers/ArtificialController.h"
    3434#include "interfaces/TeamColourable.h"
    3535#include "gametypes/TeamBaseMatch.h"
     
    9292
    9393        // Call this so bots stop shooting at the base after they converted it
    94         for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
    95             it->destroyedPawn(this);
     94        for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)
     95            it->abandonTarget(this);
    9696    }
    9797}
Note: See TracChangeset for help on using the changeset viewer.