00001 // -*-c++-*- 00002 00008 /* 00009 *Copyright: 00010 00011 Copyright (C) Hidehisa AKIYAMA 00012 00013 This code is free software; you can redistribute it and/or 00014 modify it under the terms of the GNU Lesser General Public 00015 License as published by the Free Software Foundation; either 00016 version 2.1 of the License, or (at your option) any later version. 00017 00018 This library is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 Lesser General Public License for more details. 00022 00023 You should have received a copy of the GNU Lesser General Public 00024 License along with this library; if not, write to the Free Software 00025 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 00027 *EndCopyright: 00028 */ 00029 00031 00032 #ifndef RCSC_PLAYER_ABSTRACT_PLAYER_OBJECT_H 00033 #define RCSC_PLAYER_ABSTRACT_PLAYER_OBJECT_H 00034 00035 #include <rcsc/player/localization.h> 00036 00037 #include <rcsc/common/player_type.h> 00038 #include <rcsc/geom/vector_2d.h> 00039 #include <rcsc/geom/angle_deg.h> 00040 #include <rcsc/types.h> 00041 00042 namespace rcsc { 00043 00048 class AbstractPlayerObject { 00049 protected: 00050 00051 SideID M_side; 00052 int M_unum; 00053 bool M_goalie; 00054 00055 int M_type; 00056 const PlayerType * M_player_type; 00057 00058 Vector2D M_pos; 00059 int M_pos_count; 00060 00061 Vector2D M_seen_pos; 00062 int M_seen_pos_count; 00063 00064 Vector2D M_heard_pos; 00065 int M_heard_pos_count; 00066 00067 Vector2D M_vel; 00068 int M_vel_count; 00069 00070 AngleDeg M_body; 00071 int M_body_count; 00072 AngleDeg M_face; 00073 int M_face_count; 00074 00075 double M_dist_from_ball; 00076 00077 public: 00078 00082 AbstractPlayerObject(); 00083 00089 AbstractPlayerObject( const SideID side, 00090 const Localization::PlayerT & p ); 00091 00095 virtual 00096 ~AbstractPlayerObject() 00097 { } 00098 00099 00100 // ------------------------------------------ 00105 virtual 00106 bool isSelf() const 00107 { 00108 return false; 00109 } 00110 00115 virtual 00116 bool isGhost() const 00117 { 00118 return false; 00119 } 00120 00121 // ------------------------------------------ 00122 00127 SideID side() const 00128 { 00129 return M_side; 00130 } 00131 00136 int unum() const 00137 { 00138 return M_unum; 00139 } 00140 00145 bool goalie() const 00146 { 00147 return M_goalie; 00148 } 00149 00154 int type() const 00155 { 00156 return M_type; 00157 } 00158 00163 const 00164 PlayerType * playerTypePtr() const 00165 { 00166 return M_player_type; 00167 } 00168 00173 void setPlayerType( const int type ); 00174 00179 const 00180 Vector2D & pos() const 00181 { 00182 return M_pos; 00183 } 00184 00189 int posCount() const 00190 { 00191 return M_pos_count; 00192 } 00193 00198 const 00199 Vector2D & seenPos() const 00200 { 00201 return M_seen_pos; 00202 } 00203 00208 int seenPosCount() const 00209 { 00210 return M_seen_pos_count; 00211 } 00212 00217 const 00218 Vector2D & heardPos() const 00219 { 00220 return M_heard_pos; 00221 } 00222 00227 int heardPosCount() const 00228 { 00229 return M_heard_pos_count; 00230 } 00231 00236 const 00237 Vector2D & vel() const 00238 { 00239 return M_vel; 00240 } 00241 00246 int velCount() const 00247 { 00248 return M_vel_count; 00249 } 00250 00255 const 00256 AngleDeg & body() const 00257 { 00258 return M_body; // global body angle 00259 } 00260 00265 int bodyCount() const 00266 { 00267 return M_body_count; 00268 } 00269 00274 const 00275 AngleDeg & face() const 00276 { 00277 return M_face; // global neck angle 00278 } 00279 00284 int faceCount() const 00285 { 00286 return M_face_count; 00287 } 00288 00293 const 00294 double & distFromBall() const 00295 { 00296 return M_dist_from_ball; 00297 } 00298 00304 Vector2D inertiaPoint( const int n_step ) const 00305 { 00306 return ( playerTypePtr() 00307 ? playerTypePtr()->inertiaPoint( pos(), vel(), n_step ) 00308 : Vector2D::INVALIDATED ); 00309 } 00310 00315 Vector2D inertiaFinalPoint() const 00316 { 00317 return ( playerTypePtr() 00318 ? playerTypePtr()->inertiaFinalPoint( pos(), vel() ) 00319 : Vector2D::INVALIDATED ); 00320 } 00321 00322 // ------------------------------------------ 00328 template < typename REGION > 00329 bool isWithin( const REGION & region ) const 00330 { 00331 return region.contains( this->pos() ); 00332 } 00333 00334 }; 00335 00337 typedef std::vector< AbstractPlayerObject * > AbstractPlayerCont; 00338 00339 } 00340 00341 #endif