aboutsummaryrefslogtreecommitdiffstats
path: root/include/mob.hpp
blob: 450cf69262d737e1a93c09d61b78d6c9cc5df8b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef MOB_H_
#define MOB_H_

#include <forward_list>
#include <tuple>

#include <common.hpp>
#include <entities.hpp>
#include <gametime.hpp>
#include <ui.hpp>

// local library headers
#include <tinyxml2.h>
using namespace tinyxml2;

extern Player *player;
extern std::string currentXML;

using Drop = std::tuple<std::string, unsigned int, float>;

class Mob : public Entity {
protected:
	XMLElement *xmle;
	std::forward_list<Drop> drop;

    unsigned int actCounter;
    unsigned int actCounterInitial;
    bool ridable;
public:
    Entity *rider;
	bool aggressive;
	std::string heyid;

    Mob(void);
    ~Mob(void);

	void wander(void);
    void ride(Entity *e);
    virtual void act(void) =0;

	virtual void onHit(unsigned int) =0;
	virtual void onDeath(void);

    virtual bool bindTex(void) =0;
};

constexpr Mob *Mobp(Entity *e) {
    return (Mob *)e;
}

class Page : public Mob {
private:
	std::string cId, cValue;
    std::string pageTexPath;
    GLuint pageTexture;
public:
    Page(void);

    void act(void);
	void onHit(unsigned int);
    bool bindTex(void);
    void createFromXML(XMLElement *e, World *w) final;
};

class Door : public Mob {
public:
    Door(void);

    void act(void);
	void onHit(unsigned int);
    bool bindTex(void);
    void createFromXML(XMLElement *e, World *w) final;
};

class Cat : public Mob {
public:
    Cat(void);

    void act(void);
	void onHit(unsigned int);
    bool bindTex(void);
	void createFromXML(XMLElement *e, World *w) final;
};

class Rabbit : public Mob {
public:
    Rabbit(void);

    void act(void);
	void onHit(unsigned int);
    bool bindTex(void);
    void createFromXML(XMLElement *e, World *w) final;
};

class Bird : public Mob {
private:
    float initialY;
public:
    Bird(void);

    void act(void);
	void onHit(unsigned int);
    bool bindTex(void);
    void createFromXML(XMLElement *e, World *w) final;
};

class Trigger : public Mob {
private:
    std::string id;
    bool triggered;
public:
    Trigger(void);

    void act(void);
	void onHit(unsigned int);
    bool bindTex(void);
    void createFromXML(XMLElement *e, World *w) final;
};

#endif // MOB_H_