forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_player.h
250 lines (200 loc) · 6.52 KB
/
game_player.h
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_GAME_PLAYER_H
#define EP_GAME_PLAYER_H
// Headers
#include "game_character.h"
#include "teleport_target.h"
#include <vector>
#include <lcf/rpg/fwd.h>
#include <lcf/rpg/music.h>
#include <lcf/rpg/savepartylocation.h>
#include <lcf/flag_set.h>
class Game_Vehicle;
using Game_PlayerBase = Game_CharacterDataStorage<lcf::rpg::SavePartyLocation>;
/**
* Game Player class
*/
class Game_Player : public Game_PlayerBase {
public:
Game_Player();
/** Load from saved game */
void SetSaveData(lcf::rpg::SavePartyLocation data);
/** @return save game data */
lcf::rpg::SavePartyLocation GetSaveData() const;
/**
* Implementation of abstract methods
*/
/** @{ */
Drawable::Z_t GetScreenZ(int x_offset, int y_offset) const override;
bool IsVisible() const override;
bool MakeWay(int from_x, int from_y, int to_x, int to_y) override;
void UpdateNextMovementAction() override;
void UpdateMovement(int amount) override;
void MoveRouteSetSpriteGraphic(std::string sprite_name, int index) override;
bool Move(int dir) override;
/** @} */
bool IsPendingTeleport() const;
TeleportTarget GetTeleportTarget() const;
void ResetTeleportTarget(TeleportTarget tt = {});
bool TriggerEventAt(int x, int y);
/**
* Sets the map, position and direction that the game player must have after the teleport is over
*
* @param map_id Id of the target map
* @param x new x position after teleport
* @param y new y position after teleport
* @param direction New direction after teleport. If -1, the direction isn't changed.
* @param tt teleport type
*/
void ReserveTeleport(int map_id, int x, int y, int direction, TeleportTarget::Type tt);
void ReserveTeleport(const lcf::rpg::SaveTarget& target);
void PerformTeleport();
void MoveTo(int map_id, int x, int y) override;
/** Update this for the current frame */
void Update();
/** Resets graphic based on current party */
void ResetGraphic();
bool GetOnOffVehicle();
bool InVehicle() const;
bool InAirship() const;
bool IsAboard() const;
bool IsBoardingOrUnboarding() const;
void ForceGetOffVehicle();
int GetVehicleType() const;
Game_Vehicle* GetVehicle() const;
/**
* Set the menu callling flag
*
* @param value the value of the flag to set
*/
void SetMenuCalling(bool value);
/** @return the menu calling flag */
bool IsMenuCalling() const;
/**
* Set the encounter calling flag
*
* @param value the value of the flag to set
*/
void SetEncounterCalling(bool value);
/** @return the encounter calling flag */
bool IsEncounterCalling() const;
/** @return number of encounter steps scaled by terrain encounter rate percentage. */
int GetTotalEncounterRate() const;
/**
* Sets accumulated encounter rate
*
* @param rate the rate to set.
*/
void SetTotalEncounterRate(int rate);
enum PanDirection {
PanUp,
PanRight,
PanDown,
PanLeft
};
bool IsPanActive() const;
bool IsPanLocked() const;
int GetPanX() const;
int GetPanY() const;
int GetTargetPanX() const;
int GetTargetPanY() const;
static int GetDefaultPanX();
static int GetDefaultPanY();
void LockPan();
void UnlockPan();
void StartPan(int direction, int distance, int speed);
void ResetPan(int speed);
/** @return how many frames it'll take to finish the current pan */
int GetPanWait();
bool IsMapCompatibleWithSave(int map_save_count) const;
bool IsDatabaseCompatibleWithSave(int database_save_count) const;
void UpdateSaveCounts(int db_save_count, int map_save_count);
private:
using TriggerSet = lcf::FlagSet<lcf::rpg::EventPage::Trigger>;
void UpdateScroll(int amount, bool was_jumping);
void UpdatePan();
void UpdateEncounterSteps();
bool CheckActionEvent();
bool CheckEventTriggerHere(TriggerSet triggers, bool triggered_by_decision_key);
bool CheckEventTriggerThere(TriggerSet triggers, int x, int y, bool triggered_by_decision_key);
bool GetOnVehicle();
bool GetOffVehicle();
bool UpdateAirship();
void UpdateVehicleActions();
TeleportTarget teleport_target;
int last_encounter_idx = 0;
};
inline bool Game_Player::IsPendingTeleport() const {
return teleport_target.IsActive();
}
inline TeleportTarget Game_Player::GetTeleportTarget() const {
return teleport_target;
}
inline void Game_Player::ResetTeleportTarget(TeleportTarget tt) {
teleport_target = std::move(tt);
}
inline void Game_Player::SetMenuCalling(bool value) {
data()->menu_calling = value;
}
inline bool Game_Player::IsMenuCalling() const {
return data()->menu_calling;
}
inline void Game_Player::SetEncounterCalling(bool value) {
data()->encounter_calling = value;
}
inline bool Game_Player::IsEncounterCalling() const {
return data()->encounter_calling;
}
inline int Game_Player::GetTotalEncounterRate() const {
return data()->total_encounter_rate;
}
inline bool Game_Player::IsPanActive() const {
return GetPanX() != GetTargetPanX() || GetPanY() != GetTargetPanY();
}
inline bool Game_Player::IsPanLocked() const {
return data()->pan_state == lcf::rpg::SavePartyLocation::PanState_fixed;
}
inline int Game_Player::GetPanX() const {
return data()->pan_current_x;
}
inline int Game_Player::GetPanY() const {
return data()->pan_current_y;
}
inline int Game_Player::GetTargetPanX() const {
return data()->pan_finish_x;
}
inline int Game_Player::GetTargetPanY() const {
return data()->pan_finish_y;
}
inline bool Game_Player::IsMapCompatibleWithSave(int map_save_count) const {
return data()->map_save_count == map_save_count;
}
inline bool Game_Player::IsDatabaseCompatibleWithSave(int database_save_count) const {
return data()->database_save_count == database_save_count;
}
inline void Game_Player::UpdateSaveCounts(int db_save_count, int map_save_count) {
data()->database_save_count = db_save_count;
data()->map_save_count = map_save_count;
}
inline bool Game_Player::IsVisible() const {
return !IsAboard() && Game_Character::IsVisible();
}
inline int Game_Player::GetVehicleType() const {
return data()->vehicle;
}
#endif