19#ifndef SOCCER_WORLD_HPP
20#define SOCCER_WORLD_HPP
22#include "modes/world_with_rank.hpp"
23#include "states_screens/race_gui_base.hpp"
24#include "karts/abstract_kart.hpp"
80 std::vector<KartDistanceMap> m_red_kdm;
81 std::vector<KartDistanceMap> m_blue_kdm;
82 std::unique_ptr<BallGoalData> m_bgd;
86 btRigidBody* m_ball_body;
90 bool m_count_down_reached_zero;
101 std::vector<ScorerData> m_blue_scorers;
106 float m_ball_heading;
108 std::vector<int> m_team_icon_draw_id;
110 std::vector<btTransform> m_goal_transforms;
120 std::vector<int> m_goal_frame;
122 int m_reset_ball_ticks;
123 int m_ticks_back_to_own_goal;
125 void resetKartsToSelfGoals();
132 virtual void init() OVERRIDE;
133 virtual
void onGo() OVERRIDE;
141 virtual
void reset(
bool restart=false) OVERRIDE;
148 std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
154 virtual const std::
string&
getIdent() const OVERRIDE;
156 virtual
void update(
int ticks) OVERRIDE;
160 void onCheckGoalTriggered(
bool first_goal);
167 int getScore(KartTeam team)
const
169 return (
int)(team == KART_TEAM_BLUE ? m_blue_scorers.size()
173 const std::vector<ScorerData>& getScorers(KartTeam team)
const
174 {
return (team == KART_TEAM_BLUE ? m_blue_scorers :
m_red_scorers); }
176 int getBallNode()
const;
178 const Vec3& getBallPosition()
const
179 {
return (
Vec3&)m_ball_body->getCenterOfMassTransform().getOrigin(); }
181 bool ballNotMoving()
const
183 return (m_ball_body->getLinearVelocity().x() == 0.0f ||
184 m_ball_body->getLinearVelocity().z() == 0.0f);
187 float getBallHeading()
const
188 {
return m_ball_heading; }
190 float getBallDiameter()
const;
192 bool ballApproachingGoal(KartTeam team)
const;
194 Vec3 getBallAimPosition(KartTeam team,
bool reverse =
false)
const;
196 bool isCorrectGoal(
unsigned int kart_id,
bool first_goal)
const;
198 int getBallChaser(KartTeam team)
const
201 assert(m_blue_kdm.size() > 0 && m_red_kdm.size() > 0);
202 return (team == KART_TEAM_BLUE ? m_blue_kdm[0].m_kart_id :
203 m_red_kdm[0].m_kart_id);
213 virtual bool hasTeam() const OVERRIDE {
return true; }
218 std::pair<uint32_t, uint32_t> progress(
219 std::numeric_limits<uint32_t>::max(),
220 std::numeric_limits<uint32_t>::max());
221 if (RaceManager::get()->hasTimeTarget())
223 progress.first = (uint32_t)
m_time;
228 (float)RaceManager::get()->getMaxGoal() * 100.0f);
232 progress.second = (uint32_t)((
float)m_blue_scorers.size() /
233 (float)RaceManager::get()->getMaxGoal() * 100.0f);
243 virtual bool isGoalPhase() const OVERRIDE
246 return diff > 0 && diff < stk_config->
time2Ticks(3.0f);
250 {
return getKart(m_team_icon_draw_id[p - 1]); }
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: soccer_world.cpp:55
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:46
A new implementation of NetworkString, which has a fixed format: Byte 0: The type of the message,...
Definition: network_string.hpp:422
The base class for sound effects.
Definition: sfx_base.hpp:43
int time2Ticks(float t)
Converts a time value into ticks (of physics time steps).
Definition: stk_config.hpp:316
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:76
Definition: soccer_world.hpp:62
float m_distance
Distance to ball from kart.
Definition: soccer_world.hpp:67
unsigned int m_kart_id
World ID of kart.
Definition: soccer_world.hpp:65
An implementation of WorldWithRank, to provide the soccer game mode Notice: In soccer world,...
Definition: soccer_world.hpp:40
void updateAIData()
Function to update data for AI usage.
Definition: soccer_world.cpp:877
virtual void reset(bool restart=false) OVERRIDE
Called when a soccer game is restarted.
Definition: soccer_world.cpp:322
bool shouldDrawTimer() const OVERRIDE
The code that draws the timer should call this first to know whether the game mode wants a timer draw...
Definition: soccer_world.hpp:158
TrackSector * m_ball_track_sector
Data generated from navmesh.
Definition: soccer_world.hpp:104
bool getKartSoccerResult(unsigned int kart_id) const
Get the soccer result of kart in soccer world (including AIs)
Definition: soccer_world.cpp:774
virtual std::pair< uint32_t, uint32_t > getGameStartedProgress() const OVERRIDE
Used by server to get the current started game progress in either or both remaining time or progress ...
Definition: soccer_world.hpp:215
int m_frame_count
Profiling usage.
Definition: soccer_world.hpp:119
virtual const std::string & getIdent() const OVERRIDE
Returns the internal identifier for this race.
Definition: soccer_world.cpp:411
AbstractKart * getKartAtDrawingPosition(unsigned int p) const OVERRIDE
Returns the kart at which position (start from 1) to draw race icon.
Definition: soccer_world.hpp:249
int getAttacker(KartTeam team) const
Get the AI who will attack the other team ball chaser.
Definition: soccer_world.cpp:912
virtual void getKartsDisplayInfo(std::vector< RaceGUIBase::KartIconDisplayInfo > *info) OVERRIDE
Returns the data to display in the race gui.
Definition: soccer_world.cpp:1149
virtual bool raceHasLaps() OVERRIDE
Called when it is needed to know whether this kind of race involves counting laps.
Definition: soccer_world.hpp:150
SoccerWorld()
Constructor.
Definition: soccer_world.cpp:238
virtual void update(int ticks) OVERRIDE
Update the world and the track.
Definition: soccer_world.cpp:420
int getTeamNum(KartTeam team) const
Get number of teammates in a team, used by starting position assign.
int m_goal_target
Number of goals needed to win.
Definition: soccer_world.hpp:89
virtual void terminateRace() OVERRIDE
Called at the end of a race.
Definition: soccer_world.cpp:396
virtual void onGo() OVERRIDE
Called when 'go' is being displayed for the first time.
Definition: soccer_world.cpp:388
virtual bool isRaceOver() OVERRIDE
The soccer game is over if time up or either team wins.
Definition: soccer_world.cpp:744
virtual ~SoccerWorld()
The destructor frees all data structures.
Definition: soccer_world.cpp:261
virtual void enterRaceOverState() OVERRIDE
Called when the race is finished, but it still leaves some time for an end of race animation,...
Definition: soccer_world.cpp:970
virtual void init() OVERRIDE
Initializes the soccer world.
Definition: soccer_world.cpp:273
std::vector< ScorerData > m_red_scorers
Goals data of each team scored.
Definition: soccer_world.hpp:100
virtual btTransform getRescueTransform(unsigned int rescue_pos) const OVERRIDE
Returns the bullet transformation for the specified rescue index.
Definition: soccer_world.cpp:955
TrackObject * m_ball
Keep a pointer to the track object of soccer ball.
Definition: soccer_world.hpp:85
virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE
Determines the rescue position for a kart.
Definition: soccer_world.cpp:941
virtual void countdownReachedZero() OVERRIDE
Called when the match time ends.
Definition: soccer_world.cpp:765
int m_ball_invalid_timer
Counts ticks when the ball is off track, so a reset can be triggered if the ball is off for more than...
Definition: soccer_world.hpp:96
void setBallHitter(unsigned int kart_id)
Sets the last kart that hit the ball, to be able to identify the scorer later.
Definition: soccer_world.cpp:736
void updateBallPosition(int ticks)
Function to update the location the ball on the polygon map.
Definition: soccer_world.cpp:792
virtual bool useFastMusicNearEnd() const OVERRIDE
Returns if this mode should use fast music (if available).
Definition: soccer_world.hpp:146
This is a base object for any separate object on the track, which might also have a skeletal animatio...
Definition: track_object.hpp:56
This object keeps track of which sector an object is on.
Definition: track_sector.hpp:39
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
double m_time
Elasped/remaining time in seconds.
Definition: world_status.hpp:94
int getTicksSinceStart() const
Get the ticks since start regardless of which way the clock counts.
Definition: world_status.hpp:226
A WorldWithRank is a world where the karts are ranked.
Definition: world_with_rank.hpp:39
AbstractKart * getKart(int kartId) const
Returns the kart with a given world id.
Definition: world.hpp:342
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:42
Definition: soccer_world.hpp:43
unsigned int m_id
World ID of kart which scores.
Definition: soccer_world.hpp:45
core::stringw m_player
Player name which scores.
Definition: soccer_world.hpp:53
std::string m_kart
Kart ident which scores.
Definition: soccer_world.hpp:51
std::string m_country_code
Country code of player.
Definition: soccer_world.hpp:55
HandicapLevel m_handicap_level
Handicap of player.
Definition: soccer_world.hpp:57
float m_time
Time goal.
Definition: soccer_world.hpp:49
bool m_correct_goal
Whether this goal is socred correctly (identify for own goal).
Definition: soccer_world.hpp:47