aboutsummaryrefslogtreecommitdiffstats
path: root/include/entities.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/entities.hpp')
-rw-r--r--include/entities.hpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/include/entities.hpp b/include/entities.hpp
index ca4ef2b..5a8e19b 100644
--- a/include/entities.hpp
+++ b/include/entities.hpp
@@ -17,6 +17,10 @@
#include <inventory.hpp>
#include <texture.hpp>
+// local library includes
+#include <tinyxml2.h>
+using namespace tinyxml2;
+
/* ----------------------------------------------------------------------------
** Structures section
** --------------------------------------------------------------------------*/
@@ -187,6 +191,10 @@ protected:
// the max cooldown display
float maxHitDuration;
+
+ // the entity's XML element, for saving/loading stuff
+ XMLElement *xmle;
+
public:
// contains the entity's coordinates, in pixels
vec2 loc;
@@ -235,7 +243,7 @@ public:
int subtype;
// the entity's name, randomly generated on spawn
- char *name;
+ std::string name;
// the entity's gender
GENDER gender;
@@ -289,6 +297,9 @@ public:
// returns true if the coordinate is within the entity
bool isInside(vec2 coord) const;
+ // constructs the entity with an XML thing-thang
+ virtual void createFromXML(XMLElement *e, World *w=nullptr) =0;
+
// a common constructor, clears variables
Entity(void);
@@ -296,7 +307,7 @@ public:
virtual ~Entity(){}
};
-class Player : public Entity{
+class Player : public Entity {
public:
Entity *ride;
QuestHandler qh;
@@ -305,9 +316,10 @@ public:
~Player();
void save(void);
void sspawn(float x,float y);
+ void createFromXML(XMLElement *e, World *w);
};
-class Structures : public Entity{
+class Structures : public Entity {
public:
BUILD_SUB bsubtype;
World *inWorld;
@@ -318,6 +330,7 @@ public:
~Structures();
unsigned int spawn(BUILD_SUB, float, float);
+ void createFromXML(XMLElement *e, World *w);
};
@@ -340,6 +353,7 @@ public:
virtual void interact();
virtual void wander(int);
+ void createFromXML(XMLElement *e, World *w);
};
class Merchant : public NPC {
@@ -379,8 +393,9 @@ public:
void interact(void);
bool operator==(const Object &o) {
- return !strcmp(name, o.name) && (loc == o.loc);
+ return (name == o.name) && (loc == o.loc);
}
+ void createFromXML(XMLElement *e, World *w);
};
/**
@@ -414,6 +429,8 @@ public:
void makeFlame(void){
flame = true;
}
+
+ void createFromXML(XMLElement *e);
};
#include <mob.hpp>