SuperTuxKart
check_goal.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2012-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_CHECK_GOAL_HPP
20 #define HEADER_CHECK_GOAL_HPP
21 
22 #include "tracks/check_structure.hpp"
23 #include "utils/cpp2011.hpp"
24 #include <line2d.h>
25 using namespace irr;
26 
27 class XMLNode;
28 class Track;
29 class Vec3;
30 
37 class CheckGoal : public CheckStructure
38 {
39 public:
42  {
43  POINT_FIRST,
44  POINT_CENTER,
45  POINT_LAST
46  };
47 private:
50 
53 
55  core::line2df m_line;
56 
59  Vec3 m_p2;
60  Vec3 m_p3;
61 
62 public:
63  CheckGoal(const XMLNode &node, unsigned int index);
64  virtual ~CheckGoal() {}
65  virtual void update(float dt) OVERRIDE;
66  virtual void trigger(unsigned int kart_index) OVERRIDE;
67  virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
68  int indx) OVERRIDE;
69  virtual void reset(const Track &track) OVERRIDE;
70 
71  // ------------------------------------------------------------------------
72  bool getTeam() const { return m_first_goal; }
73  // ------------------------------------------------------------------------
74  const Vec3& getPoint(PointLocation point) const
75  {
76  return (point == POINT_LAST ? m_p3 :
77  (point == POINT_CENTER ? m_p2 : m_p1));
78  }
79 }; // CheckGoal
80 
81 #endif
Vec3 m_p1
Used by AIs to test whether the ball is likely to goal.
Definition: check_goal.hpp:58
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:34
core::line2df m_line
The line that is tested for being crossed.
Definition: check_goal.hpp:55
PointLocation
Used by AIs to test whether the ball is likely to goal.
Definition: check_goal.hpp:41
Vec3 m_previous_ball_position
Previois ball position.
Definition: check_goal.hpp:49
Implements a simple checkline that will score a point when the soccer ball crosses it.
Definition: check_goal.hpp:37
utility class used to parse XML files
Definition: xml_node.hpp:47
Virtual base class for a check structure.
Definition: check_structure.hpp:51
Definition: track.hpp:96
bool m_first_goal
Which team is this goal for?
Definition: check_goal.hpp:52