[Orxonox-commit 126] r2818 - in branches/miniprojects/src/orxonox/objects: gametypes worldentities/pawns
landauf at orxonox.net
landauf at orxonox.net
Sun Mar 22 21:40:35 CET 2009
Author: landauf
Date: 2009-03-22 20:40:35 +0000 (Sun, 22 Mar 2009)
New Revision: 2818
Modified:
branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc
branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h
branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc
branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h
branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc
branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.h
Log:
added two new functions to Gametype
Modified: branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc 2009-03-21 21:17:59 UTC (rev 2817)
+++ branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc 2009-03-22 20:40:35 UTC (rev 2818)
@@ -175,6 +175,14 @@
{
}
+ void Gametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
+ {
+ }
+
+ void Gametype::playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn)
+ {
+ }
+
bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)
{
return true;
Modified: branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h 2009-03-21 21:17:59 UTC (rev 2817)
+++ branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h 2009-03-22 20:40:35 UTC (rev 2818)
@@ -100,6 +100,9 @@
virtual void playerPreSpawn(PlayerInfo* player);
virtual void playerPostSpawn(PlayerInfo* player);
+ virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
+ virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn);
+
inline const std::map<PlayerInfo*, Player>& getPlayers() const
{ return this->players_; }
Modified: branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc 2009-03-21 21:17:59 UTC (rev 2817)
+++ branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc 2009-03-22 20:40:35 UTC (rev 2818)
@@ -33,7 +33,6 @@
#include "core/ConfigValueIncludes.h"
#include "objects/Teamcolourable.h"
#include "objects/worldentities/TeamSpawnPoint.h"
-#include "objects/infos/PlayerInfo.h" // remove this
namespace orxonox
{
@@ -150,7 +149,7 @@
return 0;
}
- void TeamGametype::playerPostSpawn(PlayerInfo* player)
+ void TeamGametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
{
if (!player)
return;
@@ -159,9 +158,9 @@
std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < this->teamcolours_.size())
{
- if (player->getControllableEntity())
+ if (pawn)
{
- std::set<WorldEntity*> pawnAttachments = player->getControllableEntity()->getAttachedObjects();
+ std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
{
if ((*it)->isA(Class(Teamcolourable)))
Modified: branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h 2009-03-21 21:17:59 UTC (rev 2817)
+++ branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h 2009-03-22 20:40:35 UTC (rev 2818)
@@ -52,7 +52,7 @@
virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
- virtual void playerPostSpawn(PlayerInfo* player);
+ virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
protected:
virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
Modified: branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-03-21 21:17:59 UTC (rev 2817)
+++ branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-03-22 20:40:35 UTC (rev 2818)
@@ -132,6 +132,22 @@
this->death();
}
+ void Pawn::setPlayer(PlayerInfo* player)
+ {
+ ControllableEntity::setPlayer(player);
+
+ if (this->getGametype())
+ this->getGametype()->playerStartsControllingPawn(player, this);
+ }
+
+ void Pawn::removePlayer()
+ {
+ if (this->getGametype())
+ this->getGametype()->playerStopsControllingPawn(this->getPlayer(), this);
+
+ ControllableEntity::removePlayer();
+ }
+
void Pawn::setHealth(float health)
{
this->health_ = min(health, this->maxHealth_);
Modified: branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-03-21 21:17:59 UTC (rev 2817)
+++ branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-03-22 20:40:35 UTC (rev 2818)
@@ -47,6 +47,9 @@
virtual void tick(float dt);
void registerVariables();
+ virtual void setPlayer(PlayerInfo* player);
+ virtual void removePlayer();
+
inline bool isAlive() const
{ return this->bAlive_; }
More information about the Orxonox-commit
mailing list