2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CPLAYERSTATE
|
|
|
|
#define _CPLAYERSTATE
|
|
|
|
|
|
|
|
#include "types.h"
|
2022-04-10 00:17:06 +00:00
|
|
|
|
2022-10-01 14:08:15 +00:00
|
|
|
#include "MetroidPrime/CHealthInfo.hpp"
|
|
|
|
#include "MetroidPrime/Player/CStaticInterference.hpp"
|
2022-10-09 05:13:17 +00:00
|
|
|
|
|
|
|
#include "Kyoto/IObjectStore.hpp"
|
|
|
|
|
2022-10-01 14:08:15 +00:00
|
|
|
#include "rstl/pair.hpp"
|
|
|
|
#include "rstl/reserved_vector.hpp"
|
|
|
|
#include "rstl/vector.hpp"
|
2022-04-10 00:17:06 +00:00
|
|
|
|
2022-08-16 02:14:28 +00:00
|
|
|
class CStateManager;
|
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
class CPlayerState {
|
|
|
|
public:
|
2022-10-01 14:08:15 +00:00
|
|
|
enum EItemType {
|
|
|
|
kIT_Invalid = -1,
|
|
|
|
kIT_PowerBeam = 0,
|
|
|
|
kIT_IceBeam = 1,
|
|
|
|
kIT_WaveBeam = 2,
|
|
|
|
kIT_PlasmaBeam = 3,
|
|
|
|
kIT_Missiles = 4,
|
|
|
|
kIT_ScanVisor = 5,
|
|
|
|
kIT_MorphBallBombs = 6,
|
|
|
|
kIT_PowerBombs = 7,
|
|
|
|
kIT_Flamethrower = 8,
|
|
|
|
kIT_ThermalVisor = 9,
|
|
|
|
kIT_ChargeBeam = 10,
|
|
|
|
kIT_SuperMissile = 11,
|
|
|
|
kIT_GrappleBeam = 12,
|
|
|
|
kIT_XRayVisor = 13,
|
|
|
|
kIT_IceSpreader = 14,
|
|
|
|
kIT_SpaceJumpBoots = 15,
|
|
|
|
kIT_MorphBall = 16,
|
|
|
|
kIT_CombatVisor = 17,
|
|
|
|
kIT_BoostBall = 18,
|
|
|
|
kIT_SpiderBall = 19,
|
|
|
|
kIT_PowerSuit = 20,
|
|
|
|
kIT_GravitySuit = 21,
|
|
|
|
kIT_VariaSuit = 22,
|
|
|
|
kIT_PhazonSuit = 23,
|
|
|
|
kIT_EnergyTanks = 24,
|
|
|
|
kIT_UnknownItem1 = 25,
|
|
|
|
kIT_HealthRefill = 26,
|
|
|
|
kIT_UnknownItem2 = 27,
|
|
|
|
kIT_Wavebuster = 28,
|
|
|
|
kIT_Truth = 29,
|
|
|
|
kIT_Strength = 30,
|
|
|
|
kIT_Elder = 31,
|
|
|
|
kIT_Wild = 32,
|
|
|
|
kIT_Lifegiver = 33,
|
|
|
|
kIT_Warrior = 34,
|
|
|
|
kIT_Chozo = 35,
|
|
|
|
kIT_Nature = 36,
|
|
|
|
kIT_Sun = 37,
|
|
|
|
kIT_World = 38,
|
|
|
|
kIT_Spirit = 39,
|
|
|
|
kIT_Newborn = 40,
|
|
|
|
|
|
|
|
/* This must remain at the end of the list */
|
|
|
|
kIT_Max
|
|
|
|
};
|
|
|
|
|
2022-08-16 02:14:28 +00:00
|
|
|
enum EPlayerVisor {
|
|
|
|
kPV_Combat,
|
|
|
|
kPV_XRay,
|
|
|
|
kPV_Scan,
|
|
|
|
kPV_Thermal,
|
|
|
|
};
|
2022-09-19 04:19:46 +00:00
|
|
|
enum EPlayerSuit {
|
|
|
|
kPS_Invalid = -1,
|
|
|
|
kPS_Power,
|
|
|
|
kPS_Gravity,
|
|
|
|
kPS_Varia,
|
|
|
|
kPS_Phazon,
|
|
|
|
kPS_FusionPower,
|
|
|
|
kPS_FusionGravity,
|
|
|
|
kPS_FusionVaria,
|
|
|
|
kPS_FusionPhazon,
|
|
|
|
};
|
|
|
|
enum EBeamId {
|
|
|
|
kBI_Invalid = -1,
|
|
|
|
kBI_Power,
|
|
|
|
kBI_Ice,
|
|
|
|
kBI_Wave,
|
|
|
|
kBI_Plasma,
|
|
|
|
kBI_Phazon,
|
|
|
|
kBI_Phazon2 = 27,
|
|
|
|
};
|
2022-10-06 12:34:36 +00:00
|
|
|
enum EChargeStage { kCS_Normal, kCS_Charged };
|
2022-08-16 02:14:28 +00:00
|
|
|
|
2022-10-01 14:08:15 +00:00
|
|
|
CPlayerState();
|
|
|
|
explicit CPlayerState(CInputStream& stream);
|
|
|
|
void PutTo(COutputStream& stream);
|
|
|
|
|
2022-10-04 00:00:46 +00:00
|
|
|
int GetMissileCostForAltAttack() const;
|
2022-10-01 14:08:15 +00:00
|
|
|
float GetComboFireAmmoPeriod() const;
|
|
|
|
static float GetMissileComboChargeFactor();
|
2022-10-04 00:00:46 +00:00
|
|
|
int CalculateItemCollectionRate() const;
|
|
|
|
int GetTotalPickupCount() const;
|
2022-08-16 02:14:28 +00:00
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
void SetIsFusionEnabled(bool v);
|
2022-10-02 10:13:35 +00:00
|
|
|
bool GetIsFusionEnabled() const;
|
2022-10-01 14:08:15 +00:00
|
|
|
|
2022-12-01 13:45:36 +00:00
|
|
|
EPlayerSuit GetCurrentSuit() const;
|
2022-10-01 14:08:15 +00:00
|
|
|
EPlayerSuit GetCurrentSuitRaw() const { return x20_currentSuit; }
|
|
|
|
EBeamId GetCurrentBeam() const { return x8_currentBeam; }
|
|
|
|
void SetCurrentBeam(EBeamId beam) { x8_currentBeam = beam; }
|
|
|
|
bool CanVisorSeeFog(const CStateManager& stateMgr) const;
|
|
|
|
EPlayerVisor GetCurrentVisor() const { return x14_currentVisor; }
|
|
|
|
EPlayerVisor GetTransitioningVisor() const { return x18_transitioningVisor; }
|
|
|
|
EPlayerVisor GetActiveVisor(const CStateManager& mgr) const;
|
|
|
|
|
|
|
|
void UpdateStaticInterference(CStateManager& stateMgr, const float& dt);
|
2022-10-04 00:00:46 +00:00
|
|
|
void IncreaseScanTime(uint time, float val);
|
2022-10-01 14:08:15 +00:00
|
|
|
void SetScanTime(CAssetId res, float time);
|
|
|
|
float GetScanTime(CAssetId time) const;
|
|
|
|
bool GetIsVisorTransitioning() const;
|
|
|
|
float GetVisorTransitionFactor() const;
|
|
|
|
void UpdateVisorTransition(float dt);
|
|
|
|
void StartTransitionToVisor(EPlayerVisor visor);
|
|
|
|
void ResetVisor();
|
2022-11-09 23:45:24 +00:00
|
|
|
bool IsPlayerAlive() const { return x0_24_alive; }
|
2022-10-01 14:08:15 +00:00
|
|
|
|
|
|
|
bool ItemEnabled(EItemType type) const;
|
|
|
|
void DisableItem(EItemType type);
|
|
|
|
void EnableItem(EItemType type);
|
|
|
|
bool HasPowerUp(EItemType type) const;
|
2022-10-04 00:00:46 +00:00
|
|
|
uint GetPowerUp(EItemType type);
|
2022-10-04 18:15:07 +00:00
|
|
|
int GetItemCapacity(EItemType type) const;
|
2022-11-29 17:17:12 +00:00
|
|
|
int GetItemAmount(EItemType type) const;
|
2022-10-01 14:08:15 +00:00
|
|
|
void DecrPickUp(EItemType type, int amount);
|
|
|
|
void IncrPickUp(EItemType type, int amount);
|
2023-10-12 21:52:29 +00:00
|
|
|
void SetPickup(EItemType type, int amount);
|
2022-10-01 14:08:15 +00:00
|
|
|
static float GetEnergyTankCapacity();
|
|
|
|
static float GetBaseHealthCapacity();
|
|
|
|
float CalculateHealth();
|
|
|
|
void InitializePowerUp(CPlayerState::EItemType type, int capacity);
|
2023-10-12 21:52:29 +00:00
|
|
|
void SetPowerUp(CPlayerState::EItemType type, int capacity);
|
2022-10-01 14:08:15 +00:00
|
|
|
|
|
|
|
void InitializeScanTimes();
|
|
|
|
|
|
|
|
static uint GetBitCount(uint);
|
|
|
|
|
2022-10-04 00:00:46 +00:00
|
|
|
CStaticInterference& StaticInterference() { return x188_staticIntf; }
|
|
|
|
const CStaticInterference& GetStaticInterference() const { return x188_staticIntf; }
|
2022-10-01 14:08:15 +00:00
|
|
|
|
|
|
|
const rstl::vector< rstl::pair< CAssetId, float > >& GetScanTimes() const {
|
|
|
|
return x170_scanTimes;
|
|
|
|
}
|
|
|
|
|
2022-11-29 17:17:12 +00:00
|
|
|
CHealthInfo* HealthInfo() { return &xc_health; }
|
2022-10-01 14:08:15 +00:00
|
|
|
|
|
|
|
const CHealthInfo& GetHealthInfo() const { return xc_health; }
|
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
private:
|
2022-10-01 14:08:15 +00:00
|
|
|
struct CPowerUp {
|
|
|
|
int x0_amount;
|
|
|
|
int x4_capacity;
|
|
|
|
CPowerUp() : x0_amount(0), x4_capacity(0) {}
|
|
|
|
CPowerUp(int amount, int capacity);
|
2022-10-05 06:46:30 +00:00
|
|
|
|
|
|
|
void Add(int amount) {
|
|
|
|
int capacity = x4_capacity;
|
|
|
|
x0_amount += amount;
|
|
|
|
if (x0_amount > capacity) {
|
|
|
|
x0_amount = capacity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dec(int amount) {
|
|
|
|
x0_amount -= amount;
|
|
|
|
if (x0_amount < 0) {
|
|
|
|
x0_amount = 0;
|
|
|
|
}
|
|
|
|
}
|
2022-10-01 14:08:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool x0_24_alive : 1;
|
|
|
|
bool x0_25_firingComboBeam : 1;
|
|
|
|
bool x0_26_fusion : 1;
|
2022-10-04 00:00:46 +00:00
|
|
|
uint x4_enabledItems;
|
2022-10-01 14:08:15 +00:00
|
|
|
EBeamId x8_currentBeam;
|
|
|
|
CHealthInfo xc_health;
|
|
|
|
EPlayerVisor x14_currentVisor;
|
|
|
|
EPlayerVisor x18_transitioningVisor;
|
|
|
|
float x1c_visorTransitionFactor;
|
|
|
|
EPlayerSuit x20_currentSuit;
|
|
|
|
rstl::reserved_vector< CPowerUp, 41 > x24_powerups;
|
|
|
|
rstl::vector< rstl::pair< CAssetId, float > > x170_scanTimes;
|
2022-10-04 13:29:05 +00:00
|
|
|
int x180_scanCompletionRateFirst;
|
|
|
|
int x184_scanCompletionRateSecond;
|
2022-10-01 14:08:15 +00:00
|
|
|
CStaticInterference x188_staticIntf;
|
2022-04-10 00:17:06 +00:00
|
|
|
};
|
2022-12-05 21:35:31 +00:00
|
|
|
CHECK_SIZEOF(CPlayerState, 0x198)
|
2022-04-10 00:17:06 +00:00
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CPLAYERSTATE
|