Changeset 5861
- Timestamp:
- Oct 2, 2009, 8:58:27 PM (15 years ago)
- Location:
- code/branches/core5/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/WeakPtr.h
r5825 r5861 168 168 } 169 169 170 inline void addCallback(Functor* callback)170 inline void setCallback(Functor* callback) 171 171 { 172 172 this->callback_ = callback; -
code/branches/core5/src/orxonox/controllers/ArtificialController.cc
r5738 r5861 46 46 this->bHasTargetPosition_ = false; 47 47 this->targetPosition_ = Vector3::ZERO; 48 49 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); 48 50 } 49 51 … … 162 164 } 163 165 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(); 171 176 } 172 177 -
code/branches/core5/src/orxonox/controllers/ArtificialController.h
r5738 r5861 33 33 34 34 #include "util/Math.h" 35 #include "interfaces/PawnListener.h"36 35 #include "Controller.h" 37 36 38 37 namespace orxonox 39 38 { 40 class _OrxonoxExport ArtificialController : public Controller , public PawnListener39 class _OrxonoxExport ArtificialController : public Controller 41 40 { 42 41 public: 43 42 ArtificialController(BaseObject* creator); 44 43 virtual ~ArtificialController(); 45 46 v irtual void destroyedPawn(Pawn* pawn);44 45 void abandonTarget(Pawn* target); 47 46 48 47 protected: 48 void targetDied(); 49 49 50 void moveToPosition(const Vector3& target); 50 51 void moveToTargetPosition(); … … 65 66 bool bHasTargetPosition_; 66 67 Vector3 targetPosition_; 67 Pawn*target_;68 WeakPtr<Pawn> target_; 68 69 bool bShooting_; 69 70 -
code/branches/core5/src/orxonox/gametypes/UnderAttack.cc
r5829 r5861 46 46 this->teams_ = 2; 47 47 this->destroyer_ = 0; 48 this->destroyer_. addCallback(createFunctor(&UnderAttack::killedDestroyer, this));48 this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this)); 49 49 this->gameEnded_ = false; 50 50 -
code/branches/core5/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r5806 r5861 31 31 32 32 #include "core/CoreIncludes.h" 33 #include " interfaces/PawnListener.h"33 #include "controllers/ArtificialController.h" 34 34 #include "interfaces/TeamColourable.h" 35 35 #include "gametypes/TeamBaseMatch.h" … … 92 92 93 93 // 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); 96 96 } 97 97 }
Note: See TracChangeset
for help on using the changeset viewer.