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#include "main.h"
19
20#include "creature.h"
21
22Creature::Creature(CreatureType* ctype) :
23 direction(SOUTH), spawntime(0), saved(false), selected(false) {
24 if (ctype) {
25 type_name = ctype->name;
26 }
27}
28
29Creature::Creature(std::string ctype_name) :
30 type_name(ctype_name), direction(SOUTH), spawntime(0), saved(false), selected(false) {
31 ////
32}
33
34Creature::~Creature() {
35 ////
36}
37
38std::string Creature::DirID2Name(uint16_t id) {
39 switch (id) {
40 case NORTH:
41 return "North";
42 case EAST:
43 return "East";
44 case SOUTH:
45 return "South";
46 case WEST:
47 return "West";
48 default:
49 return "Unknown";
50 }
51}
52
53uint16_t Creature::DirName2ID(std::string dir) {
54 to_lower_str(dir);
55 if (dir == "north") {
56 return NORTH;
57 }
58 if (dir == "east") {
59 return EAST;
60 }
61 if (dir == "south") {
62 return SOUTH;
63 }
64 if (dir == "west") {
65 return WEST;
66 }
67 return SOUTH;
68}
69
70Creature* Creature::deepCopy() const {
71 Creature* copy = newd Creature(type_name);
72 copy->spawntime = spawntime;
73 copy->direction = direction;
74 copy->selected = selected;
75 copy->saved = saved;
76 return copy;
77}
78
79const Outfit& Creature::getLookType() const {
80 CreatureType* type = g_creatures[type_name];
81 if (type) {
82 return type->outfit;
83 }
84 static const Outfit otfi; // Empty outfit
85 return otfi;
86}
87