mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-06 10:25:53 +00:00
More CThardus imps, add CRandom16 stats
This commit is contained in:
parent
7ba02f28c0
commit
1ba68175e9
@ -120,6 +120,7 @@ void ViewManager::TestGameView::think() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overlayText += fmt::format(FMT_STRING("CRandom16::Next calls: {}\n"), urde::CRandom16::GetNumNextCalls());
|
||||||
if (m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean())
|
if (m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean())
|
||||||
overlayText += fmt::format(FMT_STRING("Resource Objects: {}\n"), g_SimplePool->GetLiveObjects());
|
overlayText += fmt::format(FMT_STRING("Resource Objects: {}\n"), g_SimplePool->GetLiveObjects());
|
||||||
|
|
||||||
|
@ -4,5 +4,11 @@ namespace urde {
|
|||||||
|
|
||||||
CRandom16* CRandom16::g_randomNumber = nullptr; // &DefaultRandom;
|
CRandom16* CRandom16::g_randomNumber = nullptr; // &DefaultRandom;
|
||||||
CGlobalRandom* CGlobalRandom::g_currentGlobalRandom = nullptr; //&DefaultGlobalRandom;
|
CGlobalRandom* CGlobalRandom::g_currentGlobalRandom = nullptr; //&DefaultGlobalRandom;
|
||||||
|
namespace {
|
||||||
|
u32 g_numNextCalls = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
void CRandom16::IncrementNumNextCalls() { ++g_numNextCalls; }
|
||||||
|
u32 CRandom16::GetNumNextCalls() { return g_numNextCalls; }
|
||||||
|
void CRandom16::ResetNumNextCalls() { g_numNextCalls = 0; }
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
@ -12,6 +12,7 @@ public:
|
|||||||
explicit CRandom16(s32 seed = 99) : m_seed(seed) {}
|
explicit CRandom16(s32 seed = 99) : m_seed(seed) {}
|
||||||
|
|
||||||
s32 Next() {
|
s32 Next() {
|
||||||
|
IncrementNumNextCalls();
|
||||||
m_seed = (m_seed * 0x41c64e6d) + 0x00003039;
|
m_seed = (m_seed * 0x41c64e6d) + 0x00003039;
|
||||||
return (m_seed >> 16) & 0xffff;
|
return (m_seed >> 16) & 0xffff;
|
||||||
}
|
}
|
||||||
@ -28,6 +29,9 @@ public:
|
|||||||
|
|
||||||
static CRandom16* GetRandomNumber() { return g_randomNumber; }
|
static CRandom16* GetRandomNumber() { return g_randomNumber; }
|
||||||
static void SetRandomNumber(CRandom16* rnd) { g_randomNumber = rnd; }
|
static void SetRandomNumber(CRandom16* rnd) { g_randomNumber = rnd; }
|
||||||
|
static void IncrementNumNextCalls();
|
||||||
|
static u32 GetNumNextCalls();
|
||||||
|
static void ResetNumNextCalls();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGlobalRandom {
|
class CGlobalRandom {
|
||||||
|
@ -2779,10 +2779,7 @@ void CStateManager::DeferStateTransition(EStateManagerTransition t) {
|
|||||||
|
|
||||||
bool CStateManager::CanShowMapScreen() const {
|
bool CStateManager::CanShowMapScreen() const {
|
||||||
const CHintOptions::SHintState* curDispHint = g_GameState->HintOptions().GetCurrentDisplayedHint();
|
const CHintOptions::SHintState* curDispHint = g_GameState->HintOptions().GetCurrentDisplayedHint();
|
||||||
if (curDispHint == nullptr || curDispHint->CanContinue()) {
|
return curDispHint == nullptr || curDispHint->CanContinue();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<u32, u32> CStateManager::CalculateScanCompletionRate() const {
|
std::pair<u32, u32> CStateManager::CalculateScanCompletionRate() const {
|
||||||
|
@ -880,6 +880,7 @@ void CMain::WarmupShaders() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
m_warmupIt = m_warmupTags.begin();
|
m_warmupIt = m_warmupTags.begin();
|
||||||
|
|
||||||
@ -887,6 +888,7 @@ void CMain::WarmupShaders() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CMain::Proc() {
|
bool CMain::Proc() {
|
||||||
|
CRandom16::ResetNumNextCalls();
|
||||||
// Warmup cycle overrides update
|
// Warmup cycle overrides update
|
||||||
if (m_warmupTags.size())
|
if (m_warmupTags.size())
|
||||||
return false;
|
return false;
|
||||||
|
@ -172,6 +172,7 @@ class CThardus : public CPatterned {
|
|||||||
}
|
}
|
||||||
|
|
||||||
zeus::CVector2f sub801dac30(CStateManager& mgr) const;
|
zeus::CVector2f sub801dac30(CStateManager& mgr) const;
|
||||||
|
void sub801db148(CStateManager& mgr) const {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_PATTERNED(Thardus);
|
DEFINE_PATTERNED(Thardus);
|
||||||
|
@ -1,6 +1,21 @@
|
|||||||
#include "Runtime/MP1/World/CThardusRockProjectile.hpp"
|
#include "Runtime/MP1/World/CThardusRockProjectile.hpp"
|
||||||
|
|
||||||
|
#include "Runtime/Camera/CCameraManager.hpp"
|
||||||
|
#include "Runtime/Camera/CFirstPersonCamera.hpp"
|
||||||
|
#include "Runtime/CStateManager.hpp"
|
||||||
|
#include "Runtime/Collision/CJointCollisionDescription.hpp"
|
||||||
|
#include "Runtime/World/CPlayer.hpp"
|
||||||
|
|
||||||
|
#include "Runtime/MP1/World/CThardus.hpp"
|
||||||
|
|
||||||
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
||||||
namespace urde::MP1 {
|
namespace urde::MP1 {
|
||||||
|
namespace {
|
||||||
|
constexpr std::array<SSphereJointInfo, 1> skRockCollisions{{
|
||||||
|
{"Rock_01_Collision_LCTR", 1.5f},
|
||||||
|
}};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
CThardusRockProjectile::CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
CThardusRockProjectile::CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
||||||
const zeus::CTransform& xf, CModelData&& modelData,
|
const zeus::CTransform& xf, CModelData&& modelData,
|
||||||
const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
||||||
@ -11,4 +26,97 @@ CThardusRockProjectile::CThardusRockProjectile(TUniqueId uid, std::string_view n
|
|||||||
EKnockBackVariant::Medium)
|
EKnockBackVariant::Medium)
|
||||||
, x57c_(std::move(mDataVec)) {}
|
, x57c_(std::move(mDataVec)) {}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::Think(float dt, CStateManager& mgr) {
|
||||||
|
if (!GetActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPatterned::Think(dt, mgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) {
|
||||||
|
CPatterned::AcceptScriptMsg(msg, other, mgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::Render(CStateManager& mgr) { CPatterned::Render(mgr); }
|
||||||
|
|
||||||
|
void CThardusRockProjectile::Patrol(CStateManager& mgr, EStateMsg msg, float dt) {
|
||||||
|
if (msg != EStateMsg::Update) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetBodyController()->GetCommandMgr().DeliverCmd(
|
||||||
|
CBCLocomotionCmd(zeus::skZero3f, (mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized(), 1.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::Dead(CStateManager& mgr, EStateMsg msg, float dt) {
|
||||||
|
if (msg != EStateMsg::Activate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mgr.FreeScriptObject(GetUniqueId());
|
||||||
|
SendScriptMsgs(EScriptObjectState::MassiveDeath, mgr, EScriptObjectMessage::None);
|
||||||
|
GenerateDeathExplosion(mgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::LoopedAttack(CStateManager& mgr, EStateMsg msg, float dt) {
|
||||||
|
if (msg == EStateMsg::Activate) {
|
||||||
|
x5a4_ = true;
|
||||||
|
} else if (msg == EStateMsg::Update) {
|
||||||
|
zeus::CVector3f aimPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f);
|
||||||
|
if (!x5bc_ || (aimPos - GetTranslation()).magSquared() <= x5c0_ * x5c0_) {
|
||||||
|
x5bc_ = false;
|
||||||
|
} else {
|
||||||
|
x5b0_ = x45c_steeringBehaviors.Arrival(*this, aimPos, 0.f);
|
||||||
|
x5bc_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::CVector3f movePos = x5b0_;
|
||||||
|
float radius = skRockCollisions[0].radius;
|
||||||
|
auto result = mgr.RayStaticIntersection(GetTranslation(), zeus::skDown, 100.f,
|
||||||
|
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));
|
||||||
|
|
||||||
|
if (result.IsValid()) {
|
||||||
|
movePos = (x45c_steeringBehaviors.Separation(*this, result.GetPoint(), 2.f * radius) + x5b0_).normalized();
|
||||||
|
}
|
||||||
|
GetBodyController()->GetCommandMgr().DeliverCmd(CBCLocomotionCmd{movePos, zeus::skZero3f, 1.f});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::GetUp(CStateManager& mgr, EStateMsg msg, float dt) {
|
||||||
|
if (msg == EStateMsg::Activate) {
|
||||||
|
x574_ = EAnimState::NotReady;
|
||||||
|
} else if (msg == EStateMsg::Update) {
|
||||||
|
auto result = mgr.RayStaticIntersection(GetTranslation(), zeus::skDown, 2.f,
|
||||||
|
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));
|
||||||
|
if (result.IsInvalid()) {
|
||||||
|
CThardus* thardus = static_cast<CThardus*>(mgr.ObjectById(x5d0_thardusId));
|
||||||
|
if (thardus != nullptr && !x5dc_) {
|
||||||
|
x5dc_ = true;
|
||||||
|
sub80203824(mgr, x5cc_, result.GetPoint(), GetModelData()->GetScale(), 0);
|
||||||
|
}
|
||||||
|
} else if (mgr.GetCameraManager()->GetCurrentCameraId() == mgr.GetCameraManager()->GetFirstPersonCamera()->GetUniqueId()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::Lurk(CStateManager& mgr, EStateMsg msg, float dt) { CAi::Lurk(mgr, msg, dt); }
|
||||||
|
|
||||||
|
bool CThardusRockProjectile::Delay(CStateManager& mgr, float arg) { return x5a8_ < x330_stateMachineState.GetTime(); }
|
||||||
|
|
||||||
|
bool CThardusRockProjectile::AnimOver(CStateManager& mgr, float arg) { return x574_ == EAnimState::Over; }
|
||||||
|
|
||||||
|
bool CThardusRockProjectile::ShouldAttack(CStateManager& mgr, float arg) {
|
||||||
|
if (x5ac_ < x330_stateMachineState.GetTime() && x56c_ != 3) {
|
||||||
|
x56c_ = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CThardusRockProjectile::HitSomething(CStateManager& mgr, float arg) { return x572_; }
|
||||||
|
|
||||||
|
bool CThardusRockProjectile::ShouldMove(CStateManager& mgr, float arg) { return x56c_ != 0; }
|
||||||
} // namespace urde::MP1
|
} // namespace urde::MP1
|
||||||
|
@ -4,25 +4,55 @@
|
|||||||
|
|
||||||
namespace urde::MP1 {
|
namespace urde::MP1 {
|
||||||
class CThardusRockProjectile : public CPatterned {
|
class CThardusRockProjectile : public CPatterned {
|
||||||
float x568_;
|
float x568_ = 1.f;
|
||||||
u32 x56c_ = 0;
|
u32 x56c_ = 0;
|
||||||
TUniqueId x570_ = kInvalidUniqueId;
|
TUniqueId x570_ = kInvalidUniqueId;
|
||||||
bool x572_ = false;
|
bool x572_ = false;
|
||||||
s32 x574_ = -1;
|
EAnimState x574_ = EAnimState::Invalid;
|
||||||
s32 x578_ = 0;
|
u32 x578_ = 0;
|
||||||
std::vector<std::unique_ptr<CModelData>> x57c_;
|
std::vector<std::unique_ptr<CModelData>> x57c_;
|
||||||
u32 x590_ = 0;
|
std::vector<TUniqueId> x58c_;
|
||||||
|
CAssetId x59c_stateMachine;
|
||||||
|
u32 x5a0_ = 0;
|
||||||
|
bool x5a4_ = true;
|
||||||
|
float x5a8_ = 0.f;
|
||||||
|
float x5ac_ = 0.f;
|
||||||
|
zeus::CVector3f x5b0_ = zeus::skForward;
|
||||||
|
bool x5bc_ = true;
|
||||||
|
float x5c0_;
|
||||||
|
u32 x5c4_ = 0;
|
||||||
|
u32 x5c8_ = 0;
|
||||||
|
u32 x5cc_ = 0;
|
||||||
|
TUniqueId x5d0_thardusId = kInvalidUniqueId;
|
||||||
|
u32 x5d4_ = 0;
|
||||||
|
u32 x5d8_ = 0;
|
||||||
|
bool x5dc_ = false;
|
||||||
|
bool x5dd_ = false;
|
||||||
|
void sub80203824(CStateManager& mgr, u32 w1, const zeus::CVector3f& pos, const zeus::CVector3f& scale, u32 w2) {}
|
||||||
public:
|
public:
|
||||||
DEFINE_PATTERNED(ThardusRockProjectile);
|
DEFINE_PATTERNED(ThardusRockProjectile);
|
||||||
CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||||
CModelData&& modelData, const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
CModelData&& modelData, const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
||||||
std::vector<std::unique_ptr<CModelData>>&& mDataVec, CAssetId, float);
|
std::vector<std::unique_ptr<CModelData>>&& mDataVec, CAssetId stateMachine, float);
|
||||||
|
|
||||||
|
void Think(float dt, CStateManager& mgr) override;
|
||||||
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) override;
|
||||||
|
void Render(CStateManager& mgr) override;
|
||||||
void sub80203d58() {
|
void sub80203d58() {
|
||||||
x328_25_verticalMovement = false;
|
x328_25_verticalMovement = false;
|
||||||
x150_momentum = {0.f, 0.f, 2.f * -GetWeight()};
|
x150_momentum = {0.f, 0.f, 2.f * -GetWeight()};
|
||||||
x56c_ = 3;
|
x56c_= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Patrol(CStateManager& mgr, EStateMsg msg, float dt) override;
|
||||||
|
void Dead(CStateManager& mgr, EStateMsg msg, float dt) override;
|
||||||
|
void LoopedAttack(CStateManager& mgr, EStateMsg msg, float dt) override;
|
||||||
|
void GetUp(CStateManager& mgr, EStateMsg msg, float dt) override;
|
||||||
|
void Lurk(CStateManager& mgr, EStateMsg msg, float dt) override;
|
||||||
|
bool Delay(CStateManager& mgr, float arg) override;
|
||||||
|
bool AnimOver(CStateManager& mgr, float arg) override;
|
||||||
|
bool ShouldAttack(CStateManager& mgr, float arg) override;
|
||||||
|
bool HitSomething(CStateManager& mgr, float arg) override;
|
||||||
|
bool ShouldMove(CStateManager& mgr, float arg) override;
|
||||||
};
|
};
|
||||||
} // namespace urde::MP1
|
} // namespace urde::MP1
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
enum class EBehaviourOrient { MoveDir, Constant, Destination };
|
enum class EBehaviourOrient { MoveDir, Constant, Destination };
|
||||||
enum class EBehaviourModifiers { Zero };
|
enum class EBehaviourModifiers { Zero };
|
||||||
enum class EPatrolState { Invalid = -1, Patrol, Pause, Done };
|
enum class EPatrolState { Invalid = -1, Patrol, Pause, Done };
|
||||||
enum class EAnimState { NotReady, Ready, Repeat, Over };
|
enum class EAnimState { NotReady, Ready, Repeat, Over, Invalid = -1 };
|
||||||
class CPatternNode {
|
class CPatternNode {
|
||||||
zeus::CVector3f x0_pos;
|
zeus::CVector3f x0_pos;
|
||||||
zeus::CVector3f xc_forward;
|
zeus::CVector3f xc_forward;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user