-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathcreature_factory.h
105 lines (89 loc) · 3.96 KB
/
creature_factory.h
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
/* Copyright (C) 2013-2014 Michal Brzozowski ([email protected])
This file is part of KeeperRL.
KeeperRL is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
KeeperRL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.gnu.org/licenses/ . */
#pragma once
#include "util.h"
#include "tribe.h"
#include "spell_school.h"
#include "creature_id.h"
#include "spell_school_id.h"
#include "creature_inventory.h"
class Creature;
class MonsterAIFactory;
class Tribe;
class ItemType;
class CreatureAttributes;
class ControllerFactory;
class NameGenerator;
class GameConfig;
struct CreatureInventoryElem;
using CreatureInventory = vector<CreatureInventoryElem>;
class SpellMap;
class ContentFactory;
class CreatureFactory {
public:
PCreature fromId(CreatureId, TribeId, const MonsterAIFactory&);
PCreature fromId(CreatureId, TribeId, const MonsterAIFactory&, const vector<ItemType>& inventory);
PCreature fromId(CreatureId, TribeId);
PCreature fromIdNoInventory(CreatureId, TribeId, const MonsterAIFactory&);
PCreature makeCopy(Creature*, const MonsterAIFactory&);
PCreature makeCopy(Creature*);
static PController getShopkeeper(vector<Vec2> shopArea, Creature*);
PCreature getAnimatedItem(const ContentFactory*, PItem, TribeId, int attrBonus);
static PCreature getHumanForTests();
PCreature getGhost(Creature*);
static PCreature getIllusion(Creature*);
static CreatureAttributes getKrakenAttributes(ViewId, const TString& name);
ViewIdList getViewId(CreatureId) const;
TString getName(CreatureId) const;
TString getNamePlural(CreatureId) const;
const Gender& getGender(CreatureId);
vector<CreatureId> getAllCreatures() const;
NameGenerator* getNameGenerator();
const map<SpellSchoolId, SpellSchool>& getSpellSchools() const;
const vector<Spell>& getSpells() const;
const Spell* getSpell(SpellId) const;
CreatureFactory(NameGenerator, map<CreatureId, CreatureAttributes>,
map<SpellSchoolId, SpellSchool>, vector<Spell>);
~CreatureFactory();
CreatureFactory(const CreatureFactory&) = delete;
CreatureFactory(CreatureFactory&&) noexcept;
CreatureFactory& operator = (CreatureFactory&&);
void merge(CreatureFactory);
void setContentFactory(const ContentFactory*) const;
SERIALIZATION_DECL(CreatureFactory)
struct SpecialParams {
bool humanoid;
bool large;
bool living;
bool wings;
CreatureInventory inventory;
};
static const map<CreatureId, SpecialParams>& getSpecialParams();
void initializeAttributes(optional<CreatureId>, CreatureAttributes&);
SpellMap getSpellMap(const CreatureAttributes&);
CreatureAttributes getAttributesFromId(CreatureId);
private:
void initSplash(TribeId);
static PCreature getSokobanBoulder(TribeId);
static PCreature getRollingBoulder(Vec2 direction);
PCreature getSpecial(CreatureId, TribeId, SpecialParams, const ControllerFactory&);
PCreature get(CreatureId, TribeId, MonsterAIFactory);
static PCreature get(CreatureAttributes, TribeId, const ControllerFactory&, SpellMap);
HeapAllocated<NameGenerator> SERIAL(nameGenerator);
map<CreatureId, CreatureAttributes> SERIAL(attributes);
vector<ItemType> getDefaultInventory(CreatureId) const;
map<SpellSchoolId, SpellSchool> SERIAL(spellSchools);
vector<Spell> SERIAL(spells);
void addInventory(Creature*, const vector<ItemType>& items);
mutable const ContentFactory* contentFactory = nullptr;
PCreature getSpirit(TribeId, MonsterAIFactory);
};
static_assert(std::is_nothrow_move_constructible<CreatureFactory>::value, "T should be noexcept MoveConstructible");