mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-08-30 23:30:14 +00:00
51 lines
996 B
C++
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;
|
|
}
|
|
}
|