Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Plunger Class Reference
Inheritance diagram for Plunger:
Inheritance graph

Public Member Functions

 Plunger (AbstractKart *kart)
virtual bool updateAndDelete (int ticks) OVERRIDE
 Updates the plunger in each frame. More...
virtual void hitTrack () OVERRIDE
 Called when the plunger hits the track. More...
virtual bool hit (AbstractKart *kart, PhysicalObject *obj=NULL) OVERRIDE
 Virtual function called when the plunger hits something. More...
void updateGraphics (float dt) OVERRIDE
 Called once per rendered frame. More...
void setKeepAlive (int16_t ticks)
 Sets the keep-alive value. More...
virtual HitEffectgetHitEffect () const OVERRIDE
 No hit effect when it ends. More...
virtual BareNetworkStringsaveState (std::vector< std::string > *ru) OVERRIDE
 Provides a copy of the state of the object in one memory buffer. More...
virtual void restoreState (BareNetworkString *buffer, int count) OVERRIDE
 Called when a state needs to be replayed. More...
virtual void onFireFlyable () OVERRIDE
 Call when the item is (re-)fired (during rewind if needed) by projectile_manager. More...
virtual void onDeleteFlyable () OVERRIDE
- Public Member Functions inherited from Flyable
 Flyable (AbstractKart *kart, PowerupManager::PowerupType type, float mass=1.0f)
virtual void setAnimation (AbstractKartAnimation *animation)
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 shooter hits the shooter). More...
void explode (AbstractKart *kart, PhysicalObject *obj=NULL, bool secondary_hits=true)
 Creates the explosion physical effect, i.e. More...
unsigned int getOwnerId ()
bool hasAnimation () const
 Returns if this flyable has an animation playing (e.g. More...
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 the average height. More...
void setPositionOffset (const Vec3 &o)
 Sets the offset to be used when determining the terrain under the flyable. More...
bool hasHit ()
 Enables/disables adjusting ov velocity depending on height above terrain. More...
void setHasHit ()
 Indicates that something was hit and that this object must be removed. More...
void reset () OVERRIDE
 Resets this flyable. More...
PowerupManager::PowerupType getType () const
 Returns the type of flyable. More...
AbstractKartgetOwner () const
 Returns the owner's kart.
void setDoTerrainInfo (bool d)
 Sets wether Flyable should update TerrainInfo as part of its update call, or if the inheriting object will update TerrainInfo itself (or perhaps not at all if it is not needed). More...
const Vec3getExtend () const
 Returns the size (extend) of the mesh. More...
void addForRewind (const std::string &uid)
virtual void undoEvent (BareNetworkString *buffer) OVERRIDE
 Called when an event needs to be undone. More...
virtual void rewindToEvent (BareNetworkString *buffer) OVERRIDE
 Called when an event needs to be replayed. More...
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). More...
virtual void saveTransform () OVERRIDE
 Called before a rewind. More...
virtual void computeError () OVERRIDE
 Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time). More...
bool hasServerState () const
void setCreatedTicks (int ticks)
- Public Member Functions inherited from Moveable
scene::ISceneNode * getNode () const
 Returns the scene node of this moveable. More...
void setNode (scene::ISceneNode *n)
 Sets the mesh for this model. More...
virtual const btVector3 & getVelocity () const
const btVector3 & getVelocityLC () const
virtual void setVelocity (const btVector3 &v)
const Vec3getXYZ () const
float getHeading () const
 Returns the heading between -pi and pi. More...
float getPitch () const
 Returns the pitch of the kart, restricted to between -pi/2 and pi/2. More...
float getRoll () const
 Returns the roll of the kart between -pi and pi. More...
const btQuaternion getRotation () const
virtual void flyUp ()
 Enter flying mode.
virtual void flyDown ()
virtual void stopFlying ()
virtual void setXYZ (const Vec3 &a)
 Sets the XYZ coordinates of the moveable. More...
void setRotation (const btMatrix3x3 &m)
 Sets the rotation of the physical body this moveable. More...
void setRotation (const btQuaternion &q)
 Sets the rotation of the physical body this moveable. More...
virtual void update (int ticks)
 Updates the current position and rotation from the corresponding physics body, and then calls updateGraphics to position the model correctly. More...
btRigidBody * getBody () const
void createBody (float mass, btTransform &trans, btCollisionShape *shape, float restitution)
 Creates the bullet rigid body for this moveable. More...
const btTransform & getTrans () const
void setTrans (const btTransform &t)
 Places this moveable at a certain location and stores this transform in this Moveable, so that it can be accessed easily. More...
void updatePosition ()
 Updates the current position and rotation. More...
void prepareSmoothing ()
void checkSmoothing ()
const btTransform & getSmoothedTrans () const
const Vec3getSmoothedXYZ () const
virtual const std::string & getIdent () const
- Public Member Functions inherited from SmoothNetworkBody
 SmoothNetworkBody (bool enable=false)
void reset ()
void setEnable (bool val)
bool isEnabled () const
void setSmoothRotation (bool val)
void setAdjustVerticalOffset (bool val)
void prepareSmoothing (const btTransform &current_transform, const Vec3 &current_velocity)
void checkSmoothing (const btTransform &current_transform, const Vec3 &current_velocity)
 Adds a new error between graphical and physical position/rotation. More...
void updateSmoothedGraphics (const btTransform &current_transform, const Vec3 &current_velocity, float dt)
void setSmoothedTransform (const btTransform &t)
const btTransform & getSmoothedTrans () const
const Vec3getSmoothedXYZ () const
void setMinAdjustLength (float val)
void setMaxAdjustLength (float val)
void setMinAdjustSpeed (float val)
void setMaxAdjustTime (float val)
void setAdjustLengthThreshold (float val)
- Public Member Functions inherited from TerrainInfo
 TerrainInfo ()
 Constructor to initialise terrain data.
 TerrainInfo (const Vec3 &pos)
 Constructor to initialise terrain data at a given position. More...
bool getSurfaceInfo (const Vec3 &from, Vec3 *position, const Material **m)
 Does a raycast upwards from the given position If the raycast indicated that the kart is 'under something' (i.e. More...
virtual void update (const btMatrix3x3 &rotation, const Vec3 &from)
 Update the terrain information based on the latest position. More...
virtual void update (const Vec3 &from)
 Update the terrain information based on the latest position. More...
virtual void update (const Vec3 &from, const Vec3 &towards)
 Update the terrain information based on the latest position. More...
virtual void update (const btMatrix3x3 &rotation)
 Simple wrapper with no offset. More...
float getHoT () const
 Returns the height of the terrain. More...
const MaterialgetMaterial () const
 Returns the current material the kart is on. More...
const MaterialgetLastMaterial () const
 Returns the previous material the kart was one (which might be the same as getMaterial() ). More...
const Vec3getNormal () const
 Returns the normal of the terrain the kart is on. More...
float getTerrainPitch (float heading) const
 Returns the pitch of the terrain depending on the heading. More...
const btVector3 & getHitPoint () const
 Returns the hit point of the raycast. More...
const Vec3getOrigin () const
- Public Member Functions inherited from Rewinder
 Rewinder (const std::string &ui="")
virtual std::function< void()> getLocalStateRestoreFunction ()
const std::string & getUniqueIdentity () const
bool rewinderAdd ()
 Add this object to the list of all rewindable objects in the rewind manager.
template<typename T >
std::shared_ptr< T > getShared ()

Static Public Member Functions

static void init (const XMLNode &node, scene::IMesh *missile)
- Static Public Member Functions inherited from Flyable
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 from powerup.xml. More...

Private Attributes

 The rubber band attached to a plunger. More...
int16_t m_keep_alive
 Ticks to keep the plunger alive while the rubber band is working. More...
btVector3 m_initial_velocity
bool m_reverse_mode
bool m_has_locally_played_sound
bool m_moved_to_infinity

Additional Inherited Members

- Protected Member Functions inherited from Flyable
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. More...
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 direction for a given speed in the XZ-plane. More...
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 More...
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 current game, and it will be deleted in computeError. More...
void removePhysics ()
- Protected Member Functions inherited from Moveable
void updateSmoothedGraphics (float dt)
virtual void updateGraphics (const Vec3 &off_xyz=Vec3(0.0f, 0.0f, 0.0f), const btQuaternion &off_rotation=btQuaternion(0.0f, 0.0f, 0.0f, 1.0f))
 Updates the graphics model. More...
- Protected Member Functions inherited from Rewinder
void setUniqueIdentity (const std::string &uid)
- Protected Attributes inherited from Flyable
 Kart which shot this flyable. More...
PowerupManager::PowerupType m_type
 Type of the powerup. More...
btCollisionShape * m_shape
 Collision shape of this Flyable. More...
float m_max_height
 Maximum height above terrain. More...
float m_min_height
 Minimum height above terrain. More...
float m_average_height
 Average of average of m_{min,ax}_height. More...
float m_force_updown
 Force pushing the Flyable up. More...
float m_speed
 Speed of this Flyable. More...
const float m_mass
 Mass of this Flyable. More...
Vec3 m_extend
 Size of this flyable. More...
uint16_t m_ticks_since_thrown
 Time since thrown. More...
bool m_has_server_state
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. More...
bool m_deleted_once
int m_last_deleted_ticks
int m_max_lifespan
 Set to something > -1 if this flyable should auto-destrcut after that may ticks. More...
int m_created_ticks
- Protected Attributes inherited from Moveable
btTransform m_transform
 The bullet transform of this rigid body. More...
UserPointer m_user_pointer
scene::ISceneNode * m_node
std::unique_ptr< btRigidBody > m_body
std::unique_ptr< KartMotionStatem_motion_state
- Static Protected Attributes inherited from Flyable
static float m_st_speed [PowerupManager::POWERUP_MAX]
 Speed of the projectile. More...
static scene::IMesh * m_st_model [PowerupManager::POWERUP_MAX]
 The mesh of this Flyable. More...
static float m_st_min_height [PowerupManager::POWERUP_MAX]
 Minimum height above track. More...
static float m_st_max_height [PowerupManager::POWERUP_MAX]
 Max height above track. More...
static float m_st_force_updown [PowerupManager::POWERUP_MAX]
 Force pushing up/down. More...
static Vec3 m_st_extend [PowerupManager::POWERUP_MAX]
 Size of the model. More...

Member Function Documentation

◆ getHitEffect()

virtual HitEffect* Plunger::getHitEffect ( ) const

No hit effect when it ends.

Reimplemented from Flyable.

◆ hit()

bool Plunger::hit ( AbstractKart kart,
PhysicalObject obj = NULL 

Virtual function called when the plunger hits something.

The plunger is special in that it is not deleted when hitting an object. Instead it stays around (though not as a graphical or physical object) till the rubber band expires.

kartPointer to the kart hit (NULL if not a kart).
objPointer to PhysicalObject object if hit (NULL otherwise).
True if there was actually a hit (i.e. not owner, and target is not immune), false otherwise.

Reimplemented from Flyable.

◆ hitTrack()

void Plunger::hitTrack ( )

Called when the plunger hits the track.

In this case, notify the rubber band, and remove the plunger (but keep it alive).

Reimplemented from Flyable.

◆ onFireFlyable()

void Plunger::onFireFlyable ( )

Call when the item is (re-)fired (during rewind if needed) by projectile_manager.

Reimplemented from Flyable.

◆ restoreState()

void Plunger::restoreState ( BareNetworkString buffer,
int  count 

Called when a state needs to be replayed.

This is called during rewind, i.e. when going forward in time again, and only for confirmed states.

Reimplemented from Flyable.

◆ saveState()

BareNetworkString * Plunger::saveState ( std::vector< std::string > *  ru)

Provides a copy of the state of the object in one memory buffer.

The memory is managed by the RewindManager.

[out]ruThe unique identity of rewinder writing to.
The address of the memory buffer with the state.

Reimplemented from Flyable.

◆ setKeepAlive()

void Plunger::setKeepAlive ( int16_t  ticks)

Sets the keep-alive value.

Setting it to 0 will remove the plunger at the next update - which is used if the rubber band snaps.

◆ updateAndDelete()

bool Plunger::updateAndDelete ( int  ticks)

Updates the plunger in each frame.

If this function returns true, the object will be removed by the projectile manager.

dtTime step size.
True of this object should be removed.

Reimplemented from Flyable.

◆ updateGraphics()

void Plunger::updateGraphics ( float  dt)

Called once per rendered frame.

It is used to only update any graphical effects.

dtTime step size (since last call).

Reimplemented from Flyable.

Member Data Documentation

◆ m_keep_alive

int16_t Plunger::m_keep_alive

Ticks to keep the plunger alive while the rubber band is working.

◆ m_rubber_band

RubberBand* Plunger::m_rubber_band

The rubber band attached to a plunger.

The documentation for this class was generated from the following files: