mElite  1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
World.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <vector>
9 #include <string>
10 #include <list>
11 #include "Structures.h"
12 
13 class MovingObject;
14 class Planet;
15 class Wrapper;
16 class SpaceShip;
17 class ForeignSpaceShip;
18 class Thargon;
19 class Pirate;
20 class Merchant;
21 class PoliceShip;
22 class GraphicsObject;
23 class PlayerObject;
24 class GameObject;
25 class Star;
26 class Planet;
27 class SpaceStation;
28 
30 
37 class World {
38  // singleton stuff
39 public:
40  static World * getWorld( void );
41  ~World( void );
42 private:
43  World( void );
44  static class World *m_world;
45 
46  // object handling
47 public:
48  void initialize();
49  void deinitialize();
51  Star * getStar();
52  std::vector<Planet*> * getPlanets();
54 
55  SpaceShip * createNewSpaceShip( ObjectName objectType, float radius );
56  Thargon * createNewThargon( ObjectName objectType, float radius, PlayerObject *player, float maxSpeed );
57  Pirate * createNewPirate( ObjectName objectType, float radius, PlayerObject *player, float maxSpeed );
58  Merchant * createNewMerchant( ObjectName objectType, float radius, Planet *planet, Vector3 aim );
59  PoliceShip * createNewPoliceShip( ObjectName objectType, float radius, std::vector<Vector3> point, PlayerObject * player, float maxSpeed );
60 
61  std::vector<GraphicsObject*> * getGraphicObjects();
62  std::vector<SpaceShip*> * getSpaceShips();
63  std::vector<ForeignSpaceShip*> * getForeignSpaceShips();
64  std::vector <PoliceShip*> * getPoliceShips();
65 
66  void deleteCrashedShips( void );
67  void deleteDestroyedShips( void );
68 private:
69 
70  std::list<GameObject*> GameObjects;
71  std::list<GameObject*>::iterator playerPosition;
72  std::list<GameObject*>::iterator starPosition;
73  std::list<GameObject*>::iterator stationPosition;
74 
75  // these are stored here to be consistent until the new code is completed
76  // contains all objects that are drawable
77  std::vector<GraphicsObject*> m_drawable; // a list of all drawable objects in the scene
78  // contains all objects that move
79  std::vector<MovingObject*> m_moving;
80 
81  unsigned long playerStartDistance;
82  unsigned int nrForCoriolis[256];
83 
84  // information about the systems - submitted by wrapper or selfcreated
85 public:
86  SystemInfo getSystemInfo( void );
87  SystemInfo getSystemInfo( unsigned __int8 number );
88  std::string getSystemName( int number );
89  std::vector<PlanetInfoGraphical> * getSystemPlanets( void );
90  std::vector<PlanetInfoGraphical> * getSystemPlanets( unsigned __int8 number );
91  std::vector<SystemInfo> *getSystems( SystemLists systemList );
92  std::vector<SystemInfo> *getSystems( int left, int right, int bottom, int top );
94  TextureName getSystemStarTexture( unsigned __int8 number );
95  bool isSystemReachable( int number );
96  bool isSystemLocal( int number );
97  void World::performJump( int number );
98 private:
99  TextureName getPlanetTexture( unsigned __int8 number );
100  TextureName getPlanetTextureR( bool reset );
101  TextureName getStarTexture( unsigned __int8 number );
102  TextureName getStarTextureR( void );
103  std::vector<PlanetInfoGraphical> * getSystemPlanetsR( void ); // create randomly an system info
104  std::vector<PlanetInfoGraphical> *systemPlanets[256];// array of vectors wich holds the informations about all 256 systems
105  std::vector<TextureName> systemStars;
106 
107  // marketplace and fuel
108 public:
109  void buyFuel( float amount );
110  std::vector<Tradegood> * getAllTradegoodDescriptions( void );
111  unsigned int getCargoBaySize( void );
112  float getCurrentCash( void );
113  std::vector<int> * getCurrentCargo( void );
114  std::vector<MarketplaceItem> * getCurrentMarketplace( void );
115  unsigned int getFreeHoldspace( void );
116  int getNumberOfTradegoods( void );
118  std::string performPurchase( int number, int amount );
119  std::string performSale( int number, int amount );
120 
121  float getFuelCost();
122  float getFuelAmount();
123  float getMaxFuel();
124  bool tradegoodIsInTons(int number);
125 
126  // player status
127 public:
128  PlayerStatus * getPlayerStatus( void );
129 private:
130  PlayerStatus * m_playerStatus;
131 
132  // some helping stuff
133 public:
134  std::string getEconomyString( econTypes economy );
135  std::string getGovernmentString( govTypes government );
136 private:
137  unsigned int getRandNumber( unsigned int min, unsigned int max );
138  Wrapper *wrapper;
139  friend void error1( std::string error );
140  friend void error2( std::string error );
141 };