Player: Implement PlayerJudgeDrawForward and PlayerJudgeDeadWipeStart (#72)

Co-authored-by: LynxDev2 <developer.iika@gmail.com>
This commit is contained in:
LynxDev2 2024-06-09 01:31:53 +07:00 committed by GitHub
parent 5d689911dd
commit 109c770d7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 167 additions and 11 deletions

2
.gitignore vendored
View file

@ -22,6 +22,8 @@ bin/
.cache/
.DS_Store
/cmake-build-*
compile_commands.json
.clangd
# IDA
*.id0

View file

@ -27803,13 +27803,13 @@ Address,Quality,Size,Name
0x0000007100458e88,U,000060,_ZNK23PlayerJudgeDeadSceneEnd5judgeEv
0x0000007100458ec4,U,000004,_ZN23PlayerJudgeDeadSceneEnd5resetEv
0x0000007100458ec8,U,000004,_ZN23PlayerJudgeDeadSceneEnd6updateEv
0x0000007100458ecc,U,000028,_ZN24PlayerJudgeDeadWipeStartC2EPKN2al9LiveActorEPK11PlayerConst
0x0000007100458ee8,U,000040,_ZNK24PlayerJudgeDeadWipeStart21isDeadTypeDrawForwardEv
0x0000007100458f10,U,000016,_ZNK24PlayerJudgeDeadWipeStart22isDeadEnableCoinAppearEv
0x0000007100458f20,U,000188,_ZNK24PlayerJudgeDeadWipeStart11getWipeInfoEPPKcPi
0x0000007100458fdc,U,000012,_ZN24PlayerJudgeDeadWipeStart5resetEv
0x0000007100458fe8,U,000052,_ZN24PlayerJudgeDeadWipeStart6updateEv
0x000000710045901c,U,000192,_ZNK24PlayerJudgeDeadWipeStart5judgeEv
0x0000007100458ecc,O,000028,_ZN24PlayerJudgeDeadWipeStartC2EPKN2al9LiveActorEPK11PlayerConst
0x0000007100458ee8,O,000040,_ZNK24PlayerJudgeDeadWipeStart21isDeadTypeDrawForwardEv
0x0000007100458f10,O,000016,_ZNK24PlayerJudgeDeadWipeStart22isDeadEnableCoinAppearEv
0x0000007100458f20,O,000188,_ZNK24PlayerJudgeDeadWipeStart11getWipeInfoEPPKcPi
0x0000007100458fdc,O,000012,_ZN24PlayerJudgeDeadWipeStart5resetEv
0x0000007100458fe8,O,000052,_ZN24PlayerJudgeDeadWipeStart6updateEv
0x000000710045901c,O,000192,_ZNK24PlayerJudgeDeadWipeStart5judgeEv
0x00000071004590dc,U,000036,_ZN24PlayerJudgeDirectRollingC1EPKN2al9LiveActorEPK11PlayerConstPK11PlayerInputPK19IUsePlayerCollisionPK19IPlayerModelChangerPK17PlayerCarryKeeperPK21PlayerCounterForceRun
0x0000007100459100,U,000008,_ZN24PlayerJudgeDirectRolling5resetEv
0x0000007100459108,U,000244,_ZN24PlayerJudgeDirectRolling6updateEv
@ -27818,10 +27818,10 @@ Address,Quality,Size,Name
0x0000007100459224,U,000468,_ZNK22PlayerJudgeDiveInWater5judgeEv
0x00000071004593f8,U,000004,_ZN22PlayerJudgeDiveInWater5resetEv
0x00000071004593fc,U,000004,_ZN22PlayerJudgeDiveInWater6updateEv
0x0000007100459400,U,000024,_ZN22PlayerJudgeDrawForwardC1EPKN2al9LiveActorEPK24PlayerJudgeDeadWipeStart
0x0000007100459418,U,000084,_ZNK22PlayerJudgeDrawForward5judgeEv
0x000000710045946c,U,000004,_ZN22PlayerJudgeDrawForward5resetEv
0x0000007100459470,U,000004,_ZN22PlayerJudgeDrawForward6updateEv
0x0000007100459400,O,000024,_ZN22PlayerJudgeDrawForwardC1EPKN2al9LiveActorEPK24PlayerJudgeDeadWipeStart
0x0000007100459418,O,000084,_ZNK22PlayerJudgeDrawForward5judgeEv
0x000000710045946c,O,000004,_ZN22PlayerJudgeDrawForward5resetEv
0x0000007100459470,O,000004,_ZN22PlayerJudgeDrawForward6updateEv
0x0000007100459474,U,000024,_ZN27PlayerJudgeEnableGuideArrowC2EPK12PlayerPuppet
0x000000710045948c,U,000064,_ZNK27PlayerJudgeEnableGuideArrow5judgeEv
0x00000071004594cc,U,000004,_ZN27PlayerJudgeEnableGuideArrow5resetEv

Can't render this file because it is too large.

View file

@ -7,4 +7,5 @@ class LiveActor;
class PlayerFunction {
public:
static u32 getPlayerInputPort(const al::LiveActor*);
static bool isPlayerDeadStatus(const al::LiveActor*);
};

View file

@ -0,0 +1,78 @@
#include "Player/PlayerJudgeDeadWipeStart.h"
#include "Player/PlayerConst.h"
#include "Player/PlayerFunction.h"
PlayerJudgeDeadWipeStart::PlayerJudgeDeadWipeStart(const al::LiveActor* playerActor,
const PlayerConst* playerConst)
: mPlayerActor(playerActor), mPlayerConst(playerConst) {}
void PlayerJudgeDeadWipeStart::reset() {
mDeathType = DeathType::Damage;
mCounter = -1;
}
void PlayerJudgeDeadWipeStart::update() {
if (PlayerFunction::isPlayerDeadStatus(mPlayerActor))
mCounter++;
}
bool PlayerJudgeDeadWipeStart::judge() const {
switch (mDeathType) {
case DeathType::Damage:
return mCounter >= mPlayerConst->getDeadWipeStartDamage();
case DeathType::Abyss:
return mCounter >= mPlayerConst->getDeadWipeStartAbyss();
case DeathType::AbyssWithCapMsg:
return mCounter >= mPlayerConst->getDeadWipeStartAbyssWithCapMsg();
case DeathType::Press:
return mCounter >= mPlayerConst->getDeadWipeStartPress();
case DeathType::SandSink:
return mCounter >= mPlayerConst->getDeadWipeStartSandSink();
case DeathType::NoOxygen:
return mCounter >= mPlayerConst->getDeadWipeStartNoOxygen();
case DeathType::IceWater:
return mCounter >= mPlayerConst->getDeadWipeStartIceWater();
default:
return false;
}
}
bool PlayerJudgeDeadWipeStart::isDeadTypeDrawForward() const {
return mDeathType == DeathType::Damage || mDeathType == DeathType::Press ||
mDeathType == DeathType::SandSink || mDeathType == DeathType::NoOxygen ||
mDeathType == DeathType::IceWater;
}
// Determines if a ring of coins should appear for certain death types
bool PlayerJudgeDeadWipeStart::isDeadEnableCoinAppear() const {
return mDeathType != DeathType::Press;
}
void PlayerJudgeDeadWipeStart::getWipeInfo(const char** name, s32* wait) const {
*name = "WipeMiss";
switch (mDeathType) {
case DeathType::Damage:
*wait = mPlayerConst->getDeadWipeWaitDamage();
break;
case DeathType::Abyss:
*wait = mPlayerConst->getDeadWipeWaitAbyss();
break;
case DeathType::AbyssWithCapMsg:
*wait = mPlayerConst->getDeadWipeWaitAbyssWithCapMsg();
break;
case DeathType::Press:
*wait = mPlayerConst->getDeadWipeWaitPress();
break;
case DeathType::SandSink:
*wait = mPlayerConst->getDeadWipeWaitSandSink();
break;
case DeathType::NoOxygen:
*wait = mPlayerConst->getDeadWipeWaitNoOxygen();
break;
case DeathType::IceWater:
*wait = mPlayerConst->getDeadWipeWaitIceWater();
break;
}
}

View file

@ -0,0 +1,33 @@
#pragma once
#include <basis/seadTypes.h>
#include "Player/IJudge.h"
namespace al {
class LiveActor;
}
class PlayerConst;
// note: This is just to make the code easier to read. The names are based on PlayerConst function
// names
enum class DeathType : u32 { Damage, Abyss, AbyssWithCapMsg, Press, SandSink, NoOxygen, IceWater };
class PlayerJudgeDeadWipeStart : public IJudge {
public:
PlayerJudgeDeadWipeStart(const al::LiveActor* playerActor, const PlayerConst* playerConst);
void reset() override;
void update() override;
bool judge() const override;
bool isDeadTypeDrawForward() const;
bool isDeadEnableCoinAppear() const;
void getWipeInfo(const char** name, s32* wait) const;
private:
const al::LiveActor* mPlayerActor;
const PlayerConst* mPlayerConst;
DeathType mDeathType = DeathType::Damage;
s32 mCounter = -1;
};

View file

@ -0,0 +1,18 @@
#include "Player/PlayerJudgeDrawForward.h"
#include "Player/PlayerJudgeDeadWipeStart.h"
#include "System/GameDataFunction.h"
#include "System/GameDataHolderAccessor.h"
PlayerJudgeDrawForward::PlayerJudgeDrawForward(
const al::LiveActor* playerActor, const PlayerJudgeDeadWipeStart* playerJudgeDeadWipeStart)
: mPlayerActor(playerActor), mPlayerJudgeDeadWipeStart(playerJudgeDeadWipeStart) {}
bool PlayerJudgeDrawForward::judge() const {
if (!GameDataFunction::isPlayerLifeZero(mPlayerActor))
return false;
return mPlayerJudgeDeadWipeStart->isDeadTypeDrawForward();
}
void PlayerJudgeDrawForward::reset() {}
void PlayerJudgeDrawForward::update() {}

View file

@ -0,0 +1,24 @@
#pragma once
#include <basis/seadTypes.h>
#include "Player/IJudge.h"
namespace al {
class LiveActor;
}
class PlayerJudgeDeadWipeStart;
class PlayerJudgeDrawForward : public IJudge {
public:
PlayerJudgeDrawForward(const al::LiveActor* playerActor,
const PlayerJudgeDeadWipeStart* playerJudgeDeadWipeStart);
void reset() override;
void update() override;
bool judge() const override;
private:
const al::LiveActor* mPlayerActor;
const PlayerJudgeDeadWipeStart* mPlayerJudgeDeadWipeStart;
};