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_BODY_SENSOR_H 00033 #define RCSC_PLAYER_BODY_SENSOR_H 00034 00035 #include <rcsc/player/view_mode.h> 00036 #include <rcsc/game_time.h> 00037 #include <rcsc/types.h> 00038 00039 #include <iostream> 00040 00041 namespace rcsc { 00042 00047 class BodySensor { 00048 public: 00049 00050 GameTime M_time; 00051 00052 ViewQuality M_view_quality; 00053 ViewWidth M_view_width; 00054 double M_stamina; 00055 double M_effort; 00056 double M_speed_mag; 00057 double M_speed_dir_relative; 00058 double M_neck_relative; 00059 00060 int M_kick_count; 00061 int M_dash_count; 00062 int M_turn_count; 00063 int M_say_count; 00064 int M_turn_neck_count; 00065 int M_catch_count; 00066 int M_move_count; 00067 int M_change_view_count; 00068 00073 int M_arm_movable; 00078 int M_arm_expires; 00079 00084 double M_pointto_dist; 00085 00090 double M_pointto_dir; 00091 00092 int M_pointto_count; 00093 00094 SideID M_attentionto_side; 00095 int M_attentionto_unum; 00096 int M_attentionto_count; 00097 00102 int M_tackle_expires; 00103 int M_tackle_count; 00104 00105 bool M_none_collided; 00106 bool M_ball_collided; 00107 bool M_player_collided; 00108 bool M_post_collided; 00109 00110 public: 00114 BodySensor(); 00115 00122 void parse( const char * msg, 00123 const double & version, 00124 const GameTime & current ) 00125 { 00126 parse1( msg, version, current ); 00127 } 00128 00135 void parse1( const char * msg, 00136 const double & version, 00137 const GameTime & current ); 00144 void parse2( const char * msg, 00145 const double & version, 00146 const GameTime & current ); 00147 00148 private: 00149 00154 void parseCollision( const char * msg ); 00155 00156 public: 00157 00162 const 00163 GameTime & time() const 00164 { 00165 return M_time; 00166 } 00167 00172 const 00173 ViewQuality & viewQuality() const 00174 { 00175 return M_view_quality; 00176 } 00177 00182 const 00183 ViewWidth & viewWidth() const 00184 { 00185 return M_view_width; 00186 } 00187 00192 const 00193 double & stamina() const 00194 { 00195 return M_stamina; 00196 } 00197 00202 const 00203 double & effort() const 00204 { 00205 return M_effort; 00206 } 00207 00212 const 00213 double & speedMag() const 00214 { 00215 return M_speed_mag; 00216 } 00217 00222 const 00223 double & speedDir() const 00224 { 00225 return M_speed_dir_relative; 00226 } 00227 00232 const 00233 double & neckDir() const 00234 { 00235 return M_neck_relative; 00236 } 00237 00242 int kickCount() const 00243 { 00244 return M_kick_count; 00245 } 00246 00251 int dashCount() const 00252 { 00253 return M_dash_count; 00254 } 00255 00260 int turnCount() const 00261 { 00262 return M_turn_count; 00263 } 00264 00269 int sayCount() const 00270 { 00271 return M_say_count; 00272 } 00273 00278 int turnNeckCount() const 00279 { 00280 return M_turn_neck_count; 00281 } 00282 00287 int catchCount() const 00288 { 00289 return M_catch_count; 00290 } 00291 00296 int moveCount() const 00297 { 00298 return M_move_count; 00299 } 00300 00305 int changeViewCount() const 00306 { 00307 return M_change_view_count; 00308 } 00309 00314 int armMovable() const 00315 { 00316 return M_arm_movable; 00317 } 00318 00323 int armExpires() const 00324 { 00325 return M_arm_expires; 00326 } 00327 00332 const 00333 double & pointtoDist() const 00334 { 00335 return M_pointto_dist; 00336 } 00337 00342 const 00343 double & pointtoDir() const 00344 { 00345 return M_pointto_dir; 00346 } 00347 00352 int pointtoCount() const 00353 { 00354 return M_pointto_count; 00355 } 00356 00361 SideID attentiontoSide() const 00362 { 00363 return M_attentionto_side; 00364 } 00365 00370 int attentiontoUnum() const 00371 { 00372 return M_attentionto_unum; 00373 } 00374 00379 int attentiontoCount() const 00380 { 00381 return M_attentionto_count; 00382 } 00383 00388 int tackleExpires() const 00389 { 00390 return M_tackle_expires; 00391 } 00392 00397 int tackleCount() const 00398 { 00399 return M_tackle_count; 00400 } 00401 00406 bool noneCollided() const 00407 { 00408 return M_none_collided; 00409 } 00410 00415 bool ballCollided() const 00416 { 00417 return M_ball_collided; 00418 } 00419 00424 bool playerCollided() const 00425 { 00426 return M_player_collided; 00427 } 00428 00433 bool postCollided() const 00434 { 00435 return M_post_collided; 00436 } 00437 00443 std::ostream & print( std::ostream & os ) const; 00444 }; 00445 00446 } 00447 00448 #endif