forked from twig33/ynoclient
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgame_vehicle.h
136 lines (111 loc) · 3.46 KB
/
game_vehicle.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
/*
* 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_VEHICLE_H
#define EP_GAME_VEHICLE_H
// Headers
#include <string>
#include <lcf/rpg/music.h>
#include <lcf/rpg/savevehiclelocation.h>
#include "game_character.h"
using Game_VehicleBase = Game_CharacterDataStorage<lcf::rpg::SaveVehicleLocation>;
/**
* Game_Vehicle class.
*/
class Game_Vehicle : public Game_VehicleBase {
public:
enum Type {
None = 0,
Boat,
Ship,
Airship
};
static const char TypeNames[4][8];
explicit Game_Vehicle(Type type);
/** Load from saved game */
void SetSaveData(lcf::rpg::SaveVehicleLocation save);
/** @return save game data */
lcf::rpg::SaveVehicleLocation GetSaveData() const;
/**
* Implementation of abstract methods
*/
/** @{ */
void UpdateNextMovementAction() override;
void UpdateAnimation() override;
/** @} */
/** Update this for the current frame */
void Update();
const lcf::rpg::Music& GetBGM();
int GetVehicleType() const;
bool IsInCurrentMap() const;
bool IsInPosition(int x, int y) const override;
bool IsVisible() const override;
bool IsAscending() const;
bool IsDescending() const;
bool IsAscendingOrDescending() const;
int GetAltitude() const;
bool IsInUse() const;
bool IsAboard() const;
void SyncWithRider(const Game_Character* rider);
bool AnimateAscentDescent();
int GetScreenY(bool apply_shift = false, bool apply_jump = true) const override;
bool CanLand() const;
void StartAscent();
void StartDescent();
void SetDefaultDirection();
void ForceLand();
/**
* Sets default sprite name. Usually the name of the graphic file.
*
* @param sprite_name new sprite name
* @param index the index of the new sprite.
*/
void SetOrigSpriteGraphic(std::string sprite_name, int index);
/** Gets the original sprite graphic name */
StringView GetOrigSpriteName() const;
/** Gets the original sprite graphic index */
int GetOrigSpriteIndex() const;
};
inline void Game_Vehicle::SetOrigSpriteGraphic(std::string sprite_name, int index) {
data()->orig_sprite_name = std::move(sprite_name);
data()->orig_sprite_id = index;
}
inline lcf::rpg::SaveVehicleLocation Game_Vehicle::GetSaveData() const {
return *data();
}
inline bool Game_Vehicle::IsInPosition(int x, int y) const {
return IsInCurrentMap() && Game_Character::IsInPosition(x, y);
}
inline bool Game_Vehicle::IsAscending() const {
return data()->remaining_ascent > 0;
}
inline bool Game_Vehicle::IsDescending() const {
return data()->remaining_descent > 0;
}
inline bool Game_Vehicle::IsAscendingOrDescending() const {
return IsAscending() || IsDescending();
}
inline bool Game_Vehicle::IsVisible() const {
return IsInCurrentMap() && Game_Character::IsVisible();
}
inline void Game_Vehicle::SetDefaultDirection() {
SetDirection(Left);
SetFacing(Left);
}
inline int Game_Vehicle::GetVehicleType() const {
return data()->vehicle;
}
#endif