00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- 00002 00003 this file is part of rcssserver3D 00004 Fri May 9 2003 00005 Copyright (C) 2002,2003 Koblenz University 00006 Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group 00007 $Id: gamestateaspect.h,v 1.7 2006/02/28 17:00:49 jamu Exp $ 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; version 2 of the License. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 */ 00022 #ifndef GAMESTATEASPECT_H 00023 #define GAMESTATEASPECT_H 00024 00025 #include <soccer/soccercontrolaspect/soccercontrolaspect.h> 00026 #include <set> 00027 00028 class AgentState; 00029 00030 class GameStateAspect : public SoccerControlAspect 00031 { 00032 protected: 00033 typedef std::set<int> TUnumSet; 00034 00035 public: 00036 GameStateAspect(); 00037 virtual ~GameStateAspect(); 00038 00042 virtual void Update(float deltaTime); 00043 00047 bool IsFinished() const { return mFinished; } 00048 00050 void Finish() { mFinished = true; } 00051 00053 TPlayMode GetPlayMode() const; 00054 00056 void SetPlayMode(TPlayMode mode); 00057 00061 void KickOff(TTeamIndex ti = TI_NONE); 00062 00064 TTime GetTime() const; 00065 00067 TTime GetModeTime() const; 00068 00070 TTime GetLastModeChange() const; 00071 00073 void SetGameHalf(TGameHalf half); 00074 00076 TGameHalf GetGameHalf() const; 00077 00079 void SetTeamName(TTeamIndex idx, const std::string& name); 00080 00082 std::string GetTeamName(TTeamIndex idx) const; 00083 00086 bool RequestUniform(boost::shared_ptr<AgentState> agentState, 00087 std::string teamName, unsigned int unum); 00088 00090 int RequestUniformNumber(TTeamIndex ti) const; 00091 00094 salt::Vector3f RequestInitPosition(const TTeamIndex ti); 00095 00097 void ScoreTeam(TTeamIndex idx); 00098 00100 int GetScore(TTeamIndex idx) const; 00101 00102 protected: 00104 virtual void OnLink(); 00105 00107 void UpdateTime(float deltaTime); 00108 00111 bool GameStateAspect::InsertUnum(TTeamIndex idx, int unum); 00112 00117 TTeamIndex GetTeamIndex(const std::string& teamName); 00118 00119 protected: 00121 TPlayMode mPlayMode; 00122 00124 TTime mLastModeChange; 00125 00127 TTime mTime; 00128 00130 TTime mLeadTime; 00131 00133 TTime mFupTime; 00134 00136 TGameHalf mGameHalf; 00137 00139 TTeamIndex mLastKickOff; 00140 00141 // /** the team that has to start the second half */ 00142 // TTeamIndex mSecondHalfKickOff; 00143 00145 std::string mTeamName[2]; 00146 00148 TUnumSet mUnumSet[2]; 00149 00151 int mMaxUnum[2]; 00152 00154 int mScore[2]; 00155 00157 salt::Vector3f mLeftInit; 00158 00160 salt::Vector3f mRightInit; 00161 00163 float mAgentRadius; 00165 bool mFinished; 00166 }; 00167 00168 DECLARE_CLASS(GameStateAspect); 00169 00170 #endif // GAMESTATEASPECT_H