SuperTuxKart
Loading...
Searching...
No Matches
abstract_characteristic.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2006-2015 SuperTuxKart-Team
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_ABSTRACT_CHARACTERISTICS_HPP
20#define HEADER_ABSTRACT_CHARACTERISTICS_HPP
21
22#include <string>
23#include <vector>
24
26
43{
44public:
45 union Value
46 {
47 float *f;
48 bool *b;
49 std::vector<float> *fv;
51
52 Value(float *f) : f(f) {}
53 Value(bool *b) : b(b) {}
54 Value(std::vector<float> *fv) : fv(fv) {}
55 Value(InterpolationArray *ia) : ia(ia) {}
56 };
57
58 enum ValueType
59 {
60 TYPE_FLOAT,
61 TYPE_BOOL,
62 TYPE_FLOAT_VECTOR,
63 TYPE_INTERPOLATION_ARRAY
64 };
65
66 enum CharacteristicType
67 {
68 // Script-generated content generated by tools/create_kart_properties.py enum
69 // Please don't change the following tag. It will be automatically detected
70 // by the script and replace the contained content.
71 // To update the code, use tools/update_characteristics.py
72 /* <characteristics-start enum> */
73
74 // Suspension
75 SUSPENSION_STIFFNESS,
76 SUSPENSION_REST,
77 SUSPENSION_TRAVEL,
78 SUSPENSION_EXP_SPRING_RESPONSE,
79 SUSPENSION_MAX_FORCE,
80
81 // Stability
82 STABILITY_ROLL_INFLUENCE,
83 STABILITY_CHASSIS_LINEAR_DAMPING,
84 STABILITY_CHASSIS_ANGULAR_DAMPING,
85 STABILITY_DOWNWARD_IMPULSE_FACTOR,
86 STABILITY_TRACK_CONNECTION_ACCEL,
87 STABILITY_ANGULAR_FACTOR,
88 STABILITY_SMOOTH_FLYING_IMPULSE,
89
90 // Turn
91 TURN_RADIUS,
92 TURN_TIME_RESET_STEER,
93 TURN_TIME_FULL_STEER,
94
95 // Engine
96 ENGINE_POWER,
97 ENGINE_MAX_SPEED,
98 ENGINE_GENERIC_MAX_SPEED,
99 ENGINE_BRAKE_FACTOR,
100 ENGINE_BRAKE_TIME_INCREASE,
101 ENGINE_MAX_SPEED_REVERSE_RATIO,
102
103 // Gear
104 GEAR_SWITCH_RATIO,
105 GEAR_POWER_INCREASE,
106
107 // Mass
108 MASS,
109
110 // Wheels
111 WHEELS_DAMPING_RELAXATION,
112 WHEELS_DAMPING_COMPRESSION,
113
114 // Jump
115 JUMP_ANIMATION_TIME,
116
117 // Lean
118 LEAN_MAX,
119 LEAN_SPEED,
120
121 // Anvil
122 ANVIL_DURATION,
123 ANVIL_WEIGHT,
124 ANVIL_SPEED_FACTOR,
125
126 // Parachute
127 PARACHUTE_FRICTION,
128 PARACHUTE_DURATION,
129 PARACHUTE_DURATION_OTHER,
130 PARACHUTE_DURATION_RANK_MULT,
131 PARACHUTE_DURATION_SPEED_MULT,
132 PARACHUTE_LBOUND_FRACTION,
133 PARACHUTE_UBOUND_FRACTION,
134 PARACHUTE_MAX_SPEED,
135
136 // Friction
137 FRICTION_KART_FRICTION,
138
139 // Bubblegum
140 BUBBLEGUM_DURATION,
141 BUBBLEGUM_SPEED_FRACTION,
142 BUBBLEGUM_TORQUE,
143 BUBBLEGUM_FADE_IN_TIME,
144 BUBBLEGUM_SHIELD_DURATION,
145
146 // Zipper
147 ZIPPER_DURATION,
148 ZIPPER_FORCE,
149 ZIPPER_SPEED_GAIN,
150 ZIPPER_MAX_SPEED_INCREASE,
151 ZIPPER_FADE_OUT_TIME,
152
153 // Swatter
154 SWATTER_DURATION,
155 SWATTER_DISTANCE,
156 SWATTER_SQUASH_DURATION,
157 SWATTER_SQUASH_SLOWDOWN,
158
159 // Plunger
160 PLUNGER_BAND_MAX_LENGTH,
161 PLUNGER_BAND_FORCE,
162 PLUNGER_BAND_DURATION,
163 PLUNGER_BAND_SPEED_INCREASE,
164 PLUNGER_BAND_FADE_OUT_TIME,
165 PLUNGER_IN_FACE_TIME,
166
167 // Startup
168 STARTUP_TIME,
169 STARTUP_BOOST,
170
171 // Rescue
172 RESCUE_DURATION,
173 RESCUE_VERT_OFFSET,
174 RESCUE_HEIGHT,
175
176 // Explosion
177 EXPLOSION_DURATION,
178 EXPLOSION_RADIUS,
179 EXPLOSION_INVULNERABILITY_TIME,
180
181 // Nitro
182 NITRO_DURATION,
183 NITRO_ENGINE_FORCE,
184 NITRO_ENGINE_MULT,
185 NITRO_CONSUMPTION,
186 NITRO_SMALL_CONTAINER,
187 NITRO_BIG_CONTAINER,
188 NITRO_MAX_SPEED_INCREASE,
189 NITRO_FADE_OUT_TIME,
190 NITRO_MAX,
191
192 // Slipstream
193 SLIPSTREAM_DURATION_FACTOR,
194 SLIPSTREAM_BASE_SPEED,
195 SLIPSTREAM_LENGTH,
196 SLIPSTREAM_WIDTH,
197 SLIPSTREAM_INNER_FACTOR,
198 SLIPSTREAM_MIN_COLLECT_TIME,
199 SLIPSTREAM_MAX_COLLECT_TIME,
200 SLIPSTREAM_ADD_POWER,
201 SLIPSTREAM_MIN_SPEED,
202 SLIPSTREAM_MAX_SPEED_INCREASE,
203 SLIPSTREAM_FADE_OUT_TIME,
204
205 // Skid
206 SKID_INCREASE,
207 SKID_DECREASE,
208 SKID_MAX,
209 SKID_TIME_TILL_MAX,
210 SKID_VISUAL,
211 SKID_VISUAL_TIME,
212 SKID_REVERT_VISUAL_TIME,
213 SKID_MIN_SPEED,
214 SKID_TIME_TILL_BONUS,
215 SKID_BONUS_SPEED,
216 SKID_BONUS_TIME,
217 SKID_BONUS_FORCE,
218 SKID_PHYSICAL_JUMP_TIME,
219 SKID_GRAPHICAL_JUMP_TIME,
220 SKID_POST_SKID_ROTATE_FACTOR,
221 SKID_REDUCE_TURN_MIN,
222 SKID_REDUCE_TURN_MAX,
223 SKID_ENABLED,
224
225 /* <characteristics-end enum> */
226
227
228 // Count
229 CHARACTERISTIC_COUNT
230 };
231
232public:
234 virtual ~AbstractCharacteristic() {}
235 virtual void copyFrom(const AbstractCharacteristic *other) = 0;
236
249 virtual void process(CharacteristicType type, Value value, bool *is_set) const;
250
251 static ValueType getType(CharacteristicType type);
252 static std::string getName(CharacteristicType type);
253
254
255 // Script-generated content generated by tools/create_kart_properties.py defs
256 // Please don't change the following tag. It will be automatically detected
257 // by the script and replace the contained content.
258 // To update the code, use tools/update_characteristics.py
259 /* <characteristics-start acdefs> */
260
261 float getSuspensionStiffness() const;
262 float getSuspensionRest() const;
263 float getSuspensionTravel() const;
264 bool getSuspensionExpSpringResponse() const;
265 float getSuspensionMaxForce() const;
266
267 float getStabilityRollInfluence() const;
268 float getStabilityChassisLinearDamping() const;
269 float getStabilityChassisAngularDamping() const;
270 float getStabilityDownwardImpulseFactor() const;
271 float getStabilityTrackConnectionAccel() const;
272 std::vector<float> getStabilityAngularFactor() const;
273 float getStabilitySmoothFlyingImpulse() const;
274
275 InterpolationArray getTurnRadius() const;
276 float getTurnTimeResetSteer() const;
277 InterpolationArray getTurnTimeFullSteer() const;
278
279 float getEnginePower() const;
280 float getEngineMaxSpeed() const;
281 float getEngineGenericMaxSpeed() const;
282 float getEngineBrakeFactor() const;
283 float getEngineBrakeTimeIncrease() const;
284 float getEngineMaxSpeedReverseRatio() const;
285
286 std::vector<float> getGearSwitchRatio() const;
287 std::vector<float> getGearPowerIncrease() const;
288
289 float getMass() const;
290
291 float getWheelsDampingRelaxation() const;
292 float getWheelsDampingCompression() const;
293
294 float getJumpAnimationTime() const;
295
296 float getLeanMax() const;
297 float getLeanSpeed() const;
298
299 float getAnvilDuration() const;
300 float getAnvilWeight() const;
301 float getAnvilSpeedFactor() const;
302
303 float getParachuteFriction() const;
304 float getParachuteDuration() const;
305 float getParachuteDurationOther() const;
306 float getParachuteDurationRankMult() const;
307 float getParachuteDurationSpeedMult() const;
308 float getParachuteLboundFraction() const;
309 float getParachuteUboundFraction() const;
310 float getParachuteMaxSpeed() const;
311
312 float getFrictionKartFriction() const;
313
314 float getBubblegumDuration() const;
315 float getBubblegumSpeedFraction() const;
316 float getBubblegumTorque() const;
317 float getBubblegumFadeInTime() const;
318 float getBubblegumShieldDuration() const;
319
320 float getZipperDuration() const;
321 float getZipperForce() const;
322 float getZipperSpeedGain() const;
323 float getZipperMaxSpeedIncrease() const;
324 float getZipperFadeOutTime() const;
325
326 float getSwatterDuration() const;
327 float getSwatterDistance() const;
328 float getSwatterSquashDuration() const;
329 float getSwatterSquashSlowdown() const;
330
331 float getPlungerBandMaxLength() const;
332 float getPlungerBandForce() const;
333 float getPlungerBandDuration() const;
334 float getPlungerBandSpeedIncrease() const;
335 float getPlungerBandFadeOutTime() const;
336 float getPlungerInFaceTime() const;
337
338 std::vector<float> getStartupTime() const;
339 std::vector<float> getStartupBoost() const;
340
341 float getRescueDuration() const;
342 float getRescueVertOffset() const;
343 float getRescueHeight() const;
344
345 float getExplosionDuration() const;
346 float getExplosionRadius() const;
347 float getExplosionInvulnerabilityTime() const;
348
349 float getNitroDuration() const;
350 float getNitroEngineForce() const;
351 float getNitroEngineMult() const;
352 float getNitroConsumption() const;
353 float getNitroSmallContainer() const;
354 float getNitroBigContainer() const;
355 float getNitroMaxSpeedIncrease() const;
356 float getNitroFadeOutTime() const;
357 float getNitroMax() const;
358
359 float getSlipstreamDurationFactor() const;
360 float getSlipstreamBaseSpeed() const;
361 float getSlipstreamLength() const;
362 float getSlipstreamWidth() const;
363 float getSlipstreamInnerFactor() const;
364 float getSlipstreamMinCollectTime() const;
365 float getSlipstreamMaxCollectTime() const;
366 float getSlipstreamAddPower() const;
367 float getSlipstreamMinSpeed() const;
368 float getSlipstreamMaxSpeedIncrease() const;
369 float getSlipstreamFadeOutTime() const;
370
371 float getSkidIncrease() const;
372 float getSkidDecrease() const;
373 float getSkidMax() const;
374 float getSkidTimeTillMax() const;
375 float getSkidVisual() const;
376 float getSkidVisualTime() const;
377 float getSkidRevertVisualTime() const;
378 float getSkidMinSpeed() const;
379 std::vector<float> getSkidTimeTillBonus() const;
380 std::vector<float> getSkidBonusSpeed() const;
381 std::vector<float> getSkidBonusTime() const;
382 std::vector<float> getSkidBonusForce() const;
383 float getSkidPhysicalJumpTime() const;
384 float getSkidGraphicalJumpTime() const;
385 float getSkidPostSkidRotateFactor() const;
386 float getSkidReduceTurnMin() const;
387 float getSkidReduceTurnMax() const;
388 bool getSkidEnabled() const;
389
390 /* <characteristics-end acdefs> */
391};
392
393#endif
Characteristics are the properties of a kart that influence gameplay mechanics.
Definition: abstract_characteristic.hpp:43
static ValueType getType(CharacteristicType type)
Returns the type of a given characteristic.
Definition: abstract_characteristic.cpp:45
static std::string getName(CharacteristicType type)
Converts the enum value to a string.
Definition: abstract_characteristic.cpp:281
virtual void process(CharacteristicType type, Value value, bool *is_set) const
The process function is the core of this characteristics system.
Definition: abstract_characteristic.cpp:37
This class manages a set of (x_i,y_i) points, x_i must be sorted.
Definition: interpolation_array.hpp:32
Definition: abstract_characteristic.hpp:46