SuperTuxKart
Loading...
Searching...
No Matches
check_structure.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2009-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_STRUCTURE_HPP
20#define HEADER_CHECK_STRUCTURE_HPP
21
22#include <vector>
23
24#include "utils/aligned_array.hpp"
25#include "utils/vec3.hpp"
26
28class CheckManager;
29class Track;
30class XMLNode;
31
52{
53public:
68 enum CheckType {CT_NEW_LAP, CT_ACTIVATE, CT_TOGGLE, CT_CANNON,
69 CT_GOAL, CT_AMBIENT_SPHERE, CT_TRIGGER};
70
71protected:
75 AlignedArray<Vec3> m_previous_position;
77 std::vector<bool> m_is_active;
78
81
84 unsigned int m_index;
85
88private:
91
95
101 std::vector<int> m_same_group;
102
103 enum ChangeState {CS_DEACTIVATE, CS_ACTIVATE, CS_TOGGLE};
104
105 void changeStatus(const std::vector<int> &indices, int kart_index,
106 ChangeState change_state);
107
108public:
109 CheckStructure(const XMLNode &node, unsigned int index);
110 virtual ~CheckStructure() {};
111 virtual void update(float dt);
112 virtual void resetAfterKartMove(unsigned int kart_index) {}
113 virtual void resetAfterRewind(unsigned int kart_index) {}
114 virtual void changeDebugColor(bool is_active) {}
122 virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
123 int indx)=0;
124 virtual void trigger(unsigned int kart_index);
125 virtual void reset(const Track &track);
126
127 // ------------------------------------------------------------------------
129 CheckType getType() const { return m_check_type; }
130 // ------------------------------------------------------------------------
133 void addSuccessor(unsigned int i)
134 {
136 } // addSuccessor
137 // ------------------------------------------------------------------------
138 virtual bool triggeringCheckline() const { return false; }
139 // ------------------------------------------------------------------------
140 virtual void saveCompleteState(BareNetworkString* bns);
141 // ------------------------------------------------------------------------
142 virtual void restoreCompleteState(const BareNetworkString& b);
143 // ------------------------------------------------------------------------
144 void saveIsActive(int kart_id, BareNetworkString* bns);
145 // ------------------------------------------------------------------------
146 void restoreIsActive(int kart_id, const BareNetworkString& b);
147 // ------------------------------------------------------------------------
148 int getIndex() const { return m_index; }
149 // ------------------------------------------------------------------------
151 virtual CheckStructure* clone() = 0;
152}; // CheckStructure
153
154#endif
155
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Controls all checks structures of a track.
Definition: check_manager.hpp:40
Virtual base class for a check structure.
Definition: check_structure.hpp:52
virtual void update(float dt)
Updates all check structures.
Definition: check_structure.cpp:111
void changeStatus(const std::vector< int > &indices, int kart_index, ChangeState change_state)
Changes the status (active/inactive) of all check structures contained in the index list indices.
Definition: check_structure.cpp:143
virtual CheckStructure * clone()=0
Clone to child process for server usage (atm no sound or scripting).
CheckStructure()
For CheckTrigger or CheckCylinder.
Definition: check_structure.cpp:78
CheckType
Different types of check structures: ACTIVATE: Activates another check structure (independent of the ...
Definition: check_structure.hpp:68
CheckType getType() const
Returns the type of this check structure.
Definition: check_structure.hpp:129
virtual void reset(const Track &track)
Initialises the 'previous positions' of all karts with the start position defined for this track.
Definition: check_structure.cpp:91
virtual void trigger(unsigned int kart_index)
Is called when this check structure is triggered.
Definition: check_structure.cpp:220
AlignedArray< Vec3 > m_previous_position
Stores the previous position of all karts.
Definition: check_structure.hpp:75
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx)=0
True if going from old_pos to new_pos crosses this checkline.
void addSuccessor(unsigned int i)
Adds the index of a successor check structure which will get triggered by this check structure.
Definition: check_structure.hpp:133
std::vector< int > m_check_structures_to_change_state
Contains the indices of the corresponding check structures that get their state changed (activated or...
Definition: check_structure.hpp:94
std::vector< int > m_same_group
A list of check lines that should be activated/switched when this lines is activated/switched.
Definition: check_structure.hpp:101
std::vector< bool > m_is_active
Stores if this check structure is active (for a given kart).
Definition: check_structure.hpp:77
CheckType m_check_type
The type of this checkline.
Definition: check_structure.hpp:90
unsigned int m_index
Stores the index of this check structure.
Definition: check_structure.hpp:84
bool m_active_at_reset
True if this check structure should be activated at a reset.
Definition: check_structure.hpp:80
Definition: track.hpp:114
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48