blob: 5b5b9ca1fcfc3273bc0c4323b394c9f4d49fd8e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#include "KingSystem/ActorSystem/actPlayerInfo.h"
#include "KingSystem/ActorSystem/Profiles/actPlayerBase.h"
#include "KingSystem/ActorSystem/actActorConstDataAccess.h"
#include "KingSystem/ActorSystem/actActorLinkConstDataAccess.h"
#include "KingSystem/ActorSystem/actBaseProc.h"
#include "KingSystem/ActorSystem/actBaseProcMgr.h"
#include "KingSystem/GameData/gdtCommonFlagsUtils.h"
#include "KingSystem/ksys.h"
namespace ksys::act {
SEAD_SINGLETON_DISPOSER_IMPL(PlayerInfo)
PlayerInfo::PlayerInfo() = default;
PlayerInfo::~PlayerInfo() = default;
bool PlayerInfo::init() {
return true;
}
void PlayerInfo::resetPlayer(PlayerBase* player) {
if (mPlayerActor == player) {
mPlayerActor = nullptr;
ksys::setPlayerLink(nullptr);
}
}
bool PlayerInfo::acquireHorse(BaseProc* horse) {
return mHorseLink.acquire(horse, false);
}
void PlayerInfo::setHorseLink(const BaseProcLink& horse_link) {
mHorseLink = horse_link;
}
PlayerBase* PlayerInfo::getPlayer() const {
if (!mPlayerActor) {
return nullptr;
}
BaseProcMgr::instance()->isAccessingProcSafe(mPlayerActor, nullptr);
return mPlayerActor;
}
PlayerBase* PlayerInfo::getPlayer_() const {
if (!mPlayerActor) {
return nullptr;
}
BaseProcMgr::instance()->isAccessingProcSafe(mPlayerActor, nullptr);
return mPlayerActor;
}
s32 PlayerInfo::getMaxLifeFromPlayerActor() const {
return mPlayerActor ? mPlayerActor->getMaxLife() : 0;
}
void PlayerInfo::setMaxHeartValue(s32 quarter_hearts) {
gdt::setFlag_MaxHartValue(quarter_hearts);
mMaxHeartValue = static_cast<f32>(quarter_hearts);
}
u32 PlayerInfo::getMaxHeartValue() const {
// Return type is unsigned, but the conversion is signed
return static_cast<s32>(mMaxHeartValue);
}
void PlayerInfo::updateMaxHeartValueFromGameData() {
mMaxHeartValue = static_cast<f32>(gdt::getFlag_MaxHartValue());
}
void PlayerInfo::setLifeForPlayerActor(s32 life) {
if (mPlayerActor) {
*mPlayerActor->getLife() = life;
}
}
s32 PlayerInfo::getLifeFromPlayerActor() const {
if (!mPlayerActor) {
return 0;
}
auto* life = mPlayerActor->getLife();
return life ? *life : 1;
}
void PlayerInfo::recoverLife() {
setLifeForPlayerActor(getMaxLifeFromPlayerActor());
}
void PlayerInfo::setStaminaCurrentMax(f32 max_stamina) {
gdt::setFlag_StaminaCurrentMax(max_stamina);
mStaminaCurrentMax = max_stamina;
}
f32 PlayerInfo::getStaminaCurrentMax() const {
return mStaminaCurrentMax;
}
void PlayerInfo::updateStaminaCurrentMaxFromGameData() {
mStaminaCurrentMax = gdt::getFlag_StaminaCurrentMax();
}
void PlayerInfo::setStaminaMax(f32 max_stamina) {
gdt::setFlag_StaminaMax(max_stamina);
mStaminaMax = max_stamina;
}
f32 PlayerInfo::getStaminaMax() const {
return mStaminaMax;
}
void PlayerInfo::updateStaminaMaxFromGameData() {
mStaminaMax = gdt::getFlag_StaminaMax();
}
PlayerBase* PlayerInfo::getPlayerUnchecked() {
return mPlayerActor;
}
sead::Vector3f& PlayerInfo::getPlayerPos() {
ActorConstDataAccess accessor;
acquireActor(&mPlayerLink, &accessor);
accessor.debugLog(1, "getPlayerPos");
return mPlayerPos;
}
sead::Vector3f& PlayerInfo::getPlayerPosForPostCalc() {
ActorConstDataAccess accessor;
acquireActor(&mPlayerLink, &accessor);
accessor.debugLog(0, "getPlayerPosForPostCalc");
return mPlayerPosForPostCalc;
}
} // namespace ksys::act
|