[Orxonox-commit 5064] r9728 - code/trunk/src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Tue Oct 29 20:56:38 CET 2013
Author: jo
Date: 2013-10-29 20:56:38 +0100 (Tue, 29 Oct 2013)
New Revision: 9728
Modified:
code/trunk/src/orxonox/gametypes/Mission.cc
code/trunk/src/orxonox/gametypes/Mission.h
Log:
Making a Mission endable by a ConsoleCommand such that it can be ended from within a level.
Modified: code/trunk/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Mission.cc 2013-10-29 13:45:27 UTC (rev 9727)
+++ code/trunk/src/orxonox/gametypes/Mission.cc 2013-10-29 19:56:38 UTC (rev 9728)
@@ -31,11 +31,13 @@
#include "controllers/ArtificialController.h"
#include "core/CoreIncludes.h"
+#include "core/command/ConsoleCommand.h"
#include "network/Host.h"
#include "worldentities/pawns/Pawn.h"
namespace orxonox
{
+ SetConsoleCommand("Mission", "endMission", &Mission::endMission);
RegisterUnloadableClass(Mission);
Mission::Mission(Context* context) : TeamGametype(context)
@@ -77,11 +79,10 @@
void Mission::end()
{
Gametype::end();
- /*if (this->missionAccomplished_)
+ if (this->missionAccomplished_)
this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
else
this->gtinfo_->sendAnnounceMessage("Mission failed!");
- */
}
void Mission::setTeams()
@@ -93,7 +94,14 @@
this->setDefaultObjectColour(pawn);
}
}
+ void Mission::endMission(bool accomplished)
+ {
+ for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
+ {//TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions!
+ it->setMissionAccomplished(accomplished);
+ it->end();
+ }
+ }
-
}
Modified: code/trunk/src/orxonox/gametypes/Mission.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Mission.h 2013-10-29 13:45:27 UTC (rev 9727)
+++ code/trunk/src/orxonox/gametypes/Mission.h 2013-10-29 19:56:38 UTC (rev 9728)
@@ -51,11 +51,16 @@
{this->lives_ = amount;}
inline unsigned int getLives()
{return this->lives_;}
+ inline void setMissionAccomplished(bool acc)
+ {this->missionAccomplished_ = acc;}
+ static void endMission(bool accomplished);
protected:
virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
bool missionAccomplished_; //<! indicates if player successfully finsihed the mission;
int lives_; //<! amount of player's lives <-> nr. of retries
+ //Make end() a callback function to the event "END"
+ //or create a console command.
};
}
More information about the Orxonox-commit
mailing list