Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GenCondition.cs
Go to the documentation of this file.
2
3public abstract class GenCondition : GenBase
4{
5 private enum AreaType
6 {
7 And,
8 Or,
9 None
10 }
11
12 private bool InvertResults;
13
14 private int _width;
15
16 private int _height;
17
18 private AreaType _areaType = AreaType.None;
19
20 public bool IsValid(int x, int y)
21 {
22 switch (_areaType)
23 {
24 case AreaType.None:
25 return CheckValidity(x, y) ^ InvertResults;
26 case AreaType.And:
27 {
28 for (int k = x; k < x + _width; k++)
29 {
30 for (int l = y; l < y + _height; l++)
31 {
32 if (!CheckValidity(k, l))
33 {
34 return InvertResults;
35 }
36 }
37 }
38 return !InvertResults;
39 }
40 case AreaType.Or:
41 {
42 for (int i = x; i < x + _width; i++)
43 {
44 for (int j = y; j < y + _height; j++)
45 {
46 if (CheckValidity(i, j))
47 {
48 return !InvertResults;
49 }
50 }
51 }
52 return InvertResults;
53 }
54 default:
55 return true;
56 }
57 }
58
60 {
62 return this;
63 }
64
65 public GenCondition AreaOr(int width, int height)
66 {
68 _width = width;
69 _height = height;
70 return this;
71 }
72
73 public GenCondition AreaAnd(int width, int height)
74 {
75 _areaType = AreaType.And;
76 _width = width;
77 _height = height;
78 return this;
79 }
80
81 protected abstract bool CheckValidity(int x, int y);
82}
GenCondition AreaOr(int width, int height)
GenCondition AreaAnd(int width, int height)