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,32 +378,36 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool weaponsLoaded =
|
||||||
|
std::all_of(x144_weapons.cbegin(), x144_weapons.cend(), [](const auto& weapon) { return weapon.IsLoaded(); });
|
||||||
|
if (!weaponsLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool frozenLoaded = std::all_of(x188_frozenEffects.cbegin(), x188_frozenEffects.cend(),
|
||||||
|
[](const auto& effect) { return effect.IsLoaded(); });
|
||||||
|
if (!frozenLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!x160_xferEffect.IsLoaded()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (loaded) {
|
|
||||||
if ((x210_loadFlags & 0x2) != 0x2) {
|
if ((x210_loadFlags & 0x2) != 0x2) {
|
||||||
LoadMuzzleFx(dt);
|
LoadMuzzleFx(dt);
|
||||||
x210_loadFlags |= 0x2;
|
x210_loadFlags |= 0x2;
|
||||||
|
@ -416,8 +418,6 @@ void CGunWeapon::LoadFxIdle(float dt, CStateManager& mgr) {
|
||||||
x210_loadFlags |= 0x4;
|
x210_loadFlags |= 0x4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGunWeapon::Update(float dt, CStateManager& mgr) {
|
void CGunWeapon::Update(float dt, CStateManager& mgr) {
|
||||||
if (x218_26_loaded) {
|
if (x218_26_loaded) {
|
||||||
|
|
Loading…
Reference in New Issue