-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathtile_predicate.h
95 lines (75 loc) · 1.77 KB
/
tile_predicate.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
#pragma once
#include "stdafx.h"
#include "util.h"
#include "pretty_archive.h"
#include "layout_canvas.h"
using Token = string;
struct TilePredicate;
namespace TilePredicates {
struct On {
Token SERIAL(token);
SERIALIZE_ALL(roundBracket(), NAMED(token))
};
struct Not {
HeapAllocated<TilePredicate> SERIAL(predicate);
SERIALIZE_ALL(predicate)
};
struct True {
SERIALIZE_EMPTY()
};
struct And {
vector<TilePredicate> SERIAL(predicates);
SERIALIZE_ALL(withRoundBrackets(predicates))
};
struct Or {
vector<TilePredicate> SERIAL(predicates);
SERIALIZE_ALL(withRoundBrackets(predicates))
};
struct Chance {
double SERIAL(value);
SERIALIZE_ALL(roundBracket(), NAMED(value))
};
struct Area {
int SERIAL(radius);
HeapAllocated<TilePredicate> SERIAL(predicate);
int SERIAL(minCount) = 1;
SERIALIZE_ALL(roundBracket(), NAMED(radius), NAMED(predicate), OPTION(minCount))
};
struct XMod {
int SERIAL(div);
int SERIAL(mod);
SERIALIZE_ALL(roundBracket(), NAMED(div), NAMED(mod))
};
struct YMod {
int SERIAL(div);
int SERIAL(mod);
SERIALIZE_ALL(roundBracket(), NAMED(div), NAMED(mod))
};
struct Translate {
Vec2 SERIAL(offset);
HeapAllocated<TilePredicate> SERIAL(predicate);
SERIALIZE_ALL(roundBracket(), NAMED(offset), NAMED(predicate))
};
#define VARIANT_TYPES_LIST\
X(On, 0)\
X(Not, 1)\
X(True, 2)\
X(And, 3)\
X(Or, 4)\
X(Chance, 5)\
X(Area, 6)\
X(XMod, 7)\
X(YMod, 8)\
X(Translate, 9)\
#define VARIANT_NAME PredicateImpl
#include "gen_variant.h"
#include "gen_variant_serialize.h"
inline
#include "gen_variant_serialize_pretty.h"
#undef VARIANT_TYPES_LIST
#undef VARIANT_NAME
}
struct TilePredicate : TilePredicates::PredicateImpl {
using PredicateImpl::PredicateImpl;
bool apply(LayoutCanvas::Map*, Vec2, RandomGen&) const;
};