WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
WorldObjectGlobal.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef GUILD_WORLDOBJECTGLOBAL_HPP
3 #define GUILD_WORLDOBJECTGLOBAL_HPP
4 
5 /* WorldSim: WorldObjectGlobal.hpp
6  #include "WorldObjectGlobal.hpp"
7 
8  Description:
9  Interface for objects which have a presence on the world map. Stuff like Armies, Tribes, Cities, etc.
10 
11 */
12 
13 #include <Interface/HasTexture.hpp>
14 
15 class World;
16 
17 class WorldObjectGlobal: public HasTexture
18 {
19  private:
20 
21  public:
22  int worldX, worldY; /* Coordinates on the world map. */
23  World* world; /* Link with the world. */
24 
25  std::string name;
26  std::string nameType; /* The category of this object */
27 
29 
30 
32  int type;
33 
34  //std::string name;
35 
36  /* RETURN THE NAME OF THE OBJECT. EXAMPLES:
37  CITY - ADELAIDE.
38  ARMY - IV LEGION.
39  */
40  virtual std::string getName() { return "?"; }
41 
42  /* RETURN MULTI-LINE INFO. TBD. */
43  virtual std::string getExtendedInfo() { return "?"; }
44 
45  // RETURN THE NUMBER OF TILES AWAY FROM THE OBJECT. THIS IS IN 'MOVES', INCLUDING DIAGONALS.
47  {
48  int xChange = worldX - _obj->worldX;
49  int yChange = worldY - _obj->worldY;
50 
51  if ( xChange < 0 )
52  { xChange*=-1; }
53  if ( yChange < 0 )
54  { yChange*=-1; }
55 
56  return (xChange+yChange);
57  }
58 
59  bool isOnMap(int _x, int _y)
60  {
61  return (worldX == _x && worldY == _y);
62  }
63 
65  {
66  }
67 
68 
69  // TextureInterface::
70  //virtual Texture* currentTexture() { return 0; }
71 
72 };
73 
74 #endif
WorldObjectGlobal()
Definition: WorldObjectGlobal.cpp:20
Definition: WorldObjectGlobal.hpp:31
std::string nameType
Definition: WorldObjectGlobal.hpp:26
int type
Definition: WorldObjectGlobal.hpp:32
enumType
Definition: WorldObjectGlobal.hpp:31
Definition: WorldObjectGlobal.hpp:31
Definition: World.hpp:50
World * world
Definition: WorldObjectGlobal.hpp:23
Definition: WorldObjectGlobal.hpp:31
virtual std::string getExtendedInfo()
Definition: WorldObjectGlobal.hpp:43
Definition: WorldObjectGlobal.hpp:31
Definition: WorldObjectGlobal.hpp:31
Definition: WorldObjectGlobal.hpp:17
int worldY
Definition: WorldObjectGlobal.hpp:22
int worldX
Definition: WorldObjectGlobal.hpp:22
bool isOnMap(int _x, int _y)
Definition: WorldObjectGlobal.hpp:59
int distanceTo(WorldObjectGlobal *_obj)
Definition: WorldObjectGlobal.hpp:46
std::string name
Definition: WorldObjectGlobal.hpp:25
Definition: WorldObjectGlobal.hpp:31
virtual std::string getName()
Definition: WorldObjectGlobal.hpp:40
virtual ~WorldObjectGlobal()
Definition: WorldObjectGlobal.hpp:64