Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ShapeFloodFill.cs
Go to the documentation of this file.
5
7
8public class ShapeFloodFill : GenShape
9{
10 private int _maximumActions;
11
16
17 public override bool Perform(Point origin, GenAction action)
18 {
21 queue.Enqueue(origin);
22 int num = _maximumActions;
23 while (queue.Count > 0 && num > 0)
24 {
25 Point point = queue.Dequeue();
26 if (!hashSet.Contains(new Point16(point.X, point.Y)) && UnitApply(action, origin, point.X, point.Y))
27 {
28 hashSet.Add(new Point16(point));
29 num--;
30 if (point.X + 1 < Main.maxTilesX - 1)
31 {
32 queue.Enqueue(new Point(point.X + 1, point.Y));
33 }
34 if (point.X - 1 >= 1)
35 {
36 queue.Enqueue(new Point(point.X - 1, point.Y));
37 }
38 if (point.Y + 1 < Main.maxTilesY - 1)
39 {
40 queue.Enqueue(new Point(point.X, point.Y + 1));
41 }
42 if (point.Y - 1 >= 1)
43 {
44 queue.Enqueue(new Point(point.X, point.Y - 1));
45 }
46 }
47 }
48 while (queue.Count > 0)
49 {
50 Point item = queue.Dequeue();
51 if (!hashSet.Contains(new Point16(item.X, item.Y)))
52 {
53 queue.Enqueue(item);
54 break;
55 }
56 }
57 return queue.Count == 0;
58 }
59}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
override bool Perform(Point origin, GenAction action)
static int maxTilesY
Definition Main.cs:1116
static int maxTilesX
Definition Main.cs:1114
bool UnitApply(GenAction action, Point origin, int x, int y, params object[] args)
Definition GenShape.cs:13