8 public static int MAX(
int a,
int b)
18 public static int ABS(
int a)
28 public static int ZSGN(
int a)
42 private static bool IsBlocked(
int x,
int z,
int sx,
int sz)
45 if (x < 0 || z < 0 || x >=
EClass._map.Size || z >=
EClass._map.Size)
52 byte[] weights =
EClass._map.cells[x, z].weights;
53 if ((sz == -1 && weights[0] == 0) || (sz == 1 && weights[2] == 0) || (sx == 1 && weights[1] == 0) || (sx == -1 && weights[3] == 0))
57 if (!flag && sx != 0 && sz != 0)
59 if (x + sx < 0 || z + sz < 0 || x + sx >=
EClass._map.Size || z + sz >=
EClass._map.Size)
65 byte[] weights2 =
EClass._map.cells[x + sx, z + sz].weights;
66 if ((sz < 0 && weights2[2] == 0) || (sx > 0 && weights2[3] == 0))
70 if ((sz > 0 && weights2[0] == 0) || (sx < 0 && weights2[1] == 0))
82 if (
Los.onVisit !=
null)
90 public static List<Point> ListVisible(
Point p1,
Point p2,
int radius, Action<Point, bool> _onVisit =
null)
92 List<Point> list =
new List<Point>();
93 List<Point> vecs =
new List<Point>();
94 Point lastPoint = p1.Copy();
95 Los.IsVisible(p1.x, p2.x, p1.z, p2.z, delegate(
Point p,
bool blocked)
97 Point point3 =
new Point(p.x - lastPoint.x, p.z - lastPoint.z);
98 if (point3.x != 0 || point3.z != 0)
108 Point point = p1.Copy();
109 for (
int i = 0; i < radius; i++)
111 Point point2 = vecs[i % vecs.Count];
115 Los.IsVisible(p1.x, point.x, p1.z, point.z, delegate(
Point p,
bool blocked)
121 if (_onVisit !=
null)
123 _onVisit(p, blocked);
133 Los.IsVisible(p1, p2, delegate(
Point p,
bool blocked)
135 if (!blocked && dest ==
null && p2.Distance(p) == 1 && !p.HasChara)
146 Point rushPos =
null;
148 Los.IsVisible(p1, dest, delegate(
Point p,
bool blocked)
150 if (p.Equals(dest) || p.Equals(p1))
154 if (blocked || p.HasChara || p.IsBlocked)
158 if (p.Distance(dest) == 1)
171 public static bool IsVisible(
Point p1,
Point p2, Action<Point, bool> _onVisit =
null)
173 return Los.IsVisible(p1.x, p2.x, p1.z, p2.z, _onVisit,
true);
177 public static bool IsVisible(
Card c1,
Card c2)
179 return Los.IsVisible(c1.pos.x, c2.pos.x, c1.pos.z, c2.pos.z,
null,
true);
183 public static bool IsVisible(
int x1,
int x2,
int z1,
int z2, Action<Point, bool> _onVisit =
null,
bool returnOnBlock =
true)
185 Los.onVisit = _onVisit;
187 Los.originalP.Set(x1, z1);
190 int num =
Los.ABS(a) << 1;
191 int num2 =
Los.ABS(a2) << 1;
192 int num3 =
Los.ZSGN(a);
193 int num4 =
Los.ZSGN(a2);
198 int num7 = num2 - (num >> 1);
201 if (
Los.IsBlocked(num5, num6, num3, (num7 >= 0) ? num4 : 0) && returnOnBlock)
213 Los.p.Set(num5, num6);
214 if (
Los.onVisit !=
null)
216 Los.onVisit(
Los.p,
false);
222 int num8 = num - (num2 >> 1);
225 if (
Los.IsBlocked(num5, num6, (num8 >= 0) ? num3 : 0, num4) && returnOnBlock)
237 Los.p.Set(num5, num6);
238 if (
Los.onVisit !=
null)
240 Los.onVisit(
Los.p,
false);
254 public static Action<Point, bool> onVisit;