mirror of https://github.com/AxioDL/metaforce.git
Minor fixes
This commit is contained in:
parent
7195b87ce6
commit
d29df977f3
|
@ -66,6 +66,8 @@ public:
|
|||
static void Swap8Bytes(u8* v);
|
||||
static int RecursiveMakeDir(const char* dir);
|
||||
static void MakeDir(const char* dir);
|
||||
static bool IsDir(const char* path);
|
||||
static bool IsFile(const char* path);
|
||||
static int Stat(const char* path, Sstat* statOut);
|
||||
};
|
||||
|
||||
|
|
|
@ -360,4 +360,18 @@ void CBasics::MakeDir(const char* dir) {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool CBasics::IsDir(const char* path) {
|
||||
Sstat theStat;
|
||||
Stat(path, &theStat);
|
||||
|
||||
return S_ISDIR(theStat.st_mode);
|
||||
}
|
||||
|
||||
bool CBasics::IsFile(const char* path) {
|
||||
Sstat theStat;
|
||||
Stat(path, &theStat);
|
||||
|
||||
return S_ISREG(theStat.st_mode);
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -197,9 +197,10 @@ public:
|
|||
#if TARGET_OS_IOS || TARGET_OS_TV
|
||||
m_deferredProject = std::string{m_fileMgr.getStoreRoot()} + "game.iso";
|
||||
#else
|
||||
bool inArg = false;
|
||||
for (int i = 1; i < m_argc; ++i) {
|
||||
std::string arg = m_argv[i];
|
||||
if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+'))
|
||||
if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+') && CBasics::IsDir(arg.c_str()))
|
||||
m_deferredProject = arg;
|
||||
else if (arg == "--no-sound")
|
||||
m_voiceEngine->setVolume(0.f);
|
||||
|
|
|
@ -222,7 +222,7 @@ float CMayaSpline::EvaluateAtUnclamped(float time) {
|
|||
}
|
||||
return EvaluateInfinities(time, true);
|
||||
} else if (x8_knots[lastIdx].GetTime() >= time) {
|
||||
bool bVar2 = false;
|
||||
bVar2 = false;
|
||||
s32 local_68 = -1;
|
||||
s32 iVar1 = x24_chachedKnotIndex;
|
||||
if (iVar1 != -1) {
|
||||
|
|
|
@ -196,7 +196,7 @@ public:
|
|||
virtual bool IsElitePirate() const { return true; }
|
||||
virtual void SetupHealthInfo(CStateManager& mgr);
|
||||
virtual void SetLaunchersActive(CStateManager& mgr, bool val);
|
||||
virtual SShockWaveData GetShockWaveData() const {
|
||||
virtual CShockWaveInfo GetShockWaveData() const {
|
||||
return {x5d8_data.GetShockwaveParticleDescId(), x5d8_data.GetShockwaveDamageInfo(), 16.5217f,
|
||||
x5d8_data.GetShockwaveWeaponDescId(), x5d8_data.GetShockwaveElectrocuteSfxId()};
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ void CMetroidPrimeEssence::DoUserAnimEvent(CStateManager& mgr, const CInt32POINo
|
|||
|
||||
switch (type) {
|
||||
case EUserEventType::EggLay: {
|
||||
if (x70e_29_ && x6d8_ != 0 && x6e4_ < x6f8_) {
|
||||
if (x70e_29_ && x6d8_ != 0 && x6e4_spawnedAiCount < x6f8_maxSpawnedCount) {
|
||||
const float ang1 = zeus::degToRad(22.5f) * mgr.GetActiveRandom()->Range(-1, 1);
|
||||
const float ang2 = zeus::degToRad(45.0f) * mgr.GetActiveRandom()->Range(-1, 1);
|
||||
zeus::CVector3f pos =
|
||||
|
@ -203,9 +203,9 @@ void CMetroidPrimeEssence::DoUserAnimEvent(CStateManager& mgr, const CInt32POINo
|
|||
return;
|
||||
}
|
||||
case EUserEventType::BeginAction: {
|
||||
SShockWaveData data(x660_, x698_, 2.f, x664_, x70c_);
|
||||
CShockWaveInfo data(x660_, x698_, 2.f, x664_, x70c_);
|
||||
data.SetSpeedIncrease(180.f);
|
||||
DropShockwave(mgr, data);
|
||||
CreateShockWave(mgr, data);
|
||||
ShakeCamera(mgr, 1.f);
|
||||
return;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ void CMetroidPrimeEssence::Skid(CStateManager& mgr, EStateMsg msg, float dt) {
|
|||
|
||||
void CMetroidPrimeEssence::FadeIn(CStateManager& mgr, EStateMsg msg, float dt) {
|
||||
if (msg == EStateMsg::Activate) {
|
||||
x6f8_ = sub8027d428();
|
||||
x6f8_maxSpawnedCount = GetMaxSpawnCount(mgr);
|
||||
x32c_animState = EAnimState::Ready;
|
||||
x70e_24_ = true;
|
||||
} else if (msg == EStateMsg::Update) {
|
||||
|
@ -537,7 +537,7 @@ void CMetroidPrimeEssence::ShakeCamera(CStateManager& mgr, float f1) {
|
|||
mgr.GetCameraManager()->AddCameraShaker(CCameraShakeData(0.5f, mag), true);
|
||||
}
|
||||
|
||||
void CMetroidPrimeEssence::DropShockwave(CStateManager& mgr, const SShockWaveData& shockWaveData) {
|
||||
void CMetroidPrimeEssence::CreateShockWave(CStateManager& mgr, const CShockWaveInfo& shockWaveData) {
|
||||
CRayCastResult res = RayStaticIntersection(mgr);
|
||||
if (res.IsInvalid()) {
|
||||
return;
|
||||
|
@ -616,7 +616,7 @@ void CMetroidPrimeEssence::CountListeningAi(CStateManager& mgr) {
|
|||
for (auto* ent : mgr.GetListeningAiObjectList()) {
|
||||
if (TCastToPtr<CPatterned> ai = ent) {
|
||||
if (ai != this && ai->GetActive() && ai->GetAreaIdAlways() == GetAreaIdAlways()) {
|
||||
++x6e4_;
|
||||
++x6e4_spawnedAiCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,12 @@ class CMetroidPrimeEssence : public CPatterned {
|
|||
u32 x6d8_ = 0;
|
||||
u32 x6dc_ = 0;
|
||||
u32 x6e0_ = x6dc_;
|
||||
u32 x6e4_ = 0;
|
||||
u32 x6e4_spawnedAiCount = 0;
|
||||
u32 x6e8_ = 2;
|
||||
u32 x6ec_ = 4;
|
||||
u32 x6f0_ = 0;
|
||||
u32 x6f4_ = x6e8_ - 1;
|
||||
u32 x6f8_ = 2;
|
||||
u32 x6f8_maxSpawnedCount = 2;
|
||||
u32 x6fc_ = 0;
|
||||
u32 x700_ = 1;
|
||||
TUniqueId x704_bossUtilityWaypointId = kInvalidUniqueId;
|
||||
|
@ -55,9 +55,9 @@ class CMetroidPrimeEssence : public CPatterned {
|
|||
void sub8027cee0(CStateManager& mgr);
|
||||
u32 sub8027cfd4(CStateManager& mgr, bool w1);
|
||||
void DoPhaseTransition(CStateManager& mgr);
|
||||
u32 sub8027d428() { return 2; /* Decided by fair dice roll, guaranteed to be random */ }
|
||||
u32 GetMaxSpawnCount(CStateManager& mgr) { return 2; }
|
||||
void ShakeCamera(CStateManager& mgr, float f1);
|
||||
void DropShockwave(CStateManager& mgr, const SShockWaveData& shockWaveData);
|
||||
void CreateShockWave(CStateManager& mgr, const CShockWaveInfo& shockWaveData);
|
||||
CRayCastResult RayStaticIntersection(CStateManager& mgr);
|
||||
void SetParticleEffectState(CStateManager& mgr, bool active);
|
||||
void sub8027d824(CStateManager& mgr);
|
||||
|
|
|
@ -271,7 +271,7 @@ SPrimeExoParameters::SPrimeExoParameters(CInputStream& in)
|
|||
, xa28_particle4(in.Get<CAssetId>())
|
||||
, xa2c_(LoadPrimeStruct6s(in)) {}
|
||||
|
||||
SPrimeExoRoomParameters::SPrimeExoRoomParameters(CInputStream& in) {
|
||||
CMetroidPrimeAttackWeights::CMetroidPrimeAttackWeights(CInputStream& in) {
|
||||
u32 propCount = std::min(14, in.ReadLong());
|
||||
for (u32 i = 0; i < propCount; ++i) {
|
||||
x0_.push_back(in.ReadFloat());
|
||||
|
@ -1292,7 +1292,7 @@ void CMetroidPrimeExo::sub802759a8(CStateManager& mgr, u32 w1) {
|
|||
}
|
||||
}
|
||||
|
||||
float CMetroidPrimeExo::sub80275b04(const SPrimeExoRoomParameters& roomParms, int w2) {
|
||||
float CMetroidPrimeExo::sub80275b04(const CMetroidPrimeAttackWeights& roomParms, int w2) {
|
||||
float dVar1 = 0.f;
|
||||
if (!zeus::close_enough(0.f, x1258_[w2])) {
|
||||
const float tmpFloat = roomParms.GetFloatValue(w2);
|
||||
|
|
|
@ -82,9 +82,9 @@ struct SPrimeExoParameters {
|
|||
explicit SPrimeExoParameters(CInputStream& in);
|
||||
};
|
||||
|
||||
struct SPrimeExoRoomParameters {
|
||||
struct CMetroidPrimeAttackWeights {
|
||||
rstl::reserved_vector<float, 14> x0_;
|
||||
explicit SPrimeExoRoomParameters(CInputStream& in);
|
||||
explicit CMetroidPrimeAttackWeights(CInputStream& in);
|
||||
|
||||
float GetFloatValue(size_t idx) const { return x0_[idx]; }
|
||||
};
|
||||
|
@ -191,7 +191,7 @@ class CMetroidPrimeExo : public CPatterned {
|
|||
float x1084_ = 0.f;
|
||||
float x1088_ = 0.f;
|
||||
CCameraShakeData x108c_;
|
||||
rstl::reserved_vector<SPrimeExoRoomParameters, 4> x1160_;
|
||||
rstl::reserved_vector<CMetroidPrimeAttackWeights, 4> x1160_;
|
||||
s32 x1254_ = -1;
|
||||
rstl::reserved_vector<float, 14> x1258_;
|
||||
CCameraShakeData x1294_;
|
||||
|
@ -222,7 +222,7 @@ class CMetroidPrimeExo : public CPatterned {
|
|||
void UpdateTimers(float mgr);
|
||||
void sub80275800(CStateManager& mgr);
|
||||
void sub802759a8(CStateManager& mgr, u32 w1);
|
||||
float sub80275b04(const SPrimeExoRoomParameters& roomParms, int w2);
|
||||
float sub80275b04(const CMetroidPrimeAttackWeights& roomParms, int w2);
|
||||
void sub80275b68();
|
||||
void sub80275c60(CStateManager& mgr, int w1);
|
||||
bool sub80275d68(int w1);
|
||||
|
|
|
@ -10,7 +10,7 @@ CMetroidPrimeRelay::CMetroidPrimeRelay(TUniqueId uid, std::string_view name, con
|
|||
const zeus::CTransform& xf, const zeus::CVector3f& scale,
|
||||
SPrimeExoParameters&& parms, float f1, float f2, float f3, u32 w1, bool b1,
|
||||
u32 w2, const CHealthInfo& hInfo1, const CHealthInfo& hInfo2, u32 w3, u32 w4,
|
||||
u32 w5, rstl::reserved_vector<SPrimeExoRoomParameters, 4>&& roomParms)
|
||||
u32 w5, rstl::reserved_vector<CMetroidPrimeAttackWeights, 4>&& roomParms)
|
||||
: CEntity(uid, info, active, name)
|
||||
, x38_xf(xf)
|
||||
, x68_scale(scale)
|
||||
|
|
|
@ -26,7 +26,7 @@ class CMetroidPrimeRelay : public CEntity {
|
|||
u32 xcac_w3;
|
||||
u32 xcb0_w4;
|
||||
u32 xcb4_w5;
|
||||
rstl::reserved_vector<SPrimeExoRoomParameters, 4> xcb8_roomParms;
|
||||
rstl::reserved_vector<CMetroidPrimeAttackWeights, 4> xcb8_roomParms;
|
||||
|
||||
void ForwardMessageToMetroidPrimeExo(EScriptObjectMessage msg, CStateManager& mgr);
|
||||
void GetOrBuildMetroidPrimeExo(CStateManager& mgr);
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
CMetroidPrimeRelay(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active,
|
||||
const zeus::CTransform& xf, const zeus::CVector3f& scale, SPrimeExoParameters&& parms, float f1,
|
||||
float f2, float f3, u32 w1, bool b1, u32 w2, const CHealthInfo& hInfo1, const CHealthInfo& hInfo2,
|
||||
u32 w3, u32 w4, u32 w5, rstl::reserved_vector<SPrimeExoRoomParameters, 4>&& roomParms);
|
||||
u32 w3, u32 w4, u32 w5, rstl::reserved_vector<CMetroidPrimeAttackWeights, 4>&& roomParms);
|
||||
void Accept(IVisitor& visitor) override;
|
||||
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override;
|
||||
[[nodiscard]] TUniqueId GetMetroidPrimeExoId() const { return x34_mpUid; }
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
[[nodiscard]] u32 Get_xcac() const { return xcac_w3; }
|
||||
[[nodiscard]] u32 Get_xcb0() const { return xcb0_w4; }
|
||||
[[nodiscard]] u32 Get_xcb4() const { return xcb4_w5; }
|
||||
[[nodiscard]] rstl::reserved_vector<SPrimeExoRoomParameters, 4> GetRoomParameters() const { return xcb8_roomParms; }
|
||||
[[nodiscard]] rstl::reserved_vector<CMetroidPrimeAttackWeights, 4> GetRoomParameters() const { return xcb8_roomParms; }
|
||||
};
|
||||
|
||||
} // namespace metaforce::MP1
|
||||
|
|
|
@ -161,7 +161,7 @@ public:
|
|||
bool IsElitePirate() const override { return false; }
|
||||
void SetupHealthInfo(CStateManager& mgr) override;
|
||||
void SetLaunchersActive(CStateManager& mgr, bool val) override;
|
||||
SShockWaveData GetShockWaveData() const override {
|
||||
CShockWaveInfo GetShockWaveData() const override {
|
||||
return {GetData().GetShockwaveParticleDescId(), GetData().GetShockwaveDamageInfo(), 24.78255f,
|
||||
GetData().GetShockwaveWeaponDescId(), GetData().GetShockwaveElectrocuteSfxId()};
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace metaforce::MP1 {
|
||||
CShockWave::CShockWave(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||
TUniqueId parent, const SShockWaveData& data, float minActiveTime, float knockback)
|
||||
TUniqueId parent, const CShockWaveInfo& data, float minActiveTime, float knockback)
|
||||
: CActor(uid, true, name, info, xf, CModelData::CModelDataNull(), {EMaterialTypes::Projectile},
|
||||
CActorParameters::None(), kInvalidUniqueId)
|
||||
, xe8_parentId(parent)
|
||||
|
@ -148,7 +148,7 @@ void CShockWave::Touch(CActor& actor, CStateManager& mgr) {
|
|||
if (isPlayer && (x164_timeSinceHitPlayerInAir >= 0.1333f || x168_timeSinceHitPlayer >= 0.2666f)) {
|
||||
return;
|
||||
}
|
||||
if (!IsHit(actor.GetUniqueId())) {
|
||||
if (!WasAlreadyDamaged(actor.GetUniqueId())) {
|
||||
mgr.ApplyDamage(GetUniqueId(), actor.GetUniqueId(), GetUniqueId(), damageInfo,
|
||||
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), zeus::skZero3f);
|
||||
if (isPlayer && x974_electricDesc) {
|
||||
|
@ -172,7 +172,7 @@ void CShockWave::Touch(CActor& actor, CStateManager& mgr) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CShockWave::IsHit(TUniqueId id) const {
|
||||
bool CShockWave::WasAlreadyDamaged(TUniqueId id) const {
|
||||
return std::find(x170_hitIds.begin(), x170_hitIds.end(), id) != x170_hitIds.end();
|
||||
}
|
||||
} // namespace metaforce::MP1
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Runtime/World/CDamageInfo.hpp"
|
||||
|
||||
namespace metaforce::MP1 {
|
||||
struct SShockWaveData {
|
||||
struct CShockWaveInfo {
|
||||
private:
|
||||
u32 x0_ = 8;
|
||||
CAssetId x4_particleDesc;
|
||||
|
@ -18,7 +18,7 @@ private:
|
|||
u16 x38_electrocuteSfx;
|
||||
|
||||
public:
|
||||
SShockWaveData(CAssetId part, const CDamageInfo& dInfo, float initialExpansionSpeed, CAssetId weapon, u16 sfx)
|
||||
CShockWaveInfo(CAssetId part, const CDamageInfo& dInfo, float initialExpansionSpeed, CAssetId weapon, u16 sfx)
|
||||
: x4_particleDesc(part)
|
||||
, x8_damageInfo(dInfo)
|
||||
, x2c_initialExpansionSpeed(initialExpansionSpeed)
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
CDamageInfo xec_damageInfo;
|
||||
TToken<CGenDescription> x108_elementGenDesc;
|
||||
std::unique_ptr<CElementGen> x110_elementGen;
|
||||
SShockWaveData x114_data;
|
||||
CShockWaveInfo x114_data;
|
||||
float x150_radius;
|
||||
float x154_expansionSpeed;
|
||||
float x158_activeTime = 0.f;
|
||||
|
@ -59,7 +59,7 @@ private:
|
|||
public:
|
||||
DEFINE_ENTITY
|
||||
CShockWave(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||
TUniqueId parent, const SShockWaveData& data, float minActiveTime, float knockback);
|
||||
TUniqueId parent, const CShockWaveInfo& data, float minActiveTime, float knockback);
|
||||
|
||||
void Accept(IVisitor& visitor) override;
|
||||
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
||||
|
@ -70,6 +70,6 @@ public:
|
|||
void Touch(CActor& actor, CStateManager& mgr) override;
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool IsHit(TUniqueId id) const;
|
||||
[[nodiscard]] bool WasAlreadyDamaged(TUniqueId id) const;
|
||||
};
|
||||
} // namespace metaforce::MP1
|
||||
|
|
|
@ -3704,7 +3704,7 @@ CEntity* ScriptLoader::LoadMetroidPrimeStage1(CStateManager& mgr, CInputStream&
|
|||
CHealthInfo hInfo1(in);
|
||||
CHealthInfo hInfo2(in);
|
||||
u32 w3 = in.ReadLong();
|
||||
rstl::reserved_vector<MP1::SPrimeExoRoomParameters, 4> roomParms;
|
||||
rstl::reserved_vector<MP1::CMetroidPrimeAttackWeights, 4> roomParms;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
roomParms.emplace_back(in);
|
||||
u32 w4 = in.ReadLong();
|
||||
|
|
Loading…
Reference in New Issue