Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

soccerruleaspect.h

Go to the documentation of this file.
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: soccerruleaspect.h,v 1.11 2006/02/27 19:12:24 fruit 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 SOCCERRULEASPECT_H
00023 #define SOCCERRULEASPECT_H
00024 
00025 #include <soccer/soccercontrolaspect/soccercontrolaspect.h>
00026 #include <soccer/soccertypes.h>
00027 
00028 class GameStateAspect;
00029 class BallStateAspect;
00030 class AgentState;
00031 
00032 namespace salt
00033 {
00034     class AABB2;
00035 }
00036 
00037 namespace oxygen
00038 {
00039     class Body;
00040     class AgentAspect;
00041 }
00042 
00043 class SoccerRuleAspect : public SoccerControlAspect
00044 {
00045 public:
00046     typedef std::list<boost::shared_ptr<AgentState> > TAgentStateList;
00047 
00048 public:
00049     SoccerRuleAspect();
00050     virtual ~SoccerRuleAspect();
00051 
00055     virtual void Update(float deltaTime);
00056 
00060     void DropBall();
00065     void DropBall(salt::Vector3f pos);
00066 
00073     void Broadcast(const std::string& message, const salt::Vector3f& pos,
00074                    int number, TTeamIndex idx);
00075 
00087     void ClearPlayersWithException(const salt::Vector3f& pos, float radius, float min_dist, 
00088                       TTeamIndex idx, boost::shared_ptr<AgentState> agentState);
00089 
00090 protected:
00092     virtual void UpdateCachedInternal();
00093 
00095     virtual void OnLink();
00096 
00098     virtual void OnUnlink();
00099 
00101     void CheckTime();
00102 
00104     void UpdateBeforeKickOff();
00105 
00107     void UpdateKickOff(TTeamIndex idx = TI_NONE);
00108 
00110     void UpdateKickIn(TTeamIndex ti = TI_NONE);
00111 
00113     void UpdateGoalKick(TTeamIndex ti = TI_NONE);
00114 
00116     void UpdateCornerKick(TTeamIndex ti = TI_NONE);
00117 
00119     void UpdatePlayOn();
00120 
00122     void UpdateGoal();
00123 
00125     void UpdateOffside(TTeamIndex ti = TI_NONE);
00126 
00128     void UpdateGameOver();
00129 
00134     bool CheckBallLeftField();
00135 
00140     bool CheckGoal();
00141 
00143     bool CheckOffside();
00144 
00146     void MoveBall(const salt::Vector3f& pos);
00147 
00152     void MoveAgent(boost::shared_ptr<oxygen::Body> agent_body,
00153                    const salt::Vector3f& pos);
00154 
00166     void ClearPlayers(const salt::Vector3f& pos, float radius,
00167                       float min_dist, TTeamIndex idx);
00177     void ClearPlayers(const salt::AABB2& box, float min_dist, TTeamIndex idx);
00178 
00179 protected:
00181     boost::shared_ptr<oxygen::Body> mBallBody;
00182 
00184     boost::shared_ptr<GameStateAspect> mGameState;
00185 
00187     boost::shared_ptr<BallStateAspect> mBallState;
00188 
00190     float mBallRadius;
00191 
00193     float mGoalPauseTime;
00194 
00196     float mKickInPauseTime;
00197 
00199     float mHalfTime;
00200 
00204     float mDropBallTime;
00205 
00207     salt::Vector3f mLastValidBallPos;
00209     float mFieldLength;
00211     float mFieldWidth;
00213     float mGoalWidth;
00215     salt::Vector3f mFreeKickPos;
00217     float mFreeKickDist;
00220     float mFreeKickMoveDist;
00222     bool mAutomaticKickOff;
00224     float mWaitBeforeKickOff;
00226     bool mSingleHalfTime;
00227     // areas where opponents are not allowed in certain play modes
00229     salt::AABB2 mRightHalf;
00231     salt::AABB2 mLeftHalf;
00233     salt::AABB2 mRightPenaltyArea;
00235     salt::AABB2 mLeftPenaltyArea;
00236 
00238     int mSayMsgSize;
00240     float mAudioCutDist;
00241 
00243     std::vector<int> mInOffsideLeftPlayers;
00244     std::vector<int> mInOffsideRightPlayers;
00245     boost::shared_ptr<oxygen::AgentAspect> mPreLastCollidingAgent;
00246 
00248     bool mFirstCollidingAgent;
00249 
00251     bool mNotOffside;
00252 
00254     bool mUseOffside;
00255 };
00256 
00257 DECLARE_CLASS(SoccerRuleAspect);
00258 
00259 
00260 #endif // SOCCERRULEASPECT_H

Generated on Thu Apr 6 15:25:40 2006 for rcssserver3d by  doxygen 1.4.4