| 1 | #include <string> |
|---|
| 2 | |
|---|
| 3 | class Ent { |
|---|
| 4 | protected: |
|---|
| 5 | Ent(uint16_t _entid) { |
|---|
| 6 | entid = _entid; |
|---|
| 7 | }; |
|---|
| 8 | private: |
|---|
| 9 | uint16_t entid; |
|---|
| 10 | public: |
|---|
| 11 | typedef enum { |
|---|
| 12 | Box, |
|---|
| 13 | Sphere, |
|---|
| 14 | Pad, |
|---|
| 15 | PlayerBall |
|---|
| 16 | } Class; |
|---|
| 17 | typedef Ent* (*createfct)(uint16_t); |
|---|
| 18 | uint16_t get_entid() { return entid; }; |
|---|
| 19 | virtual uint16_t get_classid() = 0; |
|---|
| 20 | virtual const std::string get_classname() = 0; |
|---|
| 21 | }; |
|---|
| 22 | |
|---|
| 23 | class Obj : public Ent { |
|---|
| 24 | protected: |
|---|
| 25 | Obj(uint16_t entid) : Ent(entid) {}; |
|---|
| 26 | }; |
|---|
| 27 | |
|---|
| 28 | class Box : public Obj { |
|---|
| 29 | protected: |
|---|
| 30 | Box(uint16_t entid) : Obj(entid) {}; |
|---|
| 31 | public: |
|---|
| 32 | virtual uint16_t get_classid() { return Ent::Box; }; |
|---|
| 33 | virtual const std::string get_classname() { return "Box"; }; |
|---|
| 34 | static Ent* create(uint16_t entid) { return new Box(entid); }; |
|---|
| 35 | }; |
|---|
| 36 | |
|---|
| 37 | class Pad : public Box { |
|---|
| 38 | protected: |
|---|
| 39 | Pad(uint16_t entid) : Box(entid) {}; |
|---|
| 40 | public: |
|---|
| 41 | virtual uint16_t get_classid() { return Ent::Pad; }; |
|---|
| 42 | virtual const std::string get_classname() { return "Pad"; }; |
|---|
| 43 | static Ent* create(uint16_t entid) { return new Pad(entid); }; |
|---|
| 44 | }; |
|---|
| 45 | |
|---|
| 46 | #define ENTLEAF(CLASS, CLASSID, CLASSNAME) \ |
|---|
| 47 | virtual uint16_t get_classid() { return Ent::CLASSID; };\ |
|---|
| 48 | virtual const std::string get_classname() { return CLASSNAME; }; \ |
|---|
| 49 | static Ent* create(uint16_t entid) { return new CLASS(entid); }; |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | class Sphere : public Ent { |
|---|
| 53 | protected: |
|---|
| 54 | Sphere(uint16_t entid) : Ent(entid) {}; |
|---|
| 55 | public: |
|---|
| 56 | ENTLEAF(Sphere, Sphere, "Sphere"); |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | class PBall : public Sphere { |
|---|
| 60 | protected: |
|---|
| 61 | PBall(uint16_t entid) : Sphere(entid) {}; |
|---|
| 62 | public: |
|---|
| 63 | ENTLEAF(PBall, PlayerBall, "PlayerBall"); |
|---|
| 64 | }; |
|---|