mirror of https://github.com/AxioDL/metaforce.git
CGunWeapon: Make use of algorithms where applicable
We can leverage these to also eliminate some hardcoded sizes.
This commit is contained in:
parent
c228baf5f7
commit
271ee6d8c3
|
@ -1,5 +1,6 @@
|
||||||
#include "Runtime/Weapon/CGunWeapon.hpp"
|
#include "Runtime/Weapon/CGunWeapon.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/CDependencyGroup.hpp"
|
#include "Runtime/CDependencyGroup.hpp"
|
||||||
|
@ -339,10 +340,7 @@ void CGunWeapon::LoadAnimations() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGunWeapon::IsAnimsLoaded() const {
|
bool CGunWeapon::IsAnimsLoaded() const {
|
||||||
for (const CToken& tok : x10c_anims)
|
return std::all_of(x10c_anims.cbegin(), x10c_anims.cend(), [](const auto& anim) { return anim.IsLoaded(); });
|
||||||
if (!tok.IsLoaded())
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGunWeapon::LoadMuzzleFx(float dt) {
|
void CGunWeapon::LoadMuzzleFx(float dt) {
|
||||||
|
@ -380,42 +378,44 @@ void CGunWeapon::LoadProjectileData(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGunWeapon::LoadFxIdle(float dt, CStateManager& mgr) {
|
void CGunWeapon::LoadFxIdle(float dt, CStateManager& mgr) {
|
||||||
if (NWeaponTypes::are_tokens_ready(x12c_deps)) {
|
if (!NWeaponTypes::are_tokens_ready(x12c_deps)) {
|
||||||
if ((x210_loadFlags & 0x2) != 0 && (x210_loadFlags & 0x4) != 0 && (x210_loadFlags & 0x10) != 0)
|
return;
|
||||||
return;
|
}
|
||||||
bool loaded = true;
|
|
||||||
for (int i = 0; i < 2; ++i) {
|
|
||||||
if (!x16c_muzzleEffects[i].IsLoaded()) {
|
|
||||||
loaded = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!x144_weapons[i].IsLoaded()) {
|
|
||||||
loaded = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i) {
|
if ((x210_loadFlags & 0x2) != 0 && (x210_loadFlags & 0x4) != 0 && (x210_loadFlags & 0x10) != 0) {
|
||||||
if (!x188_frozenEffects[i].IsLoaded()) {
|
return;
|
||||||
loaded = false;
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!x160_xferEffect.IsLoaded())
|
const bool muzzlesLoaded = std::all_of(x16c_muzzleEffects.cbegin(), x16c_muzzleEffects.cend(),
|
||||||
loaded = false;
|
[](const auto& muzzle) { return muzzle.IsLoaded(); });
|
||||||
|
if (!muzzlesLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (loaded) {
|
const bool weaponsLoaded =
|
||||||
if ((x210_loadFlags & 0x2) != 0x2) {
|
std::all_of(x144_weapons.cbegin(), x144_weapons.cend(), [](const auto& weapon) { return weapon.IsLoaded(); });
|
||||||
LoadMuzzleFx(dt);
|
if (!weaponsLoaded) {
|
||||||
x210_loadFlags |= 0x2;
|
return;
|
||||||
}
|
}
|
||||||
x210_loadFlags |= 0x10;
|
|
||||||
if ((x210_loadFlags & 0x4) != 0x4) {
|
const bool frozenLoaded = std::all_of(x188_frozenEffects.cbegin(), x188_frozenEffects.cend(),
|
||||||
LoadProjectileData(mgr);
|
[](const auto& effect) { return effect.IsLoaded(); });
|
||||||
x210_loadFlags |= 0x4;
|
if (!frozenLoaded) {
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!x160_xferEffect.IsLoaded()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((x210_loadFlags & 0x2) != 0x2) {
|
||||||
|
LoadMuzzleFx(dt);
|
||||||
|
x210_loadFlags |= 0x2;
|
||||||
|
}
|
||||||
|
x210_loadFlags |= 0x10;
|
||||||
|
if ((x210_loadFlags & 0x4) != 0x4) {
|
||||||
|
LoadProjectileData(mgr);
|
||||||
|
x210_loadFlags |= 0x4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue