00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SOCCERBASE_H
00023 #define SOCCERBASE_H
00024
00025 #include <soccer/soccertypes.h>
00026 #include <zeitgeist/scriptserver/scriptserver.h>
00027 #include <boost/shared_ptr.hpp>
00028
00029 namespace zeitgeist
00030 {
00031 class Leaf;
00032 }
00033
00034 namespace oxygen
00035 {
00036 class SceneServer;
00037 class Scene;
00038 class Transform;
00039 class Perceptor;
00040 class Body;
00041 class SphereCollider;
00042 class ControlAspect;
00043 }
00044
00045 namespace salt
00046 {
00047 class Vector3f;
00048 }
00049
00050 class AgentState;
00051 class GameStateAspect;
00052 class SoccerRuleAspect;
00053 class Ball;
00054
00055 class SoccerBase
00056 {
00057 public:
00058 typedef std::list<boost::shared_ptr<AgentState> > TAgentStateList;
00059
00060 public:
00061 SoccerBase() {}
00062
00063 virtual ~SoccerBase() {}
00064
00066 static bool
00067 GetSceneServer(const zeitgeist::Leaf& base,
00068 boost::shared_ptr<oxygen::SceneServer>& scene_server);
00069
00072 static bool
00073 GetTransformParent(const zeitgeist::Leaf& base,
00074 boost::shared_ptr<oxygen::Transform>& transform_parent);
00075
00078 static bool
00079 GetBody(const zeitgeist::Leaf& base, boost::shared_ptr<oxygen::Body>& body);
00080
00083 static bool
00084 GetAgentBody(const boost::shared_ptr<oxygen::Transform> transform,
00085 boost::shared_ptr<oxygen::Body>& agent_body);
00086
00089 static bool
00090 GetAgentBody(const zeitgeist::Leaf& base, TTeamIndex idx,
00091 int unum, boost::shared_ptr<oxygen::Body>& agent_body);
00092
00095 static bool
00096 GetAgentState(const zeitgeist::Leaf& base,
00097 boost::shared_ptr<AgentState>& agent_state);
00098
00101 static bool
00102 GetAgentState(const boost::shared_ptr<oxygen::Transform> transform,
00103 boost::shared_ptr<AgentState>& agentState);
00104
00107 static bool
00108 GetAgentState(const zeitgeist::Leaf& base, TTeamIndex idx,
00109 int unum, boost::shared_ptr<AgentState>& agent_state);
00110
00111 static bool
00112 GetAgentStates(const zeitgeist::Leaf& base,
00113 TAgentStateList& agentStates,
00114 TTeamIndex idx = TI_NONE);
00115
00117 static bool
00118 GetGameState(const zeitgeist::Leaf& base,
00119 boost::shared_ptr<GameStateAspect>& game_state);
00120
00122 static bool
00123 GetSoccerRuleAspect(const zeitgeist::Leaf& base,
00124 boost::shared_ptr<SoccerRuleAspect>& soccer_rule_aspect);
00125
00127 static bool
00128 GetActiveScene(const zeitgeist::Leaf& base,
00129 boost::shared_ptr<oxygen::Scene>& active_scene);
00130
00132 static bool
00133 GetBall(const zeitgeist::Leaf& base, boost::shared_ptr<Ball>& ball);
00134
00136 static bool
00137 GetBallBody(const zeitgeist::Leaf& base,
00138 boost::shared_ptr<oxygen::Body>& body);
00139
00141 static bool
00142 GetBallCollider(const zeitgeist::Leaf& base,
00143 boost::shared_ptr<oxygen::SphereCollider>& sphere);
00144
00146 static salt::Vector3f FlipView(const salt::Vector3f& pos, TTeamIndex ti);
00147
00149 static TTeamIndex OpponentTeam(TTeamIndex ti);
00150
00153 static boost::shared_ptr<oxygen::ControlAspect>
00154 GetControlAspect(const zeitgeist::Leaf& base, const std::string& name);
00155
00157 template<typename TYPE>
00158 static bool GetSoccerVar(const zeitgeist::Leaf& base, const std::string& name,
00159 TYPE& value)
00160 {
00161 static const std::string nSpace = "Soccer.";
00162 bool ok = base.GetCore()->GetScriptServer()->GetVariable
00163 (std::string(nSpace + name),value);
00164
00165 if (! ok)
00166 {
00167 base.GetLog()->Error()
00168 << "ERROR: (SoccerBase: " << base.GetName()
00169 << ") soccer variable '" << name << "' not found\n";
00170 return false;
00171 }
00172
00173 return ok;
00174 }
00175
00177 static std::string PlayMode2Str(const TPlayMode mode);
00178 };
00179
00180 #endif