|
| LEAK_CHECK () |
|
| PowerupManager () |
| The constructor initialises everything to zero.
|
|
| ~PowerupManager () |
| Destructor, frees all meshes.
|
|
void | loadPowerupsModels () |
| Loads powerups models and icons from the powerup.xml file.
|
|
void | loadWeights (const XMLNode *node, const std::string &category) |
| Loads the powerups weights for a given category (race, ft, ...).
|
|
void | unloadPowerups () |
| Removes any textures so that they can be reloaded.
|
|
void | computeWeightsForRace (int num_karts) |
| Create a (potentially interpolated) WeightsData objects for the current race based on the number of karts.
|
|
void | loadPowerup (PowerupType type, const XMLNode &node) |
| Loads the data for one particular powerup.
|
|
PowerupManager::PowerupType | getRandomPowerup (unsigned int pos, unsigned int *n, uint64_t random_number) |
| Returns a random powerup for a kart at a given position.
|
|
Material * | getIcon (int type) const |
| Returns the icon(material) for a powerup.
|
|
irr::scene::IMesh * | getMesh (int type) const |
| Returns the mesh for a certain powerup.
|
|
uint64_t | getRandomSeed () const |
|
void | setRandomSeed (uint64_t seed) |
|
This class manages all powerups.
It reads in powerup.xml to get the data, initialise the static member of some flyables (i.e. powerup.xml contains info about cakes, plunger etc which needs to be stored), and maintains the 'weights' (used in randomly chosing which item was collected) for all items depending on position. The latter is done so that as the first player you get less advantageous items (but no useless ones either), while as the last you get more useful ones.
The weights distribution is described in the powerup.xml file in more detail. All weights are stored in the m_all_weights data structure, which maps the race mode (race, battle, ...) to a list of WeightsData instances. Each WeightsData instance stores the data for one specific number of karts. E.g. m_all_weights['race'] contains 5 WeightsData instances for 1, 5, 9, 14, and 20 karts. At race start a new instance of WeightsData is created in m_current_item_weights. It contains the interpolated values for the number of karts in the current race (e.g. if the race is with 6 karts if will use 3/4 the weights for 5 karts, and 1/4 the weights for 9 karts. Then m_current_item_weights will create a weight distribution for each possible rank in the race (1 to 6 in the example above). This is the interpolation of the values within one WeightsData. Atm there are also 5 entries in that list (though it does not have to be the same number as above - i.e. the 1, 5, 9, 14, 20 weights list). Similarly the actual distribution used for a kart with a specific rank is based on dividing the available ranks (so 6 karts --> 6 ranks). With the 5 specified values the first entry is used for rank 1, the last entry for rank 6, and ranks 2-5 will be interpolated based on an equal distance: in a race with 6 karts for example, the 2nd weight list is used for rank 2.25, the 3nd for rank 3.5, the 4th for rank 4.75 (and the first and last for rank 1 and 6). It does not matter that the ranks are non integer: the actual weights used for say rank 2, will then be interplated between the weights of rank 1 and 2.25 (e.g. 0.8*weights_for 2.25 + 0.2*weights_for 1).