Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TileSmartInteractCandidateProvider.cs
Go to the documentation of this file.
1using System;
4
6
8{
10 {
11 private bool _strictSettings;
12
13 private int _aimedX;
14
15 private int _aimedY;
16
17 private int _hx;
18
19 private int _hy;
20
21 private int _lx;
22
23 private int _ly;
24
25 public float DistanceFromCursor { get; private set; }
26
27 public void Reuse(bool strictSettings, float distanceFromCursor, int AimedX, int AimedY, int LX, int LY, int HX, int HY)
28 {
33 _lx = LX;
34 _ly = LY;
35 _hx = HX;
36 _hy = HY;
37 }
38
39 public void WinCandidacy()
40 {
41 Main.SmartInteractX = _aimedX;
42 Main.SmartInteractY = _aimedY;
44 {
45 Main.SmartInteractShowingFake = Main.SmartInteractTileCoords.Count > 0;
46 }
47 else
48 {
49 Main.SmartInteractShowingGenuine = true;
50 }
51 Main.TileInteractionLX = _lx - 10;
52 Main.TileInteractionLY = _ly - 10;
53 Main.TileInteractionHX = _hx + 10;
54 Main.TileInteractionHY = _hy + 10;
55 }
56 }
57
59
61
63 {
64 Main.SmartInteractX = -1;
65 Main.SmartInteractY = -1;
66 Main.TileInteractionLX = -1;
67 Main.TileInteractionHX = -1;
68 Main.TileInteractionLY = -1;
69 Main.TileInteractionHY = -1;
72 targets.Clear();
73 }
74
76 {
77 candidate = null;
78 Point point = settings.mousevec.ToTileCoordinates();
80 int num = -1;
81 int num2 = -1;
82 int num3 = -1;
83 int num4 = -1;
84 if (targets.Count > 0)
85 {
86 float num5 = -1f;
88 for (int i = 0; i < targets.Count; i++)
89 {
90 float num6 = Vector2.Distance(new Vector2(targets[i].Item1, targets[i].Item2) * 16f + Vector2.One * 8f, settings.mousevec);
91 if (num5 == -1f || num6 <= num5)
92 {
93 num5 = num6;
94 tuple = targets[i];
95 }
96 }
97 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, settings.LX, settings.LY, settings.HX, settings.HY))
98 {
99 num = tuple.Item1;
100 num2 = tuple.Item2;
101 }
102 }
103 bool flag = false;
104 for (int j = 0; j < targets.Count; j++)
105 {
106 int item = targets[j].Item1;
107 int item2 = targets[j].Item2;
108 Tile tile = Main.tile[item, item2];
109 int num7 = 0;
110 int num8 = 0;
111 int num9 = 18;
112 int num10 = 18;
113 int num11 = 2;
114 switch (tile.type)
115 {
116 case 136:
117 case 144:
118 case 494:
119 num7 = 1;
120 num8 = 1;
121 num11 = 0;
122 break;
123 case 216:
124 case 338:
125 num7 = 1;
126 num8 = 2;
127 break;
128 case 15:
129 case 497:
130 num7 = 1;
131 num8 = 2;
132 num11 = 4;
133 break;
134 case 10:
135 num7 = 1;
136 num8 = 3;
137 num11 = 0;
138 break;
139 case 388:
140 case 389:
141 num7 = 1;
142 num8 = 5;
143 break;
144 case 29:
145 case 387:
146 num7 = 2;
147 num8 = 1;
148 break;
149 case 21:
150 case 55:
151 case 85:
152 case 97:
153 case 125:
154 case 132:
155 case 287:
156 case 335:
157 case 386:
158 case 411:
159 case 425:
160 case 441:
161 case 467:
162 case 468:
163 case 573:
164 case 621:
165 num7 = 2;
166 num8 = 2;
167 break;
168 case 79:
169 case 139:
170 case 510:
171 case 511:
172 num7 = 2;
173 num8 = 2;
174 num11 = 0;
175 break;
176 case 11:
177 case 356:
178 case 410:
179 case 470:
180 case 480:
181 case 509:
182 case 657:
183 case 658:
184 case 663:
185 num7 = 2;
186 num8 = 3;
187 num11 = 0;
188 break;
189 case 207:
190 num7 = 2;
191 num8 = 4;
192 num11 = 0;
193 break;
194 case 104:
195 num7 = 2;
196 num8 = 5;
197 break;
198 case 88:
199 num7 = 3;
200 num8 = 1;
201 num11 = 0;
202 break;
203 case 89:
204 case 215:
205 case 237:
206 case 377:
207 num7 = 3;
208 num8 = 2;
209 break;
210 case 354:
211 case 455:
212 case 491:
213 num7 = 3;
214 num8 = 3;
215 num11 = 0;
216 break;
217 case 487:
218 num7 = 4;
219 num8 = 2;
220 num11 = 0;
221 break;
222 case 212:
223 num7 = 4;
224 num8 = 3;
225 break;
226 case 209:
227 num7 = 4;
228 num8 = 3;
229 num11 = 0;
230 break;
231 case 102:
232 case 463:
233 case 475:
234 case 597:
235 num7 = 3;
236 num8 = 4;
237 break;
238 case 464:
239 num7 = 5;
240 num8 = 4;
241 break;
242 }
243 if (num7 == 0 || num8 == 0)
244 {
245 continue;
246 }
247 int num12 = item - tile.frameX % (num9 * num7) / num9;
248 int num13 = item2 - tile.frameY % (num10 * num8 + num11) / num10;
249 bool flag2 = Collision.InTileBounds(num, num2, num12, num13, num12 + num7 - 1, num13 + num8 - 1);
250 bool flag3 = Collision.InTileBounds(point.X, point.Y, num12, num13, num12 + num7 - 1, num13 + num8 - 1);
251 if (flag3)
252 {
253 num3 = point.X;
254 num4 = point.Y;
255 }
256 if (!settings.FullInteraction)
257 {
258 flag2 = flag2 && flag3;
259 }
260 if (flag)
261 {
262 flag2 = false;
263 }
264 for (int k = num12; k < num12 + num7; k++)
265 {
266 for (int l = num13; l < num13 + num8; l++)
267 {
268 Point item3 = new Point(k, l);
269 if (!Main.SmartInteractTileCoords.Contains(item3))
270 {
271 if (flag2)
272 {
274 }
275 if (flag2 || settings.FullInteraction)
276 {
278 }
279 }
280 }
281 }
282 if (!flag && flag2)
283 {
284 flag = true;
285 }
286 }
288 {
289 if (num3 != -1 && num4 != -1)
290 {
291 _candidate.Reuse(strictSettings: true, 0f, num3, num4, settings.LX - 10, settings.LY - 10, settings.HX + 10, settings.HY + 10);
293 return true;
294 }
295 return false;
296 }
297 if (num != -1 && num2 != -1)
298 {
299 float distanceFromCursor = new Rectangle(num * 16, num2 * 16, 16, 16).ClosestPointInRect(settings.mousevec).Distance(settings.mousevec);
300 _candidate.Reuse(strictSettings: false, distanceFromCursor, num, num2, settings.LX - 10, settings.LY - 10, settings.HX + 10, settings.HY + 10);
302 return true;
303 }
304 return false;
305 }
306
308 {
309 for (int i = settings.LX; i <= settings.HX; i++)
310 {
311 for (int j = settings.LY; j <= settings.HY; j++)
312 {
313 Tile tile = Main.tile[i, j];
314 if (tile == null || !tile.active())
315 {
316 continue;
317 }
318 switch (tile.type)
319 {
320 case 10:
321 case 11:
322 case 21:
323 case 29:
324 case 55:
325 case 79:
326 case 85:
327 case 88:
328 case 89:
329 case 97:
330 case 102:
331 case 104:
332 case 125:
333 case 132:
334 case 136:
335 case 139:
336 case 144:
337 case 207:
338 case 209:
339 case 215:
340 case 216:
341 case 287:
342 case 335:
343 case 338:
344 case 354:
345 case 377:
346 case 386:
347 case 387:
348 case 388:
349 case 389:
350 case 410:
351 case 411:
352 case 425:
353 case 441:
354 case 455:
355 case 463:
356 case 464:
357 case 467:
358 case 468:
359 case 470:
360 case 475:
361 case 480:
362 case 487:
363 case 491:
364 case 494:
365 case 509:
366 case 510:
367 case 511:
368 case 573:
369 case 597:
370 case 621:
371 case 657:
372 case 658:
373 targets.Add(new Tuple<int, int>(i, j));
374 break;
375 case 15:
376 case 497:
377 if (settings.player.IsWithinSnappngRangeToTile(i, j, 40))
378 {
379 targets.Add(new Tuple<int, int>(i, j));
380 }
381 break;
382 case 237:
383 if (settings.player.HasItem(1293))
384 {
385 targets.Add(new Tuple<int, int>(i, j));
386 }
387 break;
388 case 212:
389 if (settings.player.HasItem(949))
390 {
391 targets.Add(new Tuple<int, int>(i, j));
392 }
393 break;
394 case 356:
396 {
397 targets.Add(new Tuple<int, int>(i, j));
398 }
399 break;
400 case 663:
402 {
403 targets.Add(new Tuple<int, int>(i, j));
404 }
405 break;
406 }
407 }
408 }
409 }
410}
static bool InTileBounds(int x, int y, int lx, int ly, int hx, int hy)
void Reuse(bool strictSettings, float distanceFromCursor, int AimedX, int AimedY, int LX, int LY, int HX, int HY)
bool ProvideCandidate(SmartInteractScanSettings settings, out ISmartInteractCandidate candidate)
static int netMode
Definition Main.cs:2095
static List< Microsoft.Xna.Framework.Point > SmartInteractTileCoordsSelected
Definition Main.cs:2171
static Tile[,] tile
Definition Main.cs:1675
static int moondialCooldown
Definition Main.cs:2287
static bool fastForwardTimeToDawn
Definition Main.cs:2281
static int sundialCooldown
Definition Main.cs:2283
static List< Microsoft.Xna.Framework.Point > SmartInteractTileCoords
Definition Main.cs:2169
static bool fastForwardTimeToDusk
Definition Main.cs:2285
bool HasItem(int type)
Definition Player.cs:52305
bool IsWithinSnappngRangeToTile(int x, int y, int distanceInPixels)
Definition Player.cs:16993
ushort type
Definition Tile.cs:8
bool active()
Definition Tile.cs:565
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91