-
Notifications
You must be signed in to change notification settings - Fork 172
/
gameGlobalInfo.h
126 lines (107 loc) · 3.6 KB
/
gameGlobalInfo.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
#ifndef GAME_GLOBAL_INFO_H
#define GAME_GLOBAL_INFO_H
#include "spaceObjects/playerSpaceship.h"
#include "script.h"
#include "GMScriptCallback.h"
#include "GMMessage.h"
#include "gameStateLogger.h"
class GameStateLogger;
class GameGlobalInfo;
extern P<GameGlobalInfo> gameGlobalInfo;
enum EPlayerWarpJumpDrive
{
PWJ_ShipDefault = 0,
PWJ_WarpDrive,
PWJ_JumpDrive,
PWJ_WarpAndJumpDrive,
PWJ_None,
PWJ_MAX,
};
enum EScanningComplexity
{
SC_None = 0,
SC_Simple,
SC_Normal,
SC_Advanced,
};
enum EHackingGames
{
HG_Mine,
HG_Lights,
HG_All
};
class GameGlobalInfo : public MultiplayerObject, public Updatable
{
P<GameStateLogger> state_logger;
public:
/*!
* \brief Maximum number of player ships.
*/
static const int max_player_ships = 32;
private:
int victory_faction;
int32_t playerShipId[max_player_ships];
int callsign_counter;
/*!
* \brief List of known scripts
*/
PVector<Script> script_list;
public:
string global_message;
float global_message_timeout;
string banner_string;
std::vector<float> reputation_points;
EScanningComplexity scanning_complexity;
//Hacking difficulty ranges from 0 to 3
int hacking_difficulty;
EHackingGames hacking_games;
bool use_beam_shield_frequencies;
bool use_system_damage;
bool allow_main_screen_tactical_radar;
bool allow_main_screen_long_range_radar;
string gm_control_code;
float elapsed_time;
string scenario;
std::unordered_map<string, string> scenario_settings;
//List of script functions that can be called from the GM interface (Server only!)
std::list<GMScriptCallback> gm_callback_functions;
std::list<GMMessage> gm_messages;
//When active, all comms request goto the GM as chat, and normal scripted converstations are disabled. This does not disallow player<->player ship comms.
bool intercept_all_comms_to_gm;
//Callback called when a new player ship is created on the ship selection screen.
ScriptSimpleCallback on_new_player_ship;
bool allow_new_player_ships = true;
std::function<void(glm::vec2)> on_gm_click;
GameGlobalInfo();
virtual ~GameGlobalInfo();
P<PlayerSpaceship> getPlayerShip(int index);
void setPlayerShip(int index, P<PlayerSpaceship> ship);
int findPlayerShip(P<PlayerSpaceship> ship);
int insertPlayerShip(P<PlayerSpaceship> ship);
/*!
* \brief Set a faction to victorious.
* \param string Name of the faction that won.
*/
void setVictory(string faction_name) { victory_faction = FactionInfo::findFactionId(faction_name); }
/*!
* \brief Get ID of faction that won.
* \param int
*/
int getVictoryFactionId() { return victory_faction; }
void addScript(P<Script> script);
//Reset the global game state (called when we want to load a new scenario, and clear out this one)
void reset();
void setScenarioSettings(const string filename, std::unordered_map<string, string> new_settings);
void startScenario(string filename, std::unordered_map<string, string> new_settings = {});
virtual void update(float delta) override;
virtual void destroy() override;
string getMissionTime();
string getNextShipCallsign();
};
string getSectorName(glm::vec2 position);
glm::vec2 sectorToXY(string sectorName);
REGISTER_MULTIPLAYER_ENUM(EScanningComplexity);
REGISTER_MULTIPLAYER_ENUM(EHackingGames);
template<> int convert<EScanningComplexity>::returnType(lua_State* L, EScanningComplexity complexity);
template<> int convert<EHackingGames>::returnType(lua_State* L, EHackingGames games);
#endif//GAME_GLOBAL_INFO_H