prime/src/MetroidPrime/CWeaponMgr.cpp
Henrique Gemignani Passos Lima c3e6ee87e3 Add CWeaponMgr
Former-commit-id: 28983db847f646224db4c80629c9a439d6fa1945
2022-11-10 04:06:24 +02:00

51 lines
996 B
C++

#include "MetroidPrime/CWeaponMgr.hpp"
CWeaponMgr::CWeaponMgr() {}
void CWeaponMgr::Remove(TUniqueId uid) {
rstl::map< TUniqueId, Vec >::iterator iter = x0_weapons.find(uid);
if (iter != x0_weapons.end()) {
x0_weapons.get_inner().erase(iter);
}
}
void CWeaponMgr::IncrCount(TUniqueId uid, EWeaponType type) {
Vec* vec = GetIndex(uid);
if (vec == nullptr) {
Add(uid, type);
} else {
(*vec)[type]++;
}
}
void CWeaponMgr::DecrCount(TUniqueId uid, EWeaponType type) {
Vec* vecP = GetIndex(uid);
if (!vecP) {
return;
}
Vec& vec = *vecP;
vec[type]--;
bool found = true;
rstl::reserved_vector< int, 15 >::iterator vit = vec.begin(), end = vec.end();
for (; vit != end; ++vit) {
if (*vit > 0) {
found = false;
break;
}
}
if (found) {
Remove(uid);
}
}
int CWeaponMgr::GetNumActive(TUniqueId uid, EWeaponType type) const {
Vec* vecP = GetIndex(uid);
if (vecP) {
return (*vecP)[type];
} else {
return 0;
}
}