SuperTuxKart
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. More...
 
 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. More...
 
 ItemEventInfo (int ticks)
 Constructor for switching items. More...
 
 ItemEventInfo (BareNetworkString *buffer, int *count)
 Loads an event from a server message. More...
 
void saveState (BareNetworkString *buffer)
 Stores this event into a network string. More...
 
bool isNewItem () const
 Returns if this event represents a new item. More...
 
bool isItemCollection () const
 Returns true if this event represents collection of an item. More...
 
bool isSwitch () const
 Returns true if this event represent a switch usage. More...
 
int getIndex () const
 Returns the index of this item. More...
 
int getTicks () const
 Returns the time of the event in ticks. More...
 
int getKartId () const
 Returns the id of the kart that collected an item. More...
 
const Vec3getXYZ () const
 Returns the location of a new item. More...
 
const Vec3getNormal () const
 Returns the normal of a new item only. More...
 
int getTicksTillReturn () const
 Returns the ticks till return, used only by collection events. More...
 
ItemState::ItemType getNewItemType () const
 Returns the type of this item. More...
 

Private Types

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

Private Attributes

enum ItemEventInfo::EventType m_type
 
int m_ticks
 Time at which this event happens. More...
 
int m_index
 Index of this item in the item list. More...
 
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. More...
 
Vec3 m_xyz
 In case of new items the position of the new item. More...
 
Vec3 m_normal
 The normal of an item. More...
 
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. More...
 

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.

Member Enumeration Documentation

◆ EventType

Type of this event.

Constructor & Destructor Documentation

◆ ItemEventInfo() [1/4]

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/4]

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/4]

ItemEventInfo::ItemEventInfo ( int  ticks)
inline

Constructor for switching items.

◆ ItemEventInfo() [4/4]

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

◆ getIndex()

int ItemEventInfo::getIndex ( ) const
inline

Returns the index of this item.

◆ 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.

◆ getNormal()

const Vec3& ItemEventInfo::getNormal ( ) const
inline

Returns the normal of a new item only.

◆ getTicks()

int ItemEventInfo::getTicks ( ) const
inline

Returns the time of the event in ticks.

◆ getTicksTillReturn()

int ItemEventInfo::getTicksTillReturn ( ) const
inline

Returns the ticks till return, used only by collection events.

◆ 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.

◆ isItemCollection()

bool ItemEventInfo::isItemCollection ( ) const
inline

Returns true if this event represents collection of an item.

◆ isNewItem()

bool ItemEventInfo::isNewItem ( ) const
inline

Returns if this event represents a new item.

◆ isSwitch()

bool ItemEventInfo::isSwitch ( ) const
inline

Returns true if this event represent a switch usage.

◆ 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).

◆ m_kart_id

int ItemEventInfo::m_kart_id
private

The kart id that collected an item if >=0; if -1 it indicates a new item, and a -2 indicates a switch being used.

◆ m_normal

Vec3 ItemEventInfo::m_normal
private

The normal of an item.

◆ m_ticks

int ItemEventInfo::m_ticks
private

Time at which this event happens.

◆ m_ticks_till_return

int16_t ItemEventInfo::m_ticks_till_return
private

Ticks for the item to return, atm used by collecting banana with bomb to delay the return for banana.

◆ m_xyz

Vec3 ItemEventInfo::m_xyz
private

In case of new items the position of the new item.


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