SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
ItemEventInfo Class Reference

This class stores a delta, i.e. More...

#include <item_event_info.hpp>

Public Member Functions

 ItemEventInfo (int ticks, int index, int kart_id, int16_t ttr)
 Constructor for collecting an existing item.
 
 ItemEventInfo (int ticks, ItemState::ItemType type, int index, int kart_id, const Vec3 &xyz, const Vec3 &normal)
 Constructor for creating a new item (i.e.
 
 ItemEventInfo (int ticks)
 Constructor for switching items.
 
 ItemEventInfo (BareNetworkString *buffer, int *count)
 Loads an event from a server message.
 
void saveState (BareNetworkString *buffer)
 Stores this event into a network string.
 
bool isNewItem () const
 Returns if this event represents a new item.
 
bool isItemCollection () const
 Returns true if this event represents collection of an item.
 
bool isSwitch () const
 Returns true if this event represent a switch usage.
 
int getIndex () const
 Returns the index of this item.
 
int getTicks () const
 Returns the time of the event in ticks.
 
int getKartId () const
 Returns the id of the kart that collected an item.
 
const Vec3getXYZ () const
 Returns the location of a new item.
 
const Vec3getNormal () const
 Returns the normal of a new item only.
 
int getTicksTillReturn () const
 Returns the ticks till return, used only by collection events.
 
ItemState::ItemType getNewItemType () const
 Returns the type of this item.
 

Private Types

enum  EventType { IEI_COLLECT , IEI_NEW , IEI_SWITCH }
 Type of this event.
 

Private Attributes

enum ItemEventInfo::EventType m_type
 
int m_ticks
 Time at which this event happens.
 
int m_index
 Index of this item in the item list.
 
int m_kart_id
 The kart id that collected an item if >=0; if -1 it indicates a new item, and a -2 indicates a switch being used.
 
Vec3 m_xyz
 In case of new items the position of the new item.
 
Vec3 m_normal
 The normal of an item.
 
int16_t m_ticks_till_return
 Ticks for the item to return, atm used by collecting banana with bomb to delay the return for banana.
 

Detailed Description

This class stores a delta, i.e.

an item event (either collection of an item, adding a new item, or an item switch being activated). All those deltas will be applied to the confirmed state to get a new state.

Constructor & Destructor Documentation

◆ ItemEventInfo() [1/3]

ItemEventInfo::ItemEventInfo ( int  ticks,
int  index,
int  kart_id,
int16_t  ttr 
)
inline

Constructor for collecting an existing item.

Parameters
ticksTime of the event.
item_idThe index of the item that was collected.
kart_idthe kart that collected the item.
ttrTicks till return after being collected.

◆ ItemEventInfo() [2/3]

ItemEventInfo::ItemEventInfo ( int  ticks,
ItemState::ItemType  type,
int  index,
int  kart_id,
const Vec3 xyz,
const Vec3 normal 
)
inline

Constructor for creating a new item (i.e.

a bubble gum is dropped). At the moment only bubble gums can be droppes, so there is no need to encode the new item type.

◆ ItemEventInfo() [3/3]

ItemEventInfo::ItemEventInfo ( BareNetworkString buffer,
int *  count 
)

Loads an event from a server message.

It helps encapsulate the encoding of events from and into a message buffer.

Parameters
bufferA network string with the event data.
countThe number of bytes read will be subtracted from this value.

Member Function Documentation

◆ getKartId()

int ItemEventInfo::getKartId ( ) const
inline

Returns the id of the kart that collected an item.

Only allowed to be called when this event is an item collection.

◆ getNewItemType()

ItemState::ItemType ItemEventInfo::getNewItemType ( ) const
inline

Returns the type of this item.

Note at this stage only bubble gums can be created during a race.

◆ getXYZ()

const Vec3 & ItemEventInfo::getXYZ ( ) const
inline

Returns the location of a new item.

Only allowed to be called when this is a new item event.

◆ saveState()

void ItemEventInfo::saveState ( BareNetworkString buffer)

Stores this event into a network string.

Parameters
bufferThe network string to which the data should be appended.

Member Data Documentation

◆ m_index

int ItemEventInfo::m_index
private

Index of this item in the item list.

Only used when creating new items (e.g. bubble gum).


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