creature.h

main 129 lines · 2.7 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_CREATURE_H_
19#define RME_CREATURE_H_
20
21#include "creatures.h"
22
23enum Direction {
24 NORTH = 0,
25 EAST = 1,
26 SOUTH = 2,
27 WEST = 3,
28
29 DIRECTION_FIRST = NORTH,
30 DIRECTION_LAST = WEST
31};
32
33IMPLEMENT_INCREMENT_OP(Direction)
34
35class Creature {
36public:
37 Creature(CreatureType* ctype);
38 Creature(std::string type_name);
39 ~Creature();
40
41 // Static conversions
42 static std::string DirID2Name(uint16_t id);
43 static uint16_t DirName2ID(std::string id);
44
45 Creature* deepCopy() const;
46
47 const Outfit& getLookType() const;
48
49 bool isSaved();
50 void save();
51 void reset();
52
53 bool isSelected() const {
54 return selected;
55 }
56 void deselect() {
57 selected = false;
58 }
59 void select() {
60 selected = true;
61 }
62
63 bool isNpc() const;
64
65 std::string getName() const;
66 CreatureBrush* getBrush() const;
67
68 int getSpawnTime() const {
69 return spawntime;
70 }
71 void setSpawnTime(int spawntime) {
72 this->spawntime = spawntime;
73 }
74
75 Direction getDirection() const {
76 return direction;
77 }
78 void setDirection(Direction direction) {
79 this->direction = direction;
80 }
81
82protected:
83 std::string type_name;
84 Direction direction;
85 int spawntime;
86 bool saved;
87 bool selected;
88};
89
90inline void Creature::save() {
91 saved = true;
92}
93
94inline void Creature::reset() {
95 saved = false;
96}
97
98inline bool Creature::isSaved() {
99 return saved;
100}
101
102inline bool Creature::isNpc() const {
103 CreatureType* type = g_creatures[type_name];
104 if (type) {
105 return type->isNpc;
106 }
107 return false;
108}
109
110inline std::string Creature::getName() const {
111 CreatureType* type = g_creatures[type_name];
112 if (type) {
113 return type->name;
114 }
115 return "";
116}
117inline CreatureBrush* Creature::getBrush() const {
118 CreatureType* type = g_creatures[type_name];
119 if (type) {
120 return type->brush;
121 }
122 return nullptr;
123}
124
125typedef std::vector<Creature*> CreatureVector;
126typedef std::list<Creature*> CreatureList;
127
128#endif
129
Top