1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-08 03:42:35 +01:00
openrw/rwengine/include/engine/GameState.hpp

195 lines
3.7 KiB
C++
Raw Normal View History

2014-07-25 04:30:44 +02:00
#pragma once
#ifndef _GAMESTATE_HPP_
#define _GAMESTATE_HPP_
#include <glm/glm.hpp>
2015-01-26 02:16:25 +01:00
#include <glm/gtx/quaternion.hpp>
#include <string>
#include <map>
2014-07-30 16:48:51 +02:00
#include <vector>
#include <objects/ObjectTypes.hpp>
2014-07-25 04:30:44 +02:00
class GameWorld;
2014-12-17 01:39:52 +01:00
class GameObject;
2014-07-25 04:30:44 +02:00
class PlayerController;
struct CutsceneData;
2014-07-25 04:30:44 +02:00
2014-07-30 16:48:51 +02:00
struct TextDisplayData
{
// This is set by the final display text command.
std::string text;
glm::vec2 position;
glm::vec4 colourFG;
glm::vec4 colourBG;
};
2014-12-16 20:17:22 +01:00
struct OnscreenText
{
2014-12-17 01:39:52 +01:00
std::string id;
2014-12-16 20:17:22 +01:00
std::string osTextString;
float osTextStart;
float osTextTime;
unsigned short osTextStyle;
enum /*TextStyle*/
{
/// Used for subtitles
HighPriority = 0,
/// Mission completed message
CenterBig = 1,
/// Right aligned mission names
MissionName = 2,
/// Help text (top left, black background)
Help = 12
};
2014-12-16 20:17:22 +01:00
};
/**
* Stores information about where the game can generate vehicles.
*/
struct VehicleGenerator
{
glm::vec3 position;
float heading;
/** ID of the vehicle to spawn, or -1 for random. */
int vehicleID;
int colourFG;
int colourBG;
bool alwaysSpawn;
short alarmThreshold;
short lockedThreshold;
int minDelay;
int maxDelay;
/** Incrementing timer (in ms), will only spawn a vehicle when minDelay < spawnTimer and will always spawn if maxDelay < spawnTimer */
int lastSpawnTime;
/** Number of vehicles left to spawn 0-100, 101 = never decrement. */
int remainingSpawns;
};
2015-01-26 02:16:25 +01:00
/**
* Data about a blip
*/
struct BlipData
{
int id;
GameObject* target;
// If target is null then use coord
glm::vec3 coord;
/* Texture for use in the radar */
std::string texture;
2015-01-27 01:48:09 +01:00
enum DisplayMode
{
Hide = 0,
RadarOnly = 1,
Show = 2
};
/* Should the blip be displayed? */
DisplayMode display;
BlipData()
: id(-1), target(nullptr), display(Show)
{ }
2015-01-26 02:16:25 +01:00
};
/**
* Gameplay state object that holds persistent state, and references runtime
* world state.
*/
2014-07-25 04:30:44 +02:00
struct GameState
{
unsigned int currentProgress;
2014-07-25 04:30:44 +02:00
unsigned int maxProgress;
unsigned int numMissions;
unsigned int numHiddenPackages;
unsigned int numHiddenPackagesDiscovered;
2014-07-25 04:30:44 +02:00
unsigned int numUniqueJumps;
unsigned int numRampages;
unsigned int maxWantedLevel;
PlayerController* player;
GameObjectID playerObject;
2014-07-25 04:30:44 +02:00
unsigned int currentWeather;
2014-07-25 04:30:44 +02:00
/**
* @brief Stores a pointer to script global that stores the on-mission state.
*/
unsigned int *scriptOnMissionFlag;
2015-03-30 04:34:03 +02:00
/** Objects created by the current mission */
std::vector<GameObjectID> missionObjects;
2015-03-30 04:34:03 +02:00
bool overrideNextStart;
glm::vec4 nextRestartLocation;
2014-07-25 04:30:44 +02:00
bool fadeOut;
float fadeStart;
2014-07-25 04:30:44 +02:00
float fadeTime;
bool fadeSound;
glm::u16vec3 fadeColour;
2014-08-01 23:03:00 +02:00
std::string currentSplash;
2014-12-17 01:39:52 +01:00
bool skipCutscene;
2014-07-25 04:30:44 +02:00
bool isIntroPlaying;
CutsceneData* currentCutscene;
float cutsceneStartTime;
2014-12-16 20:17:22 +01:00
/** Flag for rendering cutscene letterbox */
bool isCinematic;
short hour;
short minute;
2014-12-16 20:17:22 +01:00
std::string lastMissionName;
2014-12-16 20:17:22 +01:00
/// Stores the "special" character and cutscene model indices.
std::map<unsigned short, std::string> specialCharacters;
std::map<unsigned short, std::string> specialModels;
/**
* Stores long-lasting on screen messages
*/
2014-12-16 20:17:22 +01:00
std::vector<OnscreenText> text;
2014-07-30 16:48:51 +02:00
TextDisplayData nextText;
/**
* Stores temporary, one-tick messages
*/
2014-07-30 16:48:51 +02:00
std::vector<TextDisplayData> texts;
/** The camera near value currently set by the script */
float cameraNear;
2014-12-16 20:17:22 +01:00
bool cameraFixed;
glm::vec3 cameraPosition;
glm::quat cameraRotation;
GameObjectID cameraTarget;
2014-12-17 01:39:52 +01:00
std::vector<VehicleGenerator> vehicleGenerators;
2015-01-26 02:16:25 +01:00
std::map<int, BlipData> radarBlips;
/**
* World to use for this state, this isn't saved, just used at runtime
*/
GameWorld* world;
GameState();
2015-01-26 02:16:25 +01:00
/**
* Adds a blip to the state, returning it's ID.
*/
int addRadarBlip(BlipData& blip);
/**
* Removes a blip
*/
void removeBlip(int blip);
2014-07-25 04:30:44 +02:00
};
#endif