2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2015-08-17 05:26:58 +00:00
|
|
|
|
2019-09-19 19:24:26 +00:00
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CStaticInterference.hpp"
|
|
|
|
#include "Runtime/IOStreams.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/World/CHealthInfo.hpp"
|
2015-08-17 20:33:58 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
class CPlayerState {
|
|
|
|
friend class CWorldTransManager;
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2016-03-23 20:38:01 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EItemType : s32 {
|
|
|
|
Invalid = -1,
|
|
|
|
PowerBeam = 0,
|
|
|
|
IceBeam = 1,
|
|
|
|
WaveBeam = 2,
|
|
|
|
PlasmaBeam = 3,
|
|
|
|
Missiles = 4,
|
|
|
|
ScanVisor = 5,
|
|
|
|
MorphBallBombs = 6,
|
|
|
|
PowerBombs = 7,
|
|
|
|
Flamethrower = 8,
|
|
|
|
ThermalVisor = 9,
|
|
|
|
ChargeBeam = 10,
|
|
|
|
SuperMissile = 11,
|
|
|
|
GrappleBeam = 12,
|
|
|
|
XRayVisor = 13,
|
|
|
|
IceSpreader = 14,
|
|
|
|
SpaceJumpBoots = 15,
|
|
|
|
MorphBall = 16,
|
|
|
|
CombatVisor = 17,
|
|
|
|
BoostBall = 18,
|
|
|
|
SpiderBall = 19,
|
|
|
|
PowerSuit = 20,
|
|
|
|
GravitySuit = 21,
|
|
|
|
VariaSuit = 22,
|
|
|
|
PhazonSuit = 23,
|
|
|
|
EnergyTanks = 24,
|
|
|
|
UnknownItem1 = 25,
|
|
|
|
HealthRefill = 26,
|
|
|
|
UnknownItem2 = 27,
|
|
|
|
Wavebuster = 28,
|
|
|
|
Truth = 29,
|
|
|
|
Strength = 30,
|
|
|
|
Elder = 31,
|
|
|
|
Wild = 32,
|
|
|
|
Lifegiver = 33,
|
|
|
|
Warrior = 34,
|
|
|
|
Chozo = 35,
|
|
|
|
Nature = 36,
|
|
|
|
Sun = 37,
|
|
|
|
World = 38,
|
|
|
|
Spirit = 39,
|
|
|
|
Newborn = 40,
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* This must remain at the end of the list */
|
|
|
|
Max
|
|
|
|
};
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EPlayerVisor : u32 {
|
|
|
|
Combat,
|
|
|
|
XRay,
|
|
|
|
Scan,
|
|
|
|
Thermal,
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* This must remain at the end of the list */
|
|
|
|
Max
|
|
|
|
};
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EPlayerSuit : s32 {
|
|
|
|
Invalid = -1,
|
|
|
|
Power,
|
|
|
|
Gravity,
|
|
|
|
Varia,
|
|
|
|
Phazon,
|
|
|
|
FusionPower,
|
|
|
|
FusionGravity,
|
|
|
|
FusionVaria,
|
|
|
|
FusionPhazon
|
|
|
|
};
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EBeamId : s32 { Invalid = -1, Power, Ice, Wave, Plasma, Phazon, Phazon2 = 27 };
|
2016-03-28 08:54:02 +00:00
|
|
|
|
2016-03-23 20:38:01 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
struct CPowerUp {
|
|
|
|
u32 x0_amount = 0;
|
|
|
|
u32 x4_capacity = 0;
|
2020-03-21 04:33:53 +00:00
|
|
|
constexpr CPowerUp() = default;
|
|
|
|
constexpr CPowerUp(u32 amount, u32 capacity) : x0_amount(amount), x4_capacity(capacity) {}
|
2018-12-08 05:30:43 +00:00
|
|
|
};
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x0_24_alive : 1 = true;
|
|
|
|
bool x0_25_firingComboBeam : 1 = false;
|
|
|
|
bool x0_26_fusion : 1 = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 x4_enabledItems = 0;
|
|
|
|
EBeamId x8_currentBeam = EBeamId::Power;
|
|
|
|
CHealthInfo xc_health = {99.f, 50.f};
|
|
|
|
EPlayerVisor x14_currentVisor = EPlayerVisor::Combat;
|
|
|
|
EPlayerVisor x18_transitioningVisor = x14_currentVisor;
|
|
|
|
float x1c_visorTransitionFactor = 0.2f;
|
|
|
|
EPlayerSuit x20_currentSuit = EPlayerSuit::Power;
|
|
|
|
rstl::reserved_vector<CPowerUp, 41> x24_powerups;
|
|
|
|
std::vector<std::pair<CAssetId, float>> x170_scanTimes;
|
|
|
|
std::pair<u32, u32> x180_scanCompletionRate = {};
|
2020-04-20 04:57:50 +00:00
|
|
|
CStaticInterference x188_staticIntf{5};
|
2018-06-13 19:36:11 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool m_canTakeDamage = true;
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
|
|
|
u32 GetMissileCostForAltAttack() const;
|
|
|
|
float GetComboFireAmmoPeriod() const;
|
|
|
|
static constexpr float GetMissileComboChargeFactor() { return 1.8f; }
|
|
|
|
u32 CalculateItemCollectionRate() const;
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2020-03-24 10:20:33 +00:00
|
|
|
CHealthInfo& GetHealthInfo();
|
2018-12-08 05:30:43 +00:00
|
|
|
const CHealthInfo& GetHealthInfo() const;
|
2020-05-20 02:25:22 +00:00
|
|
|
u32 GetPickupTotal() const { return 99; }
|
2018-12-08 05:30:43 +00:00
|
|
|
void SetIsFusionEnabled(bool val) { x0_26_fusion = val; }
|
|
|
|
bool IsFusionEnabled() const { return x0_26_fusion; }
|
|
|
|
EPlayerSuit GetCurrentSuit() const;
|
|
|
|
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& stateMgr) const;
|
|
|
|
void UpdateStaticInterference(CStateManager& stateMgr, float dt);
|
|
|
|
void IncreaseScanTime(u32 time, float val);
|
|
|
|
void SetScanTime(CAssetId res, float time);
|
|
|
|
float GetScanTime(CAssetId time) const;
|
|
|
|
bool GetIsVisorTransitioning() const;
|
|
|
|
float GetVisorTransitionFactor() const;
|
|
|
|
void UpdateVisorTransition(float dt);
|
2019-02-24 07:15:54 +00:00
|
|
|
void StartTransitionToVisor(EPlayerVisor visor);
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResetVisor();
|
|
|
|
bool ItemEnabled(EItemType type) const;
|
|
|
|
void DisableItem(EItemType type);
|
|
|
|
void EnableItem(EItemType type);
|
|
|
|
bool HasPowerUp(EItemType type) const;
|
|
|
|
u32 GetItemCapacity(EItemType type) const;
|
|
|
|
u32 GetItemAmount(EItemType type) const;
|
|
|
|
void DecrPickup(EItemType type, u32 amount);
|
|
|
|
void IncrPickup(EItemType type, u32 amount);
|
|
|
|
void ResetAndIncrPickUp(EItemType type, u32 amount);
|
|
|
|
static float GetEnergyTankCapacity() { return 100.f; }
|
|
|
|
static float GetBaseHealthCapacity() { return 99.f; }
|
|
|
|
float CalculateHealth();
|
2021-03-15 22:43:28 +00:00
|
|
|
void ReInitializePowerUp(EItemType type, u32 capacity);
|
2019-05-08 03:50:21 +00:00
|
|
|
void AddPowerUp(EItemType type, u32 capacity);
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 GetLogScans() const { return x180_scanCompletionRate.first; }
|
|
|
|
u32 GetTotalLogScans() const { return x180_scanCompletionRate.second; }
|
|
|
|
void SetScanCompletionRate(const std::pair<u32, u32>& p) { x180_scanCompletionRate = p; }
|
|
|
|
bool IsPlayerAlive() const { return x0_24_alive; }
|
|
|
|
void SetPlayerAlive(bool alive) { x0_24_alive = alive; }
|
|
|
|
bool IsFiringComboBeam() const { return x0_25_firingComboBeam; }
|
|
|
|
void SetFiringComboBeam(bool f) { x0_25_firingComboBeam = f; }
|
|
|
|
void InitializeScanTimes();
|
|
|
|
CStaticInterference& GetStaticInterference() { return x188_staticIntf; }
|
|
|
|
const std::vector<std::pair<CAssetId, float>>& GetScanTimes() const { return x170_scanTimes; }
|
|
|
|
CPlayerState();
|
2020-03-26 01:25:11 +00:00
|
|
|
explicit CPlayerState(CBitStreamReader& stream);
|
2018-12-08 05:30:43 +00:00
|
|
|
void PutTo(CBitStreamWriter& stream);
|
2019-09-19 19:33:38 +00:00
|
|
|
static u32 GetPowerUpMaxValue(EItemType type);
|
2018-12-08 05:30:43 +00:00
|
|
|
static EItemType ItemNameToType(std::string_view name);
|
2021-05-27 14:26:13 +00:00
|
|
|
static std::string_view ItemTypeToName(EItemType type);
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CanTakeDamage() const { return m_canTakeDamage; }
|
|
|
|
void SetCanTakeDamage(bool c) { m_canTakeDamage = c; }
|
2015-08-17 05:26:58 +00:00
|
|
|
};
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|