doodad_brush.h

main 143 lines · 3.5 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_DOODAD_BRUSH_H
19#define RME_DOODAD_BRUSH_H
20
21#include "brush.h"
22
23//=============================================================================
24// Doodadbrush, add doodads!
25
26typedef std::vector<std::pair<Position, ItemVector>> CompositeTileList;
27
28class DoodadBrush : public Brush {
29public:
30 DoodadBrush();
31 virtual ~DoodadBrush();
32
33 bool isDoodad() const {
34 return true;
35 }
36 DoodadBrush* asDoodad() {
37 return static_cast<DoodadBrush*>(this);
38 }
39
40protected:
41 struct AlternativeBlock;
42
43public:
44 bool loadAlternative(pugi::xml_node node, wxArrayString& warnings, AlternativeBlock* which = nullptr);
45 virtual bool load(pugi::xml_node node, wxArrayString& warnings);
46
47 virtual bool canDraw(BaseMap* map, const Position& position) const {
48 return true;
49 }
50 virtual void draw(BaseMap* map, Tile* tile, void* parameter);
51 const CompositeTileList& getComposite(int variation) const;
52 virtual void undraw(BaseMap* map, Tile* tile);
53
54 bool isEmpty(int variation) const;
55
56 int getThickness() const {
57 return thickness;
58 }
59 int getThicknessCeiling() const {
60 return thickness_ceiling;
61 }
62
63 int getCompositeChance(int variation) const;
64 int getSingleChance(int variation) const;
65 int getTotalChance(int variation) const;
66
67 bool hasSingleObjects(int variation) const;
68 bool hasCompositeObjects(int variation) const;
69
70 bool placeOnBlocking() const {
71 return on_blocking;
72 }
73 bool placeOnDuplicate() const {
74 return on_duplicate;
75 }
76 bool doNewBorders() const {
77 return do_new_borders;
78 }
79 bool ownsItem(Item* item) const;
80
81 virtual bool canSmear() const {
82 return draggable;
83 }
84 virtual bool canDrag() const {
85 return false;
86 }
87 virtual bool oneSizeFitsAll() const {
88 return one_size;
89 }
90 virtual int getLookID() const {
91 return look_id;
92 }
93 virtual int getMaxVariation() const {
94 return alternatives.size();
95 }
96 virtual std::string getName() const {
97 return name;
98 }
99 virtual void setName(const std::string& newName) {
100 name = newName;
101 }
102
103protected:
104 std::string name;
105 uint16_t look_id;
106
107 int thickness;
108 int thickness_ceiling;
109
110 bool draggable;
111 bool on_blocking;
112 bool one_size;
113 bool do_new_borders;
114 bool on_duplicate;
115 uint16_t clear_mapflags;
116 uint16_t clear_statflags;
117
118 struct SingleBlock {
119 int chance;
120 Item* item;
121 };
122
123 struct CompositeBlock {
124 int chance;
125 CompositeTileList items;
126 };
127
128 struct AlternativeBlock {
129 AlternativeBlock();
130 ~AlternativeBlock();
131 bool ownsItem(uint16_t id) const;
132 std::vector<SingleBlock> single_items;
133 std::vector<CompositeBlock> composite_items;
134
135 int composite_chance; // Total chance of a composite
136 int single_chance; // Total chance of a single object
137 };
138
139 std::vector<AlternativeBlock*> alternatives;
140};
141
142#endif
143
Top