1 #ifndef GAME_GLOBAL_INFO_H 2 #define GAME_GLOBAL_INFO_H 3 4 #include "spaceObjects/playerSpaceship.h" 5 #include "script.h" 6 #include "GMScriptCallback.h" 7 #include "GMMessage.h" 8 #include "gameStateLogger.h" 9 10 class GameStateLogger; 11 class GameGlobalInfo; 12 extern P<GameGlobalInfo> gameGlobalInfo; 13 14 enum EPlayerWarpJumpDrive 15 { 16 PWJ_ShipDefault = 0, 17 PWJ_WarpDrive, 18 PWJ_JumpDrive, 19 PWJ_WarpAndJumpDrive, 20 PWJ_None, 21 PWJ_MAX, 22 }; 23 enum EScanningComplexity 24 { 25 SC_None = 0, 26 SC_Simple, 27 SC_Normal, 28 SC_Advanced, 29 }; 30 enum EHackingGames 31 { 32 HG_Mine, 33 HG_Lights, 34 HG_All 35 }; 36 37 class GameGlobalInfo : public MultiplayerObject, public Updatable 38 { 39 P<GameStateLogger> state_logger; 40 public: 41 /*! 42 * \brief Maximum number of player ships. 43 */ 44 static const int max_player_ships = 32; 45 private: 46 int victory_faction; 47 int32_t playerShipId[max_player_ships]; 48 int callsign_counter; 49 /*! 50 * \brief List of known scripts 51 */ 52 PVector<Script> script_list; 53 public: 54 string global_message; 55 float global_message_timeout; 56 57 string banner_string; 58 59 std::vector<float> reputation_points; 60 EPlayerWarpJumpDrive player_warp_jump_drive_setting; 61 EScanningComplexity scanning_complexity; 62 //Hacking difficulty ranges from 0 to 3 63 int hacking_difficulty; 64 EHackingGames hacking_games; 65 bool use_beam_shield_frequencies; 66 bool use_system_damage; 67 bool allow_main_screen_tactical_radar; 68 bool allow_main_screen_long_range_radar; 69 string gm_control_code; 70 float elapsed_time; 71 string scenario; 72 string variation = "None"; 73 74 //List of script functions that can be called from the GM interface (Server only!) 75 std::list<GMScriptCallback> gm_callback_functions; 76 std::list<GMMessage> gm_messages; 77 //When active, all comms request goto the GM as chat, and normal scripted converstations are disabled. This does not disallow player<->player ship comms. 78 bool intercept_all_comms_to_gm; 79 80 //Callback called when a new player ship is created on the ship selection screen. 81 ScriptSimpleCallback on_new_player_ship; 82 bool allow_new_player_ships = true; 83 84 std::function<void(sf::Vector2f)> on_gm_click; 85 86 GameGlobalInfo(); 87 virtual ~GameGlobalInfo(); 88 89 P<PlayerSpaceship> getPlayerShip(int index); 90 void setPlayerShip(int index, P<PlayerSpaceship> ship); 91 92 int findPlayerShip(P<PlayerSpaceship> ship); 93 int insertPlayerShip(P<PlayerSpaceship> ship); 94 /*! 95 * \brief Set a faction to victorious. 96 * \param string Name of the faction that won. 97 */ setVictory(string faction_name)98 void setVictory(string faction_name) { victory_faction = FactionInfo::findFactionId(faction_name); } 99 /*! 100 * \brief Get ID of faction that won. 101 * \param int 102 */ getVictoryFactionId()103 int getVictoryFactionId() { return victory_faction; } 104 105 void addScript(P<Script> script); 106 //Reset the global game state (called when we want to load a new scenario, and clear out this one) 107 void reset(); 108 void startScenario(string filename); 109 110 virtual void update(float delta); 111 virtual void destroy(); 112 113 string getNextShipCallsign(); 114 }; 115 116 string playerWarpJumpDriveToString(EPlayerWarpJumpDrive player_warp_jump_drive); 117 string getSectorName(sf::Vector2f position); 118 119 REGISTER_MULTIPLAYER_ENUM(EScanningComplexity); 120 REGISTER_MULTIPLAYER_ENUM(EHackingGames); 121 122 template<> int convert<EScanningComplexity>::returnType(lua_State* L, EScanningComplexity complexity); 123 template<> int convert<EHackingGames>::returnType(lua_State* L, EHackingGames games); 124 125 #endif//GAME_GLOBAL_INFO_H 126