WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
WorldObject.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_WORLDOBJECT_HPP
3 #define WORLDSIM_WORLDOBJECT_HPP
4 
5 /* WorldObject.hpp
6  #include"WorldObject.hpp"
7 
8  A World Object is an object which can have some physical presence on a map. Therefore
9  items, weapons, creatures and NPCs are all World Objects. This interface provides the
10  basic functions for providing information on the object's location and how to render it.
11 
12  WorldObject deals with local map objects. Objects on the global map are handled with
13  WorldObjectGlobal.
14 */
15 
16 #include <Interface/HasTexture.hpp>
17 
18 class WorldObject: public HasTexture
19 {
20  public:
21 
22  short int x, y;
23 
24  bool isUnderground; /* True if the object is on the subterranean layer */
25 
26  //Implementing full global coordinates to make life easier for now.
27  // This datatype should be able to hold coordinates for any reasonably-sized world.
28  long unsigned int fullX, fullY;
29 
30 
31  /* TEMPORARY WORKAROUND TO ALLOW CHARACTERS TO MOVE ACROSS MAPS.
32  CURRENTLY ONLY USED FOR CHARACTERS
33  In future World_Local should distinguish between actors and objects */
34  int worldX, worldY;
35 
36  bool stackable; /* True if multiple objects of this class can be merged together into a single stack, sharing their data. */
37 
38  double weight; /* in grams */
39  double bulk; /* In cm^3 , and adjusted higher for cumbersome items.*/
40 
41  /* True if line of sight cannot pass this object.
42  Might be expanded in future. For example maybe a
43  crate will block view of people who are sneaking. */
44  bool blocksView;
45 
46  /* True if characters and creatures cannot walk into this tile. */
48 
49  // INTERACTIONS
50  // Should probably be moved down the heirarchy.
51  bool canCook; /* This object can be used for cooking. */
52  int chopAmount; /* -1 if chopping is not possible. */
53  bool canHarvest; /* Probably should be put into a Harvestable interface */
54 
55  WorldObject();
56  virtual ~WorldObject() {}
57 
58 
59  virtual std::string getName();
60  virtual std::string getExtendedInfo() { return "N/A"; }
61 
62  // move object 1 tile in random direction, confined to local map
63  virtual void wander();
64 
65  // DISTANCES
66  // We should add manhattan and normal
67  int distanceTo(WorldObject*); /* Chebyshev (this one is distances where diagonal movement is allowed.) */
68  int distanceFrom(WorldObject*); /* Alias. */
69 
70  int distanceTo(int /* _x */, int /* _y */); /* Same, using raw coordinates */
71 
72  virtual Texture* currentTexture();
73 
74  std::string getBaseData();
75 
76  std::string getSaveData();
77  void loadData(std::string);
78 };
79 
80 
81 
82 
83 #endif
double bulk
Definition: WorldObject.hpp:39
Definition: WorldObject.hpp:18
bool canHarvest
Definition: WorldObject.hpp:53
int worldX
Definition: WorldObject.hpp:34
bool canCook
Definition: WorldObject.hpp:51
virtual Texture * currentTexture()
Definition: WorldObject.cpp:97
std::string getSaveData()
Definition: WorldObject.cpp:120
bool blocksView
Definition: WorldObject.hpp:44
int distanceTo(WorldObject *)
Definition: WorldObject.cpp:85
bool isUnderground
Definition: WorldObject.hpp:24
virtual ~WorldObject()
Definition: WorldObject.hpp:56
std::string getBaseData()
Definition: WorldObject.cpp:102
int chopAmount
Definition: WorldObject.hpp:52
virtual std::string getExtendedInfo()
Definition: WorldObject.hpp:60
virtual void wander()
Definition: WorldObject.cpp:37
short int y
Definition: WorldObject.hpp:22
virtual std::string getName()
Definition: WorldObject.cpp:32
int worldY
Definition: WorldObject.hpp:34
long unsigned int fullY
Definition: WorldObject.hpp:28
short int x
Definition: WorldObject.hpp:22
bool stackable
Definition: WorldObject.hpp:36
int distanceFrom(WorldObject *)
Definition: WorldObject.cpp:90
WorldObject()
Definition: WorldObject.cpp:13
double weight
Definition: WorldObject.hpp:38
long unsigned int fullX
Definition: WorldObject.hpp:28
bool blocksMovement
Definition: WorldObject.hpp:47
void loadData(std::string)
Definition: WorldObject.cpp:127