SuperTuxKart
|
Public Member Functions | |
ItemManager () | |
Creates a new instance of the item manager. | |
virtual | ~ItemManager () |
Destructor. | |
virtual Item * | placeItem (ItemState::ItemType type, const Vec3 &xyz, const Vec3 &normal) |
Places a new item on the track/arena. | |
virtual Item * | dropNewItem (ItemState::ItemType type, const AbstractKart *parent, const Vec3 *server_xyz=NULL, const Vec3 *normal=NULL) |
Creates a new item at the location of the kart (e.g. | |
void | update (int ticks) |
Updates all items, and handles switching items back if the switch time is over. | |
void | updateGraphics (float dt) |
Updates the graphics, called once per rendered frame. | |
void | checkItemHit (AbstractKart *kart) |
Checks if any item was collected by the given kart. | |
void | reset () |
Resets all items and removes bubble gum that is stuck on the track. | |
virtual void | collectedItem (ItemState *item, AbstractKart *kart) |
Set an item as collected. | |
virtual void | switchItems () |
Switches all items: boxes become bananas and vice versa for a certain amount of time (as defined in stk_config.xml). | |
bool | randomItemsForArena (const AlignedArray< btTransform > &pos) |
bool | areItemsSwitched () |
Returns true if the items are switched atm. | |
virtual void | setItemConfirmationTime (std::weak_ptr< STKPeer > peer, int ticks) |
Only used in the NetworkItemManager. | |
unsigned int | getNumberOfItems () const |
Returns the number of items. | |
const ItemState * | getItem (unsigned int n) const |
Returns a pointer to the n-th item. | |
ItemState * | getItem (unsigned int n) |
Returns a pointer to the n-th item. | |
bool | itemExists (const ItemState *is) const |
const AllItemTypes & | getItemsInQuads (unsigned int n) const |
Returns a reference to the array of all items on the specified quad. | |
Item * | getFirstItemInQuad (unsigned int n) const |
Returns the first item (NULL if none) on the specified quad. | |
unsigned int | insertItem (Item *item) |
Inserts the new item into the items management data structures, if possible reusing an existing, unused entry (e.g. | |
Static Public Member Functions | |
static void | loadDefaultItemMeshes () |
Loads the default item meshes (high- and low-resolution). | |
static void | removeTextures () |
Clean up all textures. | |
static void | updateRandomSeed (uint32_t seed_number) |
static uint32_t | getRandomSeed () |
static void | disableItemCollection () |
Disable item collection, useful to test client mispreditions or client/server disagreements. | |
static scene::IMesh * | getItemModel (ItemState::ItemType type) |
Returns the mesh for a certain item. | |
static scene::IMesh * | getItemLowResolutionModel (ItemState::ItemType type) |
Returns the low resolution mesh for a certain item. | |
static std::string | getIcon (ItemState::ItemType type) |
Returns the mesh for a certain item. | |
static video::SColorf & | getGlowColor (ItemState::ItemType type) |
Returns the glow color for an item. | |
Protected Types | |
typedef std::vector< ItemState * > | AllItemTypes |
The vector of all items of the current track. | |
Protected Member Functions | |
void | deleteItem (ItemState *item) |
Removes an items from the items-in-quad list, from the list of all items, and then frees the item itself. | |
void | switchItemsInternal (std::vector< ItemState * > &all_items) |
Switches all items: boxes become bananas and vice versa for a certain amount of time (as defined in stk_config.xml). | |
void | setSwitchItems (const std::vector< int > &switch_items) |
Sets which objects is getting switched to what. | |
void | insertItemInQuad (Item *item) |
Insert into the appropriate quad list, if there is a quad list (i.e. | |
void | deleteItemInQuad (ItemState *item) |
Removes an items from the items-in-quad list only. | |
Protected Attributes | |
AllItemTypes | m_all_items |
std::vector< ItemState::ItemType > | m_switch_to |
What item this item is switched to. | |
int | m_switch_ticks |
Remaining time that items should remain switched. | |
Static Private Member Functions | |
static bool | preloadIcon (const std::string &name) |
Preload icon materials to avoid hangs when firstly insert item. | |
Private Attributes | |
std::vector< AllItemTypes > * | m_items_in_quads |
Stores which items are on which quad. | |
ItemManager::ItemManager | ( | ) |
Creates a new instance of the item manager.
This is done at startup of each race.
|
virtual |
Destructor.
Cleans up all items and meshes stored.
void ItemManager::checkItemHit | ( | AbstractKart * | kart | ) |
Checks if any item was collected by the given kart.
This function calls collectedItem if an item was collected.
kart | Pointer to the kart. |
Disable item collection detection for debug purposes.
|
virtual |
Set an item as collected.
This function is called on the server when an item is collected, or on the client upon receiving information about collected items.
item | The item that was collected. |
kart | The kart that collected the item. |
Reimplemented in NetworkItemManager.
|
protected |
Removes an items from the items-in-quad list, from the list of all items, and then frees the item itself.
The | item to delete. |
|
protected |
Removes an items from the items-in-quad list only.
The | item to delete. |
|
virtual |
Creates a new item at the location of the kart (e.g.
kart drops a bubblegum).
type | Type of the item. |
kart | The kart that drops the new item. |
server_xyz | Can be used to overwrite the item location. |
server_normal | The normal as seen on the server. |
Reimplemented in NetworkItemManager.
unsigned int ItemManager::insertItem | ( | Item * | item | ) |
Inserts the new item into the items management data structures, if possible reusing an existing, unused entry (e.g.
due to a removed bubble gum). Then the item is also added to the quad-wise list of items.
item | The item to be added. |
|
protected |
Insert into the appropriate quad list, if there is a quad list (i.e.
race mode has a quad graph).
|
virtual |
Places a new item on the track/arena.
It is used for the initial placement of the items - either according to the scene.xml file, or random item placement.
type | Type of the item. |
xyz | Position of the item. |
normal | The normal of the terrain to set roll and pitch. |
|
static |
Clean up all textures.
This is necessary when switching resolution etc.
void ItemManager::reset | ( | ) |
Resets all items and removes bubble gum that is stuck on the track.
This is done when a race is (re)started.
|
inlinevirtual |
Only used in the NetworkItemManager.
Reimplemented in NetworkItemManager.
|
protected |
Sets which objects is getting switched to what.
switch | A mapping of items types to item types for the mapping. must contain one entry for each item. |
|
virtual |
Switches all items: boxes become bananas and vice versa for a certain amount of time (as defined in stk_config.xml).
Reimplemented in NetworkItemManager.
void ItemManager::update | ( | int | ticks | ) |
Updates all items, and handles switching items back if the switch time is over.
ticks | Number of physics time steps - should be 1. |
void ItemManager::updateGraphics | ( | float | dt | ) |
Updates the graphics, called once per rendered frame.
dt | Time based on frame rate. |
|
private |
Stores which items are on which quad.
m_items_in_quads[#quads] contains all items that are not on a quad. Note that this field is undefined if no Graph exist, e.g. arena without navmesh.
|
protected |
Remaining time that items should remain switched.
If the value is <0, it indicates that the items are not switched atm.