22#ifndef HEADER_FLYABLE_HPP
23#define HEADER_FLYABLE_HPP
25#include "items/powerup_manager.hpp"
26#include "karts/moveable.hpp"
27#include "network/rewinder.hpp"
28#include "tracks/terrain_info.hpp"
29#include "utils/cpp2011.hpp"
34 namespace scene {
class IMesh; }
52 bool m_has_hit_something;
73 uint32_t m_compressed_gravity_vector;
84 PowerupManager::PowerupType
119 bool m_has_server_state;
131 int m_last_deleted_ticks;
142 static scene::IMesh *
m_st_model[PowerupManager::POWERUP_MAX];
164 float *minDistSquared,
167 const bool backwards=
false)
const;
171 float item_XY_velocity,
float gravity,
173 float *fire_angle,
float *up_velocity);
178 const Vec3 &velocity,
179 btCollisionShape *shape,
181 const btVector3& gravity=btVector3(0.0f,0.0f,0.0f),
182 const bool rotates=
false,
183 const bool turn_around=
false,
184 const btTransform* customDirection=NULL);
187 void removePhysics();
188 void fixSFXSplitscreen(
SFXBase* sfx);
192 PowerupManager::PowerupType type,
195 static void init (
const XMLNode &node, scene::IMesh *model,
196 PowerupManager::PowerupType type);
204 bool secondary_hits=
true);
205 unsigned int getOwnerId();
226 bool hasHit () {
return m_has_hit_something; }
250 void addForRewind(
const std::string& uid);
268 bool hasServerState()
const {
return m_has_server_state; }
274 virtual void onDeleteFlyable();
276 void setCreatedTicks(
int ticks) { m_created_ticks = ticks; }
The base class for all kart animation, like rescue, explosion, or cannon.
Definition: abstract_kart_animation.hpp:60
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Definition: flyable.hpp:50
static float m_st_speed[PowerupManager::POWERUP_MAX]
Speed of the projectile.
Definition: flyable.hpp:139
virtual void undoState(BareNetworkString *buffer) OVERRIDE
Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo).
Definition: flyable.hpp:256
virtual void saveTransform() OVERRIDE
Called before a rewind.
Definition: flyable.cpp:745
void setPositionOffset(const Vec3 &o)
Sets the offset to be used when determining the terrain under the flyable.
Definition: flyable.hpp:218
PowerupManager::PowerupType getType() const
Returns the type of flyable.
Definition: flyable.hpp:236
virtual BareNetworkString * saveState(std::vector< std::string > *ru) OVERRIDE
Provides a copy of the state of the object in one memory buffer.
Definition: flyable.cpp:667
AbstractKart * getOwner() const
Returns the owner's kart.
Definition: flyable.hpp:240
bool m_owner_has_temporary_immunity
If set to true, the kart that throwns this flyable can't collide with it for a short time.
Definition: flyable.hpp:123
virtual void onFireFlyable()
Call when the item is (re-)fired (during rewind if needed) by projectile_manager.
Definition: flyable.cpp:777
float m_min_height
Minimum height above terrain.
Definition: flyable.hpp:94
float m_average_height
Average of average of m_{min,ax}_height.
Definition: flyable.hpp:97
void explode(AbstractKart *kart, PhysicalObject *obj=NULL, bool secondary_hits=true)
Creates the explosion physical effect, i.e.
Definition: flyable.cpp:571
float m_speed
Speed of this Flyable.
Definition: flyable.hpp:103
static float m_st_force_updown[PowerupManager::POWERUP_MAX]
Force pushing up/down.
Definition: flyable.hpp:151
void moveToInfinity(bool set_moveable_trans=true)
It's called when undoing the creation or destruction of flyables, so that it will not affected the cu...
Definition: flyable.cpp:653
virtual bool hit(AbstractKart *kart, PhysicalObject *obj=NULL)
Callback from the physics in case that a kart or physical object is hit.
Definition: flyable.cpp:551
static float m_st_max_height[PowerupManager::POWERUP_MAX]
Max height above track.
Definition: flyable.hpp:148
const Vec3 & getExtend() const
Returns the size (extend) of the mesh.
Definition: flyable.hpp:248
bool isOwnerImmunity(const AbstractKart *kart_hit) const
Returns true if the item hit the kart who shot it (to avoid that an item that's too close to the shoo...
Definition: flyable.cpp:537
int m_max_lifespan
Set to something > -1 if this flyable should auto-destrcut after that may ticks.
Definition: flyable.hpp:158
bool m_adjust_up_velocity
If this flag is set, the up velocity of the kart will not be adjusted in case that the objects is too...
Definition: flyable.hpp:57
void setHasHit()
Indicates that something was hit and that this object must be removed.
Definition: flyable.hpp:230
PowerupManager::PowerupType m_type
Type of the powerup.
Definition: flyable.hpp:85
uint16_t m_ticks_since_thrown
Time since thrown.
Definition: flyable.hpp:113
static scene::IMesh * m_st_model[PowerupManager::POWERUP_MAX]
The mesh of this Flyable.
Definition: flyable.hpp:142
void createPhysics(float y_offset, const Vec3 &velocity, btCollisionShape *shape, float restitution, const btVector3 &gravity=btVector3(0.0f, 0.0f, 0.0f), const bool rotates=false, const bool turn_around=false, const btTransform *customDirection=NULL)
init bullet for moving objects like projectiles
Definition: flyable.cpp:126
bool m_do_terrain_info
If this variable is set to true (which is the default) flyable will update the height of terrain when...
Definition: flyable.hpp:70
AbstractKart * m_owner
Kart which shot this flyable.
Definition: flyable.hpp:81
float m_max_height
Maximum height above terrain.
Definition: flyable.hpp:91
static Vec3 m_st_extend[PowerupManager::POWERUP_MAX]
Size of the model.
Definition: flyable.hpp:154
void setAdjustUpVelocity(bool f)
If true the up velocity of the flyable will be adjust so that the flyable stays at a height close to ...
Definition: flyable.hpp:213
Vec3 m_position_offset
An offset that is added when doing the raycast for terrain.
Definition: flyable.hpp:63
const float m_mass
Mass of this Flyable.
Definition: flyable.hpp:106
Vec3 m_extend
Size of this flyable.
Definition: flyable.hpp:109
bool hasHit()
Enables/disables adjusting ov velocity depending on height above terrain.
Definition: flyable.hpp:226
void setDoTerrainInfo(bool d)
Sets wether Flyable should update TerrainInfo as part of its update call, or if the inheriting object...
Definition: flyable.hpp:245
btCollisionShape * m_shape
Collision shape of this Flyable.
Definition: flyable.hpp:88
virtual void undoEvent(BareNetworkString *buffer) OVERRIDE
Called when an event needs to be undone.
Definition: flyable.hpp:252
AbstractKartAnimation * m_animation
If the flyable is in a cannon, this is the pointer to the cannon animation.
Definition: flyable.hpp:77
void getLinearKartItemIntersection(const Vec3 &origin, const AbstractKart *target_kart, float item_XY_velocity, float gravity, float forw_offset, float *fire_angle, float *up_velocity)
Returns information on the parameters needed to hit a target kart moving at constant velocity and dir...
Definition: flyable.cpp:330
void updateGraphics(float dt) OVERRIDE
Called once per rendered frame.
Definition: flyable.cpp:415
virtual void restoreState(BareNetworkString *buffer, int count) OVERRIDE
Called when a state needs to be replayed.
Definition: flyable.cpp:692
void reset() OVERRIDE
Resets this flyable.
Definition: flyable.hpp:233
virtual void hitTrack()
Called when this flyable hits the track.
Definition: flyable.hpp:221
float m_force_updown
Force pushing the Flyable up.
Definition: flyable.hpp:100
static float m_st_min_height[PowerupManager::POWERUP_MAX]
Minimum height above track.
Definition: flyable.hpp:145
virtual void computeError() OVERRIDE
Called when a rewind is finished, and is used to compute the error caused by the rewind (which is the...
Definition: flyable.cpp:756
virtual HitEffect * getHitEffect() const
Returns the hit effect object to use when this objects hits something.
Definition: flyable.cpp:631
static void init(const XMLNode &node, scene::IMesh *model, PowerupManager::PowerupType type)
Initialises the static members of this class for a certain type with default values and with settings...
Definition: flyable.cpp:198
bool hasAnimation() const
Returns if this flyable has an animation playing (e.g.
Definition: flyable.hpp:208
virtual void rewindToEvent(BareNetworkString *buffer) OVERRIDE
Called when an event needs to be replayed.
Definition: flyable.hpp:254
void getClosestKart(const AbstractKart **minKart, float *minDistSquared, Vec3 *minDelta, const AbstractKart *inFrontOf=NULL, const bool backwards=false) const
Returns information on what is the closest kart and at what distance it is.
Definition: flyable.cpp:251
virtual bool updateAndDelete(int ticks)
Updates this flyable.
Definition: flyable.cpp:427
A small interface for effects to be used when a kart is hit.
Definition: hit_effect.hpp:33
Definition: moveable.hpp:46
virtual void reset()
The reset position must be set before calling reset.
Definition: moveable.cpp:104
Definition: physical_object.hpp:40
Definition: rewinder.hpp:44
The base class for sound effects.
Definition: sfx_base.hpp:43
This class stores information about the triangle that's under an object, i.e.: the normal,...
Definition: terrain_info.hpp:32
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