|
SuperTuxKart
|
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. | |
| 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. | |
| 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. More... | |
| const Vec3 & | getXYZ () const |
| Returns the location of a new item. More... | |
| const Vec3 & | getNormal () 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. More... | |
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. 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. | |
| 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. | |
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.
|
inline |
Constructor for collecting an existing item.
| ticks | Time of the event. |
| item_id | The index of the item that was collected. |
| kart_id | the kart that collected the item. |
| ttr | Ticks till return after being collected. |
|
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::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.
| buffer | A network string with the event data. |
| count | The number of bytes read will be subtracted from this value. |
|
inline |
Returns the id of the kart that collected an item.
Only allowed to be called when this event is an item collection.
|
inline |
Returns the type of this item.
Note at this stage only bubble gums can be created during a race.
|
inline |
Returns the location of a new item.
Only allowed to be called when this is a new item event.
| void ItemEventInfo::saveState | ( | BareNetworkString * | buffer | ) |
Stores this event into a network string.
| buffer | The network string to which the data should be appended. |
|
private |
Index of this item in the item list.
Only used when creating new items (e.g. bubble gum).