19#ifndef HEADER_ITEMMANAGER_HPP
20#define HEADER_ITEMMANAGER_HPP
22#include "LinearMath/btTransform.h"
24#include "items/item.hpp"
25#include "utils/aligned_array.hpp"
26#include "utils/no_copy.hpp"
27#include "utils/vec3.hpp"
56 static std::mt19937 m_random_engine;
58 static uint32_t m_random_seed;
64 static void updateRandomSeed(uint32_t seed_number)
66 m_random_engine.seed(seed_number);
67 m_random_seed = seed_number;
70 static uint32_t getRandomSeed()
143 const Vec3 *server_xyz = NULL,
144 const Vec3 *normal = NULL);
151 bool randomItemsForArena(
const AlignedArray<btTransform>& pos);
167 return (
unsigned int) m_all_items.size();
173 return dynamic_cast<Item*
>(m_all_items[n]);
179 return dynamic_cast<Item*
>(m_all_items[n]);
182 bool itemExists(
const ItemState* is)
const
186 auto it = std::find(m_all_items.begin(), m_all_items.end(), is);
187 return it != m_all_items.end();
195 assert(n<(*m_items_in_quads).size());
204 assert(n < m_items_in_quads->size());
207 :
dynamic_cast<Item*
>((*m_items_in_quads)[n].front());
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: item_manager.hpp:47
std::vector< ItemState * > AllItemTypes
The vector of all items of the current track.
Definition: item_manager.hpp:104
void updateGraphics(float dt)
Updates the graphics, called once per rendered frame.
Definition: item_manager.cpp:513
static void removeTextures()
Clean up all textures.
Definition: item_manager.cpp:146
unsigned int insertItem(Item *item)
Inserts the new item into the items management data structures, if possible reusing an existing,...
Definition: item_manager.cpp:232
static std::vector< scene::IMesh * > m_item_lowres_mesh
Stores all low-resolution item models.
Definition: item_manager.hpp:120
ItemManager()
Creates a new instance of the item manager.
Definition: item_manager.cpp:171
void reset()
Resets all items and removes bubble gum that is stuck on the track.
Definition: item_manager.cpp:434
std::vector< AllItemTypes > * m_items_in_quads
Stores which items are on which quad.
Definition: item_manager.hpp:114
void checkItemHit(AbstractKart *kart)
Checks if any item was collected by the given kart.
Definition: item_manager.cpp:389
static bool preloadIcon(const std::string &name)
Preload icon materials to avoid hangs when firstly insert item.
Definition: item_manager.cpp:132
void setSwitchItems(const std::vector< int > &switch_items)
Sets which objects is getting switched to what.
Definition: item_manager.cpp:202
static void disableItemCollection()
Disable item collection, useful to test client mispreditions or client/server disagreements.
Definition: item_manager.hpp:79
void update(int ticks)
Updates all items, and handles switching items back if the switch time is over.
Definition: item_manager.cpp:479
void deleteItemInQuad(ItemState *item)
Removes an items from the items-in-quad list only.
Definition: item_manager.cpp:541
virtual void setItemConfirmationTime(std::weak_ptr< STKPeer > peer, int ticks)
Only used in the NetworkItemManager.
Definition: item_manager.hpp:158
static std::vector< video::SColorf > m_glow_color
Stores the glow color for all items.
Definition: item_manager.hpp:51
const AllItemTypes & getItemsInQuads(unsigned int n) const
Returns a reference to the array of all items on the specified quad.
Definition: item_manager.hpp:192
virtual void collectedItem(ItemState *item, AbstractKart *kart)
Set an item as collected.
Definition: item_manager.cpp:375
void insertItemInQuad(Item *item)
Insert into the appropriate quad list, if there is a quad list (i.e.
Definition: item_manager.cpp:258
bool areItemsSwitched()
Returns true if the items are switched atm.
Definition: item_manager.hpp:155
unsigned int getNumberOfItems() const
Returns the number of items.
Definition: item_manager.hpp:165
void deleteItem(ItemState *item)
Removes an items from the items-in-quad list, from the list of all items, and then frees the item its...
Definition: item_manager.cpp:528
static bool m_disable_item_collection
Disable item collection (for debugging purposes).
Definition: item_manager.hpp:54
virtual Item * placeItem(ItemState::ItemType type, const Vec3 &xyz, const Vec3 &normal)
Places a new item on the track/arena.
Definition: item_manager.cpp:345
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.
Definition: item_manager.cpp:281
const ItemState * getItem(unsigned int n) const
Returns a pointer to the n-th item.
Definition: item_manager.hpp:171
static std::string getIcon(ItemState::ItemType type)
Returns the mesh for a certain item.
Definition: item_manager.hpp:94
static video::SColorf & getGlowColor(ItemState::ItemType type)
Returns the glow color for an item.
Definition: item_manager.hpp:98
virtual ~ItemManager()
Destructor.
Definition: item_manager.cpp:211
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 s...
Definition: item_manager.cpp:569
ItemState * getItem(unsigned int n)
Returns a pointer to the n-th item.
Definition: item_manager.hpp:177
static scene::IMesh * getItemLowResolutionModel(ItemState::ItemType type)
Returns the low resolution mesh for a certain item.
Definition: item_manager.hpp:90
std::vector< ItemState::ItemType > m_switch_to
What item this item is switched to.
Definition: item_manager.hpp:108
static scene::IMesh * getItemModel(ItemState::ItemType type)
Returns the mesh for a certain item.
Definition: item_manager.hpp:86
static std::vector< std::string > m_icon
Stores all item models.
Definition: item_manager.hpp:123
static void loadDefaultItemMeshes()
Loads the default item meshes (high- and low-resolution).
Definition: item_manager.cpp:60
static std::vector< scene::IMesh * > m_item_mesh
Stores all item models.
Definition: item_manager.hpp:117
Item * getFirstItemInQuad(unsigned int n) const
Returns the first item (NULL if none) on the specified quad.
Definition: item_manager.hpp:201
virtual void switchItems()
Switches all items: boxes become bananas and vice versa for a certain amount of time (as defined in s...
Definition: item_manager.cpp:560
int m_switch_ticks
Remaining time that items should remain switched.
Definition: item_manager.hpp:128
Contains the state information of an item, i.e.
Definition: item.hpp:53
ItemType
The list of all items.
Definition: item.hpp:62
The main kart class.
Definition: kart.hpp:69
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:76
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35