19#ifndef HEADER_POWERUPMANAGER_HPP
20#define HEADER_POWERUPMANAGER_HPP
22#include "utils/leak_check.hpp"
23#include "utils/no_copy.hpp"
26#include "btBulletDynamicsCommon.h"
37 namespace scene {
class IMesh; }
131 enum PowerupType {POWERUP_NOTHING,
133 POWERUP_BUBBLEGUM = POWERUP_FIRST,
135 POWERUP_BOWLING, POWERUP_ZIPPER, POWERUP_PLUNGER,
136 POWERUP_SWITCH, POWERUP_SWATTER, POWERUP_RUBBERBALL,
139 POWERUP_LAST=POWERUP_ANVIL,
171 PowerupManager::PowerupType
173 uint64_t random_number);
182 uint64_t getRandomSeed()
const {
return m_random_seed.load(); }
184 void setRandomSeed(uint64_t seed) {
m_random_seed.store(seed); }
Definition: material.hpp:48
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
This object stores all the weights for one particular number of karts.
Definition: powerup_manager.hpp:88
unsigned int m_num_karts
The number of karts for which this entry is to be used.
Definition: powerup_manager.hpp:91
std::vector< std::vector< unsigned > > m_summed_weights_for_rank
This field is only populated for the WeightData class that is used during a race.
Definition: powerup_manager.hpp:99
std::vector< std::vector< int > > m_weights_for_section
Stores for each of the sections the weights from the XML file.
Definition: powerup_manager.hpp:94
void setNumKarts(int num_karts)
Sets the number of karts.
Definition: powerup_manager.hpp:115
int getNumKarts() const
Returns for how many karts this entry is meant for.
Definition: powerup_manager.hpp:118
void convertRankToSection(int rank, int *prev, int *next, float *weight)
For a given rank in the current race this computes the previous and next entry in the weight list,...
Definition: powerup_manager.cpp:308
void readData(int num_karts, const XMLNode *node)
Reads in all weights for a given category and number of karts.
Definition: powerup_manager.cpp:219
int getRandomItem(int rank, uint64_t random_number)
Computes a random item dependent on the rank of the kart and a given random number.
Definition: powerup_manager.cpp:411
void precomputeWeights()
This function computes the item distribution for each possible rank in the race.
Definition: powerup_manager.cpp:380
void interpolate(WeightsData *prev, WeightsData *next, int num_karts)
Defines the weights for this WeightsData object based on a linear interpolation between the previous ...
Definition: powerup_manager.cpp:267
void reset()
Deletes all data stored in a WeightsData objects.
Definition: powerup_manager.cpp:207
This class manages all powerups.
Definition: powerup_manager.hpp:79
std::map< std::string, std::vector< WeightsData * > > m_all_weights
The first key is the race type: race, battle, soccer etc.
Definition: powerup_manager.hpp:126
Material * m_all_icons[POWERUP_MAX]
The icon for each powerup.
Definition: powerup_manager.hpp:146
WeightsData m_current_item_weights
The weight distribution to be used for the current race.
Definition: powerup_manager.hpp:153
void loadPowerupsModels()
Loads powerups models and icons from the powerup.xml file.
Definition: powerup_manager.cpp:126
void loadPowerup(PowerupType type, const XMLNode &node)
Loads the data for one particular powerup.
Definition: powerup_manager.cpp:453
void computeWeightsForRace(int num_karts)
Create a (potentially interpolated) WeightsData objects for the current race based on the number of k...
Definition: powerup_manager.cpp:519
void loadWeights(const XMLNode *node, const std::string &category)
Loads the powerups weights for a given category (race, ft, ...).
Definition: powerup_manager.cpp:179
PowerupManager::PowerupType getRandomPowerup(unsigned int pos, unsigned int *n, uint64_t random_number)
Returns a random powerup for a kart at a given position.
Definition: powerup_manager.cpp:601
Material * getIcon(int type) const
Returns the icon(material) for a powerup.
Definition: powerup_manager.hpp:176
PowerupManager()
The constructor initialises everything to zero.
Definition: powerup_manager.cpp:48
void unloadPowerups()
Removes any textures so that they can be reloaded.
Definition: powerup_manager.cpp:88
PowerupType getPowerupType(const std::string &name) const
Determines the powerup type for a given name.
Definition: powerup_manager.cpp:107
static void unitTesting()
Unit testing is based on deterministic item distributions: if all random numbers from 0 till sum_of_a...
Definition: powerup_manager.cpp:630
irr::scene::IMesh * getMesh(int type) const
Returns the mesh for a certain powerup.
Definition: powerup_manager.hpp:180
irr::scene::IMesh * m_all_meshes[POWERUP_MAX]
The mesh for each model (if the powerup has a model), e.g.
Definition: powerup_manager.hpp:150
std::atomic< uint64_t > m_random_seed
Seed for random powerup, for local game it will use a random number, for network games it will use th...
Definition: powerup_manager.hpp:159
~PowerupManager()
Destructor, frees all meshes.
Definition: powerup_manager.cpp:60
utility class used to parse XML files
Definition: xml_node.hpp:48
Declares the general types that are used by the network.