Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

un-PawnListener-ized ArtificialController

Location:
code/branches/core5/src/orxonox/controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.