Match and link CGSComboFire

This commit is contained in:
Henrique Gemignani Passos Lima 2022-11-08 01:04:20 +02:00
parent cab29870fd
commit 9ed61ba6a8
No known key found for this signature in database
GPG Key ID: E224F951761145F8
6 changed files with 136 additions and 3 deletions

View File

@ -278,7 +278,7 @@ LIBS = [
"MetroidPrime/PathFinding/CPathFindArea", "MetroidPrime/PathFinding/CPathFindArea",
["MetroidPrime/Weapons/GunController/CGunController", False], ["MetroidPrime/Weapons/GunController/CGunController", False],
["MetroidPrime/Weapons/GunController/CGSFreeLook", False], ["MetroidPrime/Weapons/GunController/CGSFreeLook", False],
"MetroidPrime/Weapons/GunController/CGSComboFire", ["MetroidPrime/Weapons/GunController/CGSComboFire", True],
["MetroidPrime/HUD/CHudBallInterface", False], ["MetroidPrime/HUD/CHudBallInterface", False],
"MetroidPrime/Tweaks/CTweakGuiColors", "MetroidPrime/Tweaks/CTweakGuiColors",
"MetroidPrime/ScriptObjects/CFishCloud", "MetroidPrime/ScriptObjects/CFishCloud",
@ -301,7 +301,7 @@ LIBS = [
["MetroidPrime/ScriptObjects/CScriptAiJumpPoint", True], ["MetroidPrime/ScriptObjects/CScriptAiJumpPoint", True],
"MetroidPrime/CMessageScreen", "MetroidPrime/CMessageScreen",
"MetroidPrime/Enemies/CFlaahgraTentacle", "MetroidPrime/Enemies/CFlaahgraTentacle",
"MetroidPrime/Weapons/GunController/CGSFidget", ["MetroidPrime/Weapons/GunController/CGSFidget", False],
["MetroidPrime/BodyState/CABSReaction", True], ["MetroidPrime/BodyState/CABSReaction", True],
"MetroidPrime/Weapons/CIceProjectile", "MetroidPrime/Weapons/CIceProjectile",
"MetroidPrime/Enemies/CFlyingPirate", "MetroidPrime/Enemies/CFlyingPirate",

View File

@ -0,0 +1,27 @@
#ifndef _CGSCOMBOFIRE
#define _CGSCOMBOFIRE
class CAnimData;
class CStateManager;
class CGSComboFire {
public:
CGSComboFire();
bool IsComboOver() const { return x10_24_over; }
int GetLoopState() const { return x4_loopState; }
void SetLoopState(int l) { x4_loopState = l; }
void SetIdle(bool i) { x10_25_idle = i; }
int GetGunId() const { return xc_gunId; }
bool Update(CAnimData& data, float dt, CStateManager& mgr);
int SetAnim(CAnimData& data, int gunId, int loopState, CStateManager& mgr, float delay);
private:
float x0_delay;
int x4_loopState; // In, loop, out
int x8_cueAnimId;
int xc_gunId;
bool x10_24_over : 1;
bool x10_25_idle : 1;
};
#endif // _CGSCOMBOFIRE

View File

@ -0,0 +1,27 @@
#ifndef _CGSFIDGET
#define _CGSFIDGET
#include "rstl/vector.hpp"
class CAnimData;
class CStateManager;
class CToken;
class CGSFidget {
public:
CGSFidget();
bool Update(CAnimData& data, float dt, CStateManager& mgr);
int SetAnim(CAnimData& data, int type, int gunId, int animSet, CStateManager& mgr);
void LoadAnimAsync(CAnimData& data, int type, int gunId, int animSet, CStateManager& mgr);
void UnLoadAnim();
bool IsAnimLoaded() const;
private:
rstl::vector< CToken > x0_anims;
int x10_;
int x14_gunId;
int x18_animSet;
};
#endif // _CGSFIDGET

View File

@ -243,7 +243,7 @@ METROIDPRIME :=\
$(BUILD_DIR)/asm/MetroidPrime/PathFinding/CPathFindArea.o\ $(BUILD_DIR)/asm/MetroidPrime/PathFinding/CPathFindArea.o\
$(BUILD_DIR)/asm/MetroidPrime/Weapons/GunController/CGunController.o\ $(BUILD_DIR)/asm/MetroidPrime/Weapons/GunController/CGunController.o\
$(BUILD_DIR)/asm/MetroidPrime/Weapons/GunController/CGSFreeLook.o\ $(BUILD_DIR)/asm/MetroidPrime/Weapons/GunController/CGSFreeLook.o\
$(BUILD_DIR)/asm/MetroidPrime/Weapons/GunController/CGSComboFire.o\ $(BUILD_DIR)/src/MetroidPrime/Weapons/GunController/CGSComboFire.o\
$(BUILD_DIR)/asm/MetroidPrime/HUD/CHudBallInterface.o\ $(BUILD_DIR)/asm/MetroidPrime/HUD/CHudBallInterface.o\
$(BUILD_DIR)/asm/MetroidPrime/Tweaks/CTweakGuiColors.o\ $(BUILD_DIR)/asm/MetroidPrime/Tweaks/CTweakGuiColors.o\
$(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CFishCloud.o\ $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CFishCloud.o\

View File

@ -0,0 +1,74 @@
#include "MetroidPrime/Weapons/GunController/CGSComboFire.hpp"
#include "MetroidPrime/CAnimData.hpp"
#include "MetroidPrime/CAnimPlaybackParms.hpp"
#include "MetroidPrime/CStateManager.hpp"
#include "Kyoto/Animation/CPASAnimParmData.hpp"
CGSComboFire::CGSComboFire()
: x0_delay(0.f)
, x4_loopState(-1)
, x8_cueAnimId(-1)
, xc_gunId(-1)
, x10_24_over(false)
, x10_25_idle(false) {}
bool CGSComboFire::Update(CAnimData& data, float dt, CStateManager& mgr) {
if (x8_cueAnimId != -1) {
x0_delay -= dt;
if (x0_delay <= 0.f) {
data.EnableLooping(x4_loopState == 1);
CAnimPlaybackParms aparms(x8_cueAnimId, -1, 1.f, true);
data.SetAnimation(aparms, false);
x0_delay = 0.f;
x8_cueAnimId = -1;
}
} else if (!data.IsAnimTimeRemaining(0.001f, rstl::string_l("Whole Body"))) {
switch (x4_loopState) {
case 0:
SetAnim(data, xc_gunId, 1, mgr, 0.f);
switch (xc_gunId) {
case 4:
case 0:
case 1:
x10_24_over = true;
break;
default:
break;
}
break;
case 2:
x4_loopState = -1;
return true;
default:
break;
}
}
return false;
}
int CGSComboFire::SetAnim(CAnimData& data, int gunId, int loopState, CStateManager& mgr,
float delay) {
int useLoopState = !x10_25_idle ? loopState : 2;
x10_25_idle = false;
const CPASDatabase& pas = data.GetCharacterInfo().GetPASDatabase();
rstl::pair< float, int > anim =
pas.FindBestAnimation(CPASAnimParmData(pas::kAS_Death, CPASAnimParm::FromInt32(gunId),
CPASAnimParm::FromEnum(useLoopState)),
*mgr.Random(), -1);
x10_24_over = false;
xc_gunId = gunId;
x4_loopState = useLoopState;
if (delay != 0.f) {
x0_delay = delay;
x8_cueAnimId = anim.second;
} else {
data.EnableLooping(useLoopState == 1);
CAnimPlaybackParms aparms(anim.second, -1, 1.f, true);
data.SetAnimation(aparms, false);
}
return anim.second;
}

View File

@ -0,0 +1,5 @@
#include "MetroidPrime/Weapons/GunController/CGSFidget.hpp"
#include "Kyoto/CToken.hpp"
CGSFidget::CGSFidget() : x10_(-1), x14_gunId(-1), x18_animSet(-1) {}