Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Wiring.cs
Go to the documentation of this file.
1using System;
8using Terraria.ID;
10
11namespace Terraria;
12
13public static class Wiring
14{
16
17 public static bool running;
18
20
22
24
26
28
30
31 private static Queue<Point16> _GatesNext;
32
34
36
37 private static Vector2[] _teleport;
38
39 private const int MaxPump = 20;
40
41 private static int[] _inPumpX;
42
43 private static int[] _inPumpY;
44
45 private static int _numInPump;
46
47 private static int[] _outPumpX;
48
49 private static int[] _outPumpY;
50
51 private static int _numOutPump;
52
53 private const int MaxMech = 1000;
54
55 private static int[] _mechX;
56
57 private static int[] _mechY;
58
59 private static int _numMechs;
60
61 private static int[] _mechTime;
62
63 private static int _currentWireColor;
64
65 private static int CurrentUser = 255;
66
67 public static void SetCurrentUser(int plr = -1)
68 {
69 if (plr < 0 || plr > 255)
70 {
71 plr = 255;
72 }
73 if (Main.netMode == 0)
74 {
76 }
78 }
79
80 public static void Initialize()
81 {
91 _inPumpX = new int[20];
92 _inPumpY = new int[20];
93 _outPumpX = new int[20];
94 _outPumpY = new int[20];
95 _teleport = new Vector2[2]
96 {
97 Vector2.One * -1f,
98 Vector2.One * -1f
99 };
100 _mechX = new int[1000];
101 _mechY = new int[1000];
102 _mechTime = new int[1000];
103 }
104
105 public static void SkipWire(int x, int y)
106 {
107 _wireSkip[new Point16(x, y)] = true;
108 }
109
110 public static void SkipWire(Point16 point)
111 {
112 _wireSkip[point] = true;
113 }
114
115 public static void ClearAll()
116 {
117 for (int i = 0; i < 20; i++)
118 {
119 _inPumpX[i] = 0;
120 _inPumpY[i] = 0;
121 _outPumpX[i] = 0;
122 _outPumpY[i] = 0;
123 }
124 _numInPump = 0;
125 _numOutPump = 0;
126 for (int j = 0; j < 1000; j++)
127 {
128 _mechTime[j] = 0;
129 _mechX[j] = 0;
130 _mechY[j] = 0;
131 }
132 _numMechs = 0;
133 }
134
135 public static void UpdateMech()
136 {
138 for (int num = _numMechs - 1; num >= 0; num--)
139 {
140 _mechTime[num]--;
141 int num2 = _mechX[num];
142 int num3 = _mechY[num];
143 if (!WorldGen.InWorld(num2, num3, 1))
144 {
145 _numMechs--;
146 }
147 else
148 {
149 Tile tile = Main.tile[num2, num3];
150 if (tile == null)
151 {
152 _numMechs--;
153 }
154 else
155 {
156 if (tile.active() && tile.type == 144)
157 {
158 if (tile.frameY == 0)
159 {
160 _mechTime[num] = 0;
161 }
162 else
163 {
164 int num4 = tile.frameX / 18;
165 switch (num4)
166 {
167 case 0:
168 num4 = 60;
169 break;
170 case 1:
171 num4 = 180;
172 break;
173 case 2:
174 num4 = 300;
175 break;
176 case 3:
177 num4 = 30;
178 break;
179 case 4:
180 num4 = 15;
181 break;
182 }
183 if (Math.IEEERemainder(_mechTime[num], num4) == 0.0)
184 {
185 _mechTime[num] = 18000;
186 TripWire(_mechX[num], _mechY[num], 1, 1);
187 }
188 }
189 }
190 if (_mechTime[num] <= 0)
191 {
192 if (tile.active() && tile.type == 144)
193 {
194 tile.frameY = 0;
195 NetMessage.SendTileSquare(-1, _mechX[num], _mechY[num]);
196 }
197 if (tile.active() && tile.type == 411)
198 {
199 int num5 = tile.frameX % 36 / 18;
200 int num6 = tile.frameY % 36 / 18;
201 int num7 = _mechX[num] - num5;
202 int num8 = _mechY[num] - num6;
203 int num9 = 36;
204 if (Main.tile[num7, num8].frameX >= 36)
205 {
206 num9 = -36;
207 }
208 for (int i = num7; i < num7 + 2; i++)
209 {
210 for (int j = num8; j < num8 + 2; j++)
211 {
212 if (WorldGen.InWorld(i, j, 1))
213 {
214 Tile tile2 = Main.tile[i, j];
215 if (tile2 != null)
216 {
217 tile2.frameX = (short)(tile2.frameX + num9);
218 }
219 }
220 }
221 }
223 }
224 for (int k = num; k < _numMechs; k++)
225 {
226 _mechX[k] = _mechX[k + 1];
227 _mechY[k] = _mechY[k + 1];
228 _mechTime[k] = _mechTime[k + 1];
229 }
230 _numMechs--;
231 }
232 }
233 }
234 }
235 }
236
237 public static void HitSwitch(int i, int j)
238 {
239 if (!WorldGen.InWorld(i, j) || Main.tile[i, j] == null)
240 {
241 return;
242 }
243 if (Main.tile[i, j].type == 135 || Main.tile[i, j].type == 314 || Main.tile[i, j].type == 423 || Main.tile[i, j].type == 428 || Main.tile[i, j].type == 442 || Main.tile[i, j].type == 476)
244 {
245 SoundEngine.PlaySound(28, i * 16, j * 16, 0);
246 TripWire(i, j, 1, 1);
247 }
248 else if (Main.tile[i, j].type == 440)
249 {
250 SoundEngine.PlaySound(28, i * 16 + 16, j * 16 + 16, 0);
251 TripWire(i, j, 3, 3);
252 }
253 else if (Main.tile[i, j].type == 136)
254 {
255 if (Main.tile[i, j].frameY == 0)
256 {
257 Main.tile[i, j].frameY = 18;
258 }
259 else
260 {
261 Main.tile[i, j].frameY = 0;
262 }
263 SoundEngine.PlaySound(28, i * 16, j * 16, 0);
264 TripWire(i, j, 1, 1);
265 }
266 else if (Main.tile[i, j].type == 443)
267 {
268 GeyserTrap(i, j);
269 }
270 else if (Main.tile[i, j].type == 144)
271 {
272 if (Main.tile[i, j].frameY == 0)
273 {
274 Main.tile[i, j].frameY = 18;
275 if (Main.netMode != 1)
276 {
277 CheckMech(i, j, 18000);
278 }
279 }
280 else
281 {
282 Main.tile[i, j].frameY = 0;
283 }
284 SoundEngine.PlaySound(28, i * 16, j * 16, 0);
285 }
286 else if (Main.tile[i, j].type == 441 || Main.tile[i, j].type == 468)
287 {
288 int num = Main.tile[i, j].frameX / 18 * -1;
289 int num2 = Main.tile[i, j].frameY / 18 * -1;
290 num %= 4;
291 if (num < -1)
292 {
293 num += 2;
294 }
295 num += i;
296 num2 += j;
297 SoundEngine.PlaySound(28, i * 16, j * 16, 0);
298 TripWire(num, num2, 2, 2);
299 }
300 else if (Main.tile[i, j].type == 467)
301 {
302 if (Main.tile[i, j].frameX / 36 == 4)
303 {
304 int num3 = Main.tile[i, j].frameX / 18 * -1;
305 int num4 = Main.tile[i, j].frameY / 18 * -1;
306 num3 %= 4;
307 if (num3 < -1)
308 {
309 num3 += 2;
310 }
311 num3 += i;
312 num4 += j;
313 SoundEngine.PlaySound(28, i * 16, j * 16, 0);
314 TripWire(num3, num4, 2, 2);
315 }
316 }
317 else
318 {
319 if (Main.tile[i, j].type != 132 && Main.tile[i, j].type != 411)
320 {
321 return;
322 }
323 short num5 = 36;
324 int num6 = Main.tile[i, j].frameX / 18 * -1;
325 int num7 = Main.tile[i, j].frameY / 18 * -1;
326 num6 %= 4;
327 if (num6 < -1)
328 {
329 num6 += 2;
330 num5 = -36;
331 }
332 num6 += i;
333 num7 += j;
334 if (Main.netMode != 1 && Main.tile[num6, num7].type == 411)
335 {
336 CheckMech(num6, num7, 60);
337 }
338 for (int k = num6; k < num6 + 2; k++)
339 {
340 for (int l = num7; l < num7 + 2; l++)
341 {
342 if (Main.tile[k, l].type == 132 || Main.tile[k, l].type == 411)
343 {
344 Main.tile[k, l].frameX += num5;
345 }
346 }
347 }
349 SoundEngine.PlaySound(28, i * 16, j * 16, 0);
350 TripWire(num6, num7, 2, 2);
351 }
352 }
353
354 public static void PokeLogicGate(int lampX, int lampY)
355 {
356 if (Main.netMode != 1)
357 {
358 _LampsToCheck.Enqueue(new Point16(lampX, lampY));
360 }
361 }
362
363 public static bool Actuate(int i, int j)
364 {
365 Tile tile = Main.tile[i, j];
366 if (!tile.actuator())
367 {
368 return false;
369 }
370 if (tile.inActive())
371 {
372 ReActive(i, j);
373 }
374 else
375 {
376 DeActive(i, j);
377 }
378 return true;
379 }
380
381 public static void ActuateForced(int i, int j)
382 {
383 if (Main.tile[i, j].inActive())
384 {
385 ReActive(i, j);
386 }
387 else
388 {
389 DeActive(i, j);
390 }
391 }
392
393 public static void MassWireOperation(Point ps, Point pe, Player master)
394 {
395 int wireCount = 0;
396 int actuatorCount = 0;
397 for (int i = 0; i < 58; i++)
398 {
399 if (master.inventory[i].type == 530)
400 {
401 wireCount += master.inventory[i].stack;
402 }
403 if (master.inventory[i].type == 849)
404 {
405 actuatorCount += master.inventory[i].stack;
406 }
407 }
408 int num = wireCount;
409 int num2 = actuatorCount;
410 MassWireOperationInner(master, ps, pe, master.Center, master.direction == 1, ref wireCount, ref actuatorCount);
411 int num3 = num - wireCount;
412 int num4 = num2 - actuatorCount;
413 if (Main.netMode == 2)
414 {
415 NetMessage.SendData(110, master.whoAmI, -1, null, 530, num3, master.whoAmI);
416 NetMessage.SendData(110, master.whoAmI, -1, null, 849, num4, master.whoAmI);
417 return;
418 }
419 for (int j = 0; j < num3; j++)
420 {
421 master.ConsumeItem(530);
422 }
423 for (int k = 0; k < num4; k++)
424 {
425 master.ConsumeItem(849);
426 }
427 }
428
429 private static bool CheckMech(int i, int j, int time)
430 {
431 for (int k = 0; k < _numMechs; k++)
432 {
433 if (_mechX[k] == i && _mechY[k] == j)
434 {
435 return false;
436 }
437 }
438 if (_numMechs < 999)
439 {
440 _mechX[_numMechs] = i;
441 _mechY[_numMechs] = j;
442 _mechTime[_numMechs] = time;
443 _numMechs++;
444 return true;
445 }
446 return false;
447 }
448
449 private static void XferWater()
450 {
451 for (int i = 0; i < _numInPump; i++)
452 {
453 int num = _inPumpX[i];
454 int num2 = _inPumpY[i];
455 int liquid = Main.tile[num, num2].liquid;
456 if (liquid <= 0)
457 {
458 continue;
459 }
460 byte b = Main.tile[num, num2].liquidType();
461 for (int j = 0; j < _numOutPump; j++)
462 {
463 int num3 = _outPumpX[j];
464 int num4 = _outPumpY[j];
465 int liquid2 = Main.tile[num3, num4].liquid;
466 if (liquid2 >= 255)
467 {
468 continue;
469 }
470 byte b2 = Main.tile[num3, num4].liquidType();
471 if (liquid2 == 0)
472 {
473 b2 = b;
474 }
475 if (b2 == b)
476 {
477 int num5 = liquid;
478 if (num5 + liquid2 > 255)
479 {
480 num5 = 255 - liquid2;
481 }
482 Main.tile[num3, num4].liquid += (byte)num5;
483 Main.tile[num, num2].liquid -= (byte)num5;
484 liquid = Main.tile[num, num2].liquid;
485 Main.tile[num3, num4].liquidType(b);
487 if (Main.tile[num, num2].liquid == 0)
488 {
489 Main.tile[num, num2].liquidType(0);
491 break;
492 }
493 }
494 }
496 }
497 }
498
499 private static void TripWire(int left, int top, int width, int height)
500 {
501 if (Main.netMode == 1)
502 {
503 return;
504 }
505 running = true;
506 if (_wireList.Count != 0)
507 {
508 _wireList.Clear(quickClear: true);
509 }
510 if (_wireDirectionList.Count != 0)
511 {
512 _wireDirectionList.Clear(quickClear: true);
513 }
514 Vector2[] array = new Vector2[8];
515 int num = 0;
516 for (int i = left; i < left + width; i++)
517 {
518 for (int j = top; j < top + height; j++)
519 {
520 Point16 back = new Point16(i, j);
521 Tile tile = Main.tile[i, j];
522 if (tile != null && tile.wire())
523 {
524 _wireList.PushBack(back);
525 }
526 }
527 }
528 _teleport[0].X = -1f;
529 _teleport[0].Y = -1f;
530 _teleport[1].X = -1f;
531 _teleport[1].Y = -1f;
532 if (_wireList.Count > 0)
533 {
534 _numInPump = 0;
535 _numOutPump = 0;
536 HitWire(_wireList, 1);
537 if (_numInPump > 0 && _numOutPump > 0)
538 {
539 XferWater();
540 }
541 }
542 array[num++] = _teleport[0];
543 array[num++] = _teleport[1];
544 for (int k = left; k < left + width; k++)
545 {
546 for (int l = top; l < top + height; l++)
547 {
548 Point16 back = new Point16(k, l);
549 Tile tile2 = Main.tile[k, l];
550 if (tile2 != null && tile2.wire2())
551 {
552 _wireList.PushBack(back);
553 }
554 }
555 }
556 _teleport[0].X = -1f;
557 _teleport[0].Y = -1f;
558 _teleport[1].X = -1f;
559 _teleport[1].Y = -1f;
560 if (_wireList.Count > 0)
561 {
562 _numInPump = 0;
563 _numOutPump = 0;
564 HitWire(_wireList, 2);
565 if (_numInPump > 0 && _numOutPump > 0)
566 {
567 XferWater();
568 }
569 }
570 array[num++] = _teleport[0];
571 array[num++] = _teleport[1];
572 _teleport[0].X = -1f;
573 _teleport[0].Y = -1f;
574 _teleport[1].X = -1f;
575 _teleport[1].Y = -1f;
576 for (int m = left; m < left + width; m++)
577 {
578 for (int n = top; n < top + height; n++)
579 {
580 Point16 back = new Point16(m, n);
581 Tile tile3 = Main.tile[m, n];
582 if (tile3 != null && tile3.wire3())
583 {
584 _wireList.PushBack(back);
585 }
586 }
587 }
588 if (_wireList.Count > 0)
589 {
590 _numInPump = 0;
591 _numOutPump = 0;
592 HitWire(_wireList, 3);
593 if (_numInPump > 0 && _numOutPump > 0)
594 {
595 XferWater();
596 }
597 }
598 array[num++] = _teleport[0];
599 array[num++] = _teleport[1];
600 _teleport[0].X = -1f;
601 _teleport[0].Y = -1f;
602 _teleport[1].X = -1f;
603 _teleport[1].Y = -1f;
604 for (int num2 = left; num2 < left + width; num2++)
605 {
606 for (int num3 = top; num3 < top + height; num3++)
607 {
608 Point16 back = new Point16(num2, num3);
610 if (tile4 != null && tile4.wire4())
611 {
612 _wireList.PushBack(back);
613 }
614 }
615 }
616 if (_wireList.Count > 0)
617 {
618 _numInPump = 0;
619 _numOutPump = 0;
620 HitWire(_wireList, 4);
621 if (_numInPump > 0 && _numOutPump > 0)
622 {
623 XferWater();
624 }
625 }
626 array[num++] = _teleport[0];
627 array[num++] = _teleport[1];
628 running = false;
629 for (int num4 = 0; num4 < 8; num4 += 2)
630 {
631 _teleport[0] = array[num4];
632 _teleport[1] = array[num4 + 1];
633 if (_teleport[0].X >= 0f && _teleport[1].X >= 0f)
634 {
635 Teleport();
636 }
637 }
638 PixelBoxPass();
640 }
641
642 private static void PixelBoxPass()
643 {
645 {
646 if (pixelBoxTrigger.Value == 3)
647 {
648 Tile tile = Main.tile[pixelBoxTrigger.Key.X, pixelBoxTrigger.Key.Y];
649 tile.frameX = (short)((tile.frameX != 18) ? 18 : 0);
651 }
652 }
653 _PixelBoxTriggers.Clear();
654 }
655
656 private static void LogicGatePass()
657 {
658 if (_GatesCurrent.Count != 0)
659 {
660 return;
661 }
662 _GatesDone.Clear();
663 while (_LampsToCheck.Count > 0)
664 {
665 while (_LampsToCheck.Count > 0)
666 {
667 Point16 point = _LampsToCheck.Dequeue();
668 CheckLogicGate(point.X, point.Y);
669 }
670 while (_GatesNext.Count > 0)
671 {
673 while (_GatesCurrent.Count > 0)
674 {
675 Point16 key = _GatesCurrent.Peek();
676 if (_GatesDone.TryGetValue(key, out var value) && value)
677 {
678 _GatesCurrent.Dequeue();
679 continue;
680 }
681 _GatesDone.Add(key, value: true);
682 TripWire(key.X, key.Y, 1, 1);
683 _GatesCurrent.Dequeue();
684 }
685 }
686 }
687 _GatesDone.Clear();
689 {
691 }
692 }
693
694 private static void CheckLogicGate(int lampX, int lampY)
695 {
696 if (!WorldGen.InWorld(lampX, lampY, 1))
697 {
698 return;
699 }
700 for (int i = lampY; i < Main.maxTilesY; i++)
701 {
702 Tile tile = Main.tile[lampX, i];
703 if (!tile.active())
704 {
705 break;
706 }
707 if (tile.type == 420)
708 {
709 _GatesDone.TryGetValue(new Point16(lampX, i), out var value);
710 int num = tile.frameY / 18;
711 bool flag = tile.frameX == 18;
712 bool flag2 = tile.frameX == 36;
713 if (num < 0)
714 {
715 break;
716 }
717 int num2 = 0;
718 int num3 = 0;
719 bool flag3 = false;
720 for (int num4 = i - 1; num4 > 0; num4--)
721 {
723 if (!tile2.active() || tile2.type != 419)
724 {
725 break;
726 }
727 if (tile2.frameX == 36)
728 {
729 flag3 = true;
730 break;
731 }
732 num2++;
733 num3 += (tile2.frameX == 18).ToInt();
734 }
735 bool flag4 = false;
736 switch (num)
737 {
738 default:
739 return;
740 case 0:
741 flag4 = num2 == num3;
742 break;
743 case 2:
744 flag4 = num2 != num3;
745 break;
746 case 1:
747 flag4 = num3 > 0;
748 break;
749 case 3:
750 flag4 = num3 == 0;
751 break;
752 case 4:
753 flag4 = num3 == 1;
754 break;
755 case 5:
756 flag4 = num3 != 1;
757 break;
758 }
759 bool flag5 = !flag3 && flag2;
760 bool flag6 = false;
761 if (flag3 && Framing.GetTileSafely(lampX, lampY).frameX == 36)
762 {
763 flag6 = true;
764 }
765 if (!(flag4 != flag || flag5 || flag6))
766 {
767 break;
768 }
769 _ = tile.frameX % 18 / 18;
770 tile.frameX = (short)(18 * flag4.ToInt());
771 if (flag3)
772 {
773 tile.frameX = 36;
774 }
775 SkipWire(lampX, i);
778 bool flag7 = !flag3 || flag6;
779 if (flag6)
780 {
781 if (num3 == 0 || num2 == 0)
782 {
783 flag7 = false;
784 }
785 flag7 = Main.rand.NextFloat() < (float)num3 / (float)num2;
786 }
787 if (flag5)
788 {
789 flag7 = false;
790 }
791 if (flag7)
792 {
793 if (!value)
794 {
795 _GatesNext.Enqueue(new Point16(lampX, i));
796 break;
797 }
798 Vector2 position = new Vector2(lampX, i) * 16f - new Vector2(10f);
799 Utils.PoofOfSmoke(position);
800 NetMessage.SendData(106, -1, -1, null, (int)position.X, position.Y);
801 }
802 break;
803 }
804 if (tile.type != 419)
805 {
806 break;
807 }
808 }
809 }
810
811 private static void HitWire(DoubleStack<Point16> next, int wireType)
812 {
813 _wireDirectionList.Clear(quickClear: true);
814 for (int i = 0; i < next.Count; i++)
815 {
816 Point16 point = next.PopFront();
817 SkipWire(point);
818 _toProcess.Add(point, 4);
819 next.PushBack(point);
820 _wireDirectionList.PushBack(0);
821 }
823 while (next.Count > 0)
824 {
825 Point16 key = next.PopFront();
826 int num = _wireDirectionList.PopFront();
827 int x = key.X;
828 int y = key.Y;
829 if (!_wireSkip.ContainsKey(key))
830 {
831 HitWireSingle(x, y);
832 }
833 for (int j = 0; j < 4; j++)
834 {
835 int num2;
836 int num3;
837 switch (j)
838 {
839 case 0:
840 num2 = x;
841 num3 = y + 1;
842 break;
843 case 1:
844 num2 = x;
845 num3 = y - 1;
846 break;
847 case 2:
848 num2 = x + 1;
849 num3 = y;
850 break;
851 case 3:
852 num2 = x - 1;
853 num3 = y;
854 break;
855 default:
856 num2 = x;
857 num3 = y + 1;
858 break;
859 }
861 {
862 continue;
863 }
864 Tile tile = Main.tile[num2, num3];
865 if (tile == null)
866 {
867 continue;
868 }
869 Tile tile2 = Main.tile[x, y];
870 if (tile2 == null)
871 {
872 continue;
873 }
874 byte b = 3;
875 if (tile.type == 424 || tile.type == 445)
876 {
877 b = 0;
878 }
879 if (tile2.type == 424)
880 {
881 switch (tile2.frameX / 18)
882 {
883 case 0:
884 if (j != num)
885 {
886 continue;
887 }
888 break;
889 case 1:
890 if ((num != 0 || j != 3) && (num != 3 || j != 0) && (num != 1 || j != 2) && (num != 2 || j != 1))
891 {
892 continue;
893 }
894 break;
895 case 2:
896 if ((num != 0 || j != 2) && (num != 2 || j != 0) && (num != 1 || j != 3) && (num != 3 || j != 1))
897 {
898 continue;
899 }
900 break;
901 }
902 }
903 if (tile2.type == 445)
904 {
905 if (j != num)
906 {
907 continue;
908 }
909 if (_PixelBoxTriggers.ContainsKey(key))
910 {
911 _PixelBoxTriggers[key] |= (byte)((!(j == 0 || j == 1)) ? 1 : 2);
912 }
913 else
914 {
915 _PixelBoxTriggers[key] = (byte)((!(j == 0 || j == 1)) ? 1u : 2u);
916 }
917 }
918 if (wireType switch
919 {
920 1 => tile.wire() ? 1 : 0,
921 2 => tile.wire2() ? 1 : 0,
922 3 => tile.wire3() ? 1 : 0,
923 4 => tile.wire4() ? 1 : 0,
924 _ => 0,
925 } == 0)
926 {
927 continue;
928 }
930 if (_toProcess.TryGetValue(point2, out var value))
931 {
932 value--;
933 if (value == 0)
934 {
935 _toProcess.Remove(point2);
936 }
937 else
938 {
940 }
941 continue;
942 }
943 next.PushBack(point2);
944 _wireDirectionList.PushBack((byte)j);
945 if (b > 0)
946 {
947 _toProcess.Add(point2, b);
948 }
949 }
950 }
951 _wireSkip.Clear();
952 _toProcess.Clear();
953 }
954
959
961 {
963 }
964
966 {
968 }
969
970 private static void HitWireSingle(int i, int j)
971 {
972 Tile tile = Main.tile[i, j];
973 bool? forcedStateWhereTrueIsOn = null;
974 bool doSkipWires = true;
975 int type = tile.type;
976 if (tile.actuator())
977 {
978 ActuateForced(i, j);
979 }
980 if (!tile.active())
981 {
982 return;
983 }
984 switch (type)
985 {
986 case 144:
987 HitSwitch(i, j);
990 break;
991 case 421:
992 if (!tile.actuator())
993 {
994 tile.type = 422;
997 }
998 break;
999 case 422:
1000 if (!tile.actuator())
1001 {
1002 tile.type = 421;
1004 NetMessage.SendTileSquare(-1, i, j);
1005 }
1006 break;
1007 }
1008 if (type >= 255 && type <= 268)
1009 {
1010 if (!tile.actuator())
1011 {
1012 if (type >= 262)
1013 {
1014 tile.type -= 7;
1015 }
1016 else
1017 {
1018 tile.type += 7;
1019 }
1021 NetMessage.SendTileSquare(-1, i, j);
1022 }
1023 return;
1024 }
1025 if (type == 419)
1026 {
1027 int num = 18;
1028 if (tile.frameX >= num)
1029 {
1030 num = -num;
1031 }
1032 if (tile.frameX == 36)
1033 {
1034 num = 0;
1035 }
1036 SkipWire(i, j);
1037 tile.frameX = (short)(tile.frameX + num);
1039 NetMessage.SendTileSquare(-1, i, j);
1040 _LampsToCheck.Enqueue(new Point16(i, j));
1041 return;
1042 }
1043 if (type == 406)
1044 {
1045 int num2 = tile.frameX % 54 / 18;
1046 int num3 = tile.frameY % 54 / 18;
1047 int num4 = i - num2;
1048 int num5 = j - num3;
1049 int num6 = 54;
1050 if (Main.tile[num4, num5].frameY >= 108)
1051 {
1052 num6 = -108;
1053 }
1054 for (int k = num4; k < num4 + 3; k++)
1055 {
1056 for (int l = num5; l < num5 + 3; l++)
1057 {
1058 SkipWire(k, l);
1059 Main.tile[k, l].frameY = (short)(Main.tile[k, l].frameY + num6);
1060 }
1061 }
1062 NetMessage.SendTileSquare(-1, num4 + 1, num5 + 1, 3);
1063 return;
1064 }
1065 if (type == 452)
1066 {
1067 int num7 = tile.frameX % 54 / 18;
1068 int num8 = tile.frameY % 54 / 18;
1069 int num9 = i - num7;
1070 int num10 = j - num8;
1071 int num11 = 54;
1072 if (Main.tile[num9, num10].frameX >= 54)
1073 {
1074 num11 = -54;
1075 }
1076 for (int m = num9; m < num9 + 3; m++)
1077 {
1078 for (int n = num10; n < num10 + 3; n++)
1079 {
1080 SkipWire(m, n);
1081 Main.tile[m, n].frameX = (short)(Main.tile[m, n].frameX + num11);
1082 }
1083 }
1084 NetMessage.SendTileSquare(-1, num9 + 1, num10 + 1, 3);
1085 return;
1086 }
1087 if (type == 411)
1088 {
1089 int num12 = tile.frameX % 36 / 18;
1090 int num13 = tile.frameY % 36 / 18;
1091 int num14 = i - num12;
1092 int num15 = j - num13;
1093 int num16 = 36;
1094 if (Main.tile[num14, num15].frameX >= 36)
1095 {
1096 num16 = -36;
1097 }
1098 for (int num17 = num14; num17 < num14 + 2; num17++)
1099 {
1100 for (int num18 = num15; num18 < num15 + 2; num18++)
1101 {
1103 Main.tile[num17, num18].frameX = (short)(Main.tile[num17, num18].frameX + num16);
1104 }
1105 }
1107 return;
1108 }
1109 if (type == 356)
1110 {
1111 int num19 = tile.frameX % 36 / 18;
1112 int num20 = tile.frameY % 54 / 18;
1113 int num21 = i - num19;
1114 int num22 = j - num20;
1115 for (int num23 = num21; num23 < num21 + 2; num23++)
1116 {
1117 for (int num24 = num22; num24 < num22 + 3; num24++)
1118 {
1120 }
1121 }
1123 {
1124 Main.Sundialing();
1125 }
1127 return;
1128 }
1129 if (type == 663)
1130 {
1131 int num25 = tile.frameX % 36 / 18;
1132 int num26 = tile.frameY % 54 / 18;
1133 int num27 = i - num25;
1134 int num28 = j - num26;
1135 for (int num29 = num27; num29 < num27 + 2; num29++)
1136 {
1137 for (int num30 = num28; num30 < num28 + 3; num30++)
1138 {
1140 }
1141 }
1143 {
1144 Main.Moondialing();
1145 }
1147 return;
1148 }
1149 if (type == 425)
1150 {
1151 int num31 = tile.frameX % 36 / 18;
1152 int num32 = tile.frameY % 36 / 18;
1153 int num33 = i - num31;
1154 int num34 = j - num32;
1155 for (int num35 = num33; num35 < num33 + 2; num35++)
1156 {
1157 for (int num36 = num34; num36 < num34 + 2; num36++)
1158 {
1160 }
1161 }
1163 {
1164 return;
1165 }
1166 Color pink = Color.Pink;
1167 int num37 = Sign.ReadSign(num33, num34, CreateIfMissing: false);
1168 if (num37 == -1 || Main.sign[num37] == null || string.IsNullOrWhiteSpace(Main.sign[num37].text))
1169 {
1170 return;
1171 }
1172 if (Main.AnnouncementBoxRange == -1)
1173 {
1174 if (Main.netMode == 0)
1175 {
1176 Main.NewTextMultiline(Main.sign[num37].text, force: false, pink, 460);
1177 }
1178 else if (Main.netMode == 2)
1179 {
1180 NetMessage.SendData(107, -1, -1, NetworkText.FromLiteral(Main.sign[num37].text), 255, (int)pink.R, (int)pink.G, (int)pink.B, 460);
1181 }
1182 }
1183 else if (Main.netMode == 0)
1184 {
1185 if (Main.player[Main.myPlayer].Distance(new Vector2(num33 * 16 + 16, num34 * 16 + 16)) <= (float)Main.AnnouncementBoxRange)
1186 {
1187 Main.NewTextMultiline(Main.sign[num37].text, force: false, pink, 460);
1188 }
1189 }
1190 else
1191 {
1192 if (Main.netMode != 2)
1193 {
1194 return;
1195 }
1196 for (int num38 = 0; num38 < 255; num38++)
1197 {
1198 if (Main.player[num38].active && Main.player[num38].Distance(new Vector2(num33 * 16 + 16, num34 * 16 + 16)) <= (float)Main.AnnouncementBoxRange)
1199 {
1200 NetMessage.SendData(107, num38, -1, NetworkText.FromLiteral(Main.sign[num37].text), 255, (int)pink.R, (int)pink.G, (int)pink.B, 460);
1201 }
1202 }
1203 }
1204 return;
1205 }
1206 if (type == 405)
1207 {
1209 return;
1210 }
1211 if (type == 209)
1212 {
1213 int num39 = tile.frameX % 72 / 18;
1214 int num40 = tile.frameY % 54 / 18;
1215 int num41 = i - num39;
1216 int num42 = j - num40;
1217 int num43 = tile.frameY / 54;
1218 int num44 = tile.frameX / 72;
1219 int num45 = -1;
1220 if (num39 == 1 || num39 == 2)
1221 {
1222 num45 = num40;
1223 }
1224 int num46 = 0;
1225 if (num39 == 3)
1226 {
1227 num46 = -54;
1228 }
1229 if (num39 == 0)
1230 {
1231 num46 = 54;
1232 }
1233 if (num43 >= 8 && num46 > 0)
1234 {
1235 num46 = 0;
1236 }
1237 if (num43 == 0 && num46 < 0)
1238 {
1239 num46 = 0;
1240 }
1241 bool flag = false;
1242 if (num46 != 0)
1243 {
1244 for (int num47 = num41; num47 < num41 + 4; num47++)
1245 {
1246 for (int num48 = num42; num48 < num42 + 3; num48++)
1247 {
1249 Main.tile[num47, num48].frameY = (short)(Main.tile[num47, num48].frameY + num46);
1250 }
1251 }
1252 flag = true;
1253 }
1254 if ((num44 == 3 || num44 == 4) && (num45 == 0 || num45 == 1))
1255 {
1256 num46 = ((num44 == 3) ? 72 : (-72));
1257 for (int num49 = num41; num49 < num41 + 4; num49++)
1258 {
1259 for (int num50 = num42; num50 < num42 + 3; num50++)
1260 {
1262 Main.tile[num49, num50].frameX = (short)(Main.tile[num49, num50].frameX + num46);
1263 }
1264 }
1265 flag = true;
1266 }
1267 if (flag)
1268 {
1270 }
1271 if (num45 != -1)
1272 {
1273 bool flag2 = true;
1274 if ((num44 == 3 || num44 == 4) && num45 < 2)
1275 {
1276 flag2 = false;
1277 }
1278 if (CheckMech(num41, num42, 30) && flag2)
1279 {
1281 }
1282 }
1283 return;
1284 }
1285 if (type == 212)
1286 {
1287 int num51 = tile.frameX % 54 / 18;
1288 int num52 = tile.frameY % 54 / 18;
1289 int num53 = i - num51;
1290 int num54 = j - num52;
1291 int num55 = tile.frameX / 54;
1292 int num56 = -1;
1293 if (num51 == 1)
1294 {
1295 num56 = num52;
1296 }
1297 int num57 = 0;
1298 if (num51 == 0)
1299 {
1300 num57 = -54;
1301 }
1302 if (num51 == 2)
1303 {
1304 num57 = 54;
1305 }
1306 if (num55 >= 1 && num57 > 0)
1307 {
1308 num57 = 0;
1309 }
1310 if (num55 == 0 && num57 < 0)
1311 {
1312 num57 = 0;
1313 }
1314 bool flag3 = false;
1315 if (num57 != 0)
1316 {
1317 for (int num58 = num53; num58 < num53 + 3; num58++)
1318 {
1319 for (int num59 = num54; num59 < num54 + 3; num59++)
1320 {
1322 Main.tile[num58, num59].frameX = (short)(Main.tile[num58, num59].frameX + num57);
1323 }
1324 }
1325 flag3 = true;
1326 }
1327 if (flag3)
1328 {
1330 }
1331 if (num56 != -1 && CheckMech(num53, num54, 10))
1332 {
1333 float num60 = 12f + (float)Main.rand.Next(450) * 0.01f;
1334 float num61 = Main.rand.Next(85, 105);
1335 float num62 = Main.rand.Next(-35, 11);
1336 int type2 = 166;
1337 int damage = 0;
1338 float knockBack = 0f;
1339 Vector2 vector = new Vector2((num53 + 2) * 16 - 8, (num54 + 2) * 16 - 8);
1340 if (tile.frameX / 54 == 0)
1341 {
1342 num61 *= -1f;
1343 vector.X -= 12f;
1344 }
1345 else
1346 {
1347 vector.X += 12f;
1348 }
1349 float num63 = num61;
1350 float num64 = num62;
1351 float num65 = (float)Math.Sqrt(num63 * num63 + num64 * num64);
1352 num65 = num60 / num65;
1353 num63 *= num65;
1354 num64 *= num65;
1356 }
1357 return;
1358 }
1359 if (type == 215)
1360 {
1362 return;
1363 }
1364 if (type == 130)
1365 {
1366 if (Main.tile[i, j - 1] == null || !Main.tile[i, j - 1].active() || (!TileID.Sets.BasicChest[Main.tile[i, j - 1].type] && !TileID.Sets.BasicChestFake[Main.tile[i, j - 1].type] && Main.tile[i, j - 1].type != 88))
1367 {
1368 tile.type = 131;
1370 NetMessage.SendTileSquare(-1, i, j);
1371 }
1372 return;
1373 }
1374 if (type == 131)
1375 {
1376 tile.type = 130;
1378 NetMessage.SendTileSquare(-1, i, j);
1379 return;
1380 }
1381 if (type == 387 || type == 386)
1382 {
1383 bool value = type == 387;
1384 int num66 = WorldGen.ShiftTrapdoor(i, j, playerAbove: true).ToInt();
1385 if (num66 == 0)
1386 {
1387 num66 = -WorldGen.ShiftTrapdoor(i, j, playerAbove: false).ToInt();
1388 }
1389 if (num66 != 0)
1390 {
1391 NetMessage.SendData(19, -1, -1, null, 3 - value.ToInt(), i, j, num66);
1392 }
1393 return;
1394 }
1395 if (type == 389 || type == 388)
1396 {
1397 bool flag4 = type == 389;
1399 NetMessage.SendData(19, -1, -1, null, 4 + flag4.ToInt(), i, j);
1400 return;
1401 }
1402 if (type == 11)
1403 {
1404 if (WorldGen.CloseDoor(i, j, forced: true))
1405 {
1406 NetMessage.SendData(19, -1, -1, null, 1, i, j);
1407 }
1408 return;
1409 }
1410 if (type == 10)
1411 {
1412 int num67 = 1;
1413 if (Main.rand.Next(2) == 0)
1414 {
1415 num67 = -1;
1416 }
1417 if (!WorldGen.OpenDoor(i, j, num67))
1418 {
1419 if (WorldGen.OpenDoor(i, j, -num67))
1420 {
1421 NetMessage.SendData(19, -1, -1, null, 0, i, j, -num67);
1422 }
1423 }
1424 else
1425 {
1426 NetMessage.SendData(19, -1, -1, null, 0, i, j, num67);
1427 }
1428 return;
1429 }
1430 if (type == 216)
1431 {
1432 WorldGen.LaunchRocket(i, j, fromWiring: true);
1433 SkipWire(i, j);
1434 return;
1435 }
1436 if (type == 497 || (type == 15 && tile.frameY / 40 == 1) || (type == 15 && tile.frameY / 40 == 20))
1437 {
1438 int num68 = j - tile.frameY % 40 / 18;
1439 SkipWire(i, num68);
1440 SkipWire(i, num68 + 1);
1441 if (CheckMech(i, num68, 60))
1442 {
1443 Projectile.NewProjectile(GetProjectileSource(i, num68), i * 16 + 8, num68 * 16 + 12, 0f, 0f, 733, 0, 0f, Main.myPlayer);
1444 }
1445 return;
1446 }
1447 switch (type)
1448 {
1449 case 335:
1450 {
1451 int num156 = j - tile.frameY / 18;
1452 int num157 = i - tile.frameX / 18;
1454 SkipWire(num157, num156 + 1);
1455 SkipWire(num157 + 1, num156);
1456 SkipWire(num157 + 1, num156 + 1);
1457 if (CheckMech(num157, num156, 30))
1458 {
1460 }
1461 break;
1462 }
1463 case 338:
1464 {
1465 int num75 = j - tile.frameY / 18;
1466 int num76 = i - tile.frameX / 18;
1468 SkipWire(num76, num75 + 1);
1469 if (!CheckMech(num76, num75, 30))
1470 {
1471 break;
1472 }
1473 bool flag5 = false;
1474 for (int num77 = 0; num77 < 1000; num77++)
1475 {
1476 if (Main.projectile[num77].active && Main.projectile[num77].aiStyle == 73 && Main.projectile[num77].ai[0] == (float)num76 && Main.projectile[num77].ai[1] == (float)num75)
1477 {
1478 flag5 = true;
1479 break;
1480 }
1481 }
1482 if (!flag5)
1483 {
1484 int type3 = 419 + Main.rand.Next(4);
1485 Projectile.NewProjectile(GetProjectileSource(num76, num75), num76 * 16 + 8, num75 * 16 + 2, 0f, 0f, type3, 0, 0f, Main.myPlayer, num76, num75);
1486 }
1487 break;
1488 }
1489 case 235:
1490 {
1491 int num107 = i - tile.frameX / 18;
1492 if (tile.wall == 87 && (double)j > Main.worldSurface && !NPC.downedPlantBoss)
1493 {
1494 break;
1495 }
1496 if (_teleport[0].X == -1f)
1497 {
1498 _teleport[0].X = num107;
1499 _teleport[0].Y = j;
1500 if (tile.halfBrick())
1501 {
1502 _teleport[0].Y += 0.5f;
1503 }
1504 }
1505 else if (_teleport[0].X != (float)num107 || _teleport[0].Y != (float)j)
1506 {
1507 _teleport[1].X = num107;
1508 _teleport[1].Y = j;
1509 if (tile.halfBrick())
1510 {
1511 _teleport[1].Y += 0.5f;
1512 }
1513 }
1514 break;
1515 }
1516 case 4:
1518 break;
1519 case 429:
1520 {
1521 int num78 = Main.tile[i, j].frameX / 18;
1522 bool flag6 = num78 % 2 >= 1;
1523 bool flag7 = num78 % 4 >= 2;
1524 bool flag8 = num78 % 8 >= 4;
1525 bool flag9 = num78 % 16 >= 8;
1526 bool flag10 = false;
1527 short num79 = 0;
1528 switch (_currentWireColor)
1529 {
1530 case 1:
1531 num79 = 18;
1532 flag10 = !flag6;
1533 break;
1534 case 2:
1535 num79 = 72;
1536 flag10 = !flag8;
1537 break;
1538 case 3:
1539 num79 = 36;
1540 flag10 = !flag7;
1541 break;
1542 case 4:
1543 num79 = 144;
1544 flag10 = !flag9;
1545 break;
1546 }
1547 if (flag10)
1548 {
1549 tile.frameX += num79;
1550 }
1551 else
1552 {
1553 tile.frameX -= num79;
1554 }
1555 NetMessage.SendTileSquare(-1, i, j);
1556 break;
1557 }
1558 case 149:
1560 break;
1561 case 244:
1562 {
1563 int num131;
1564 for (num131 = tile.frameX / 18; num131 >= 3; num131 -= 3)
1565 {
1566 }
1567 int num132;
1568 for (num132 = tile.frameY / 18; num132 >= 3; num132 -= 3)
1569 {
1570 }
1571 int num133 = i - num131;
1572 int num134 = j - num132;
1573 int num135 = 54;
1574 if (Main.tile[num133, num134].frameX >= 54)
1575 {
1576 num135 = -54;
1577 }
1578 for (int num136 = num133; num136 < num133 + 3; num136++)
1579 {
1580 for (int num137 = num134; num137 < num134 + 2; num137++)
1581 {
1583 Main.tile[num136, num137].frameX = (short)(Main.tile[num136, num137].frameX + num135);
1584 }
1585 }
1587 break;
1588 }
1589 case 565:
1590 {
1591 int num98;
1592 for (num98 = tile.frameX / 18; num98 >= 2; num98 -= 2)
1593 {
1594 }
1595 int num99;
1596 for (num99 = tile.frameY / 18; num99 >= 2; num99 -= 2)
1597 {
1598 }
1599 int num100 = i - num98;
1600 int num101 = j - num99;
1601 int num102 = 36;
1602 if (Main.tile[num100, num101].frameX >= 36)
1603 {
1604 num102 = -36;
1605 }
1606 for (int num103 = num100; num103 < num100 + 2; num103++)
1607 {
1608 for (int num104 = num101; num104 < num101 + 2; num104++)
1609 {
1611 Main.tile[num103, num104].frameX = (short)(Main.tile[num103, num104].frameX + num102);
1612 }
1613 }
1615 break;
1616 }
1617 case 42:
1619 break;
1620 case 93:
1622 break;
1623 case 95:
1624 case 100:
1625 case 126:
1626 case 173:
1627 case 564:
1629 break;
1630 case 593:
1631 {
1632 SkipWire(i, j);
1633 short num105 = (short)((Main.tile[i, j].frameX != 0) ? (-18) : 18);
1634 Main.tile[i, j].frameX += num105;
1635 if (Main.netMode == 2)
1636 {
1637 NetMessage.SendTileSquare(-1, i, j, 1, 1);
1638 }
1639 int num106 = ((num105 > 0) ? 4 : 3);
1642 break;
1643 }
1644 case 594:
1645 {
1646 int num80;
1647 for (num80 = tile.frameY / 18; num80 >= 2; num80 -= 2)
1648 {
1649 }
1650 num80 = j - num80;
1651 int num81 = tile.frameX / 18;
1652 if (num81 > 1)
1653 {
1654 num81 -= 2;
1655 }
1656 num81 = i - num81;
1658 SkipWire(num81, num80 + 1);
1659 SkipWire(num81 + 1, num80);
1660 SkipWire(num81 + 1, num80 + 1);
1661 short num82 = (short)((Main.tile[num81, num80].frameX != 0) ? (-36) : 36);
1662 for (int num83 = 0; num83 < 2; num83++)
1663 {
1664 for (int num84 = 0; num84 < 2; num84++)
1665 {
1666 Main.tile[num81 + num83, num80 + num84].frameX += num82;
1667 }
1668 }
1669 if (Main.netMode == 2)
1670 {
1672 }
1673 int num85 = ((num82 > 0) ? 4 : 3);
1676 break;
1677 }
1678 case 34:
1680 break;
1681 case 314:
1682 if (CheckMech(i, j, 5))
1683 {
1685 }
1686 break;
1687 case 33:
1688 case 49:
1689 case 174:
1690 case 372:
1691 case 646:
1693 break;
1694 case 92:
1696 break;
1697 case 137:
1698 {
1699 int num138 = tile.frameY / 18;
1701 float speedX = 0f;
1702 float speedY = 0f;
1703 int num139 = 0;
1704 int damage3 = 0;
1705 switch (num138)
1706 {
1707 case 0:
1708 case 1:
1709 case 2:
1710 case 5:
1711 if (CheckMech(i, j, 200))
1712 {
1713 int num147 = ((tile.frameX == 0) ? (-1) : ((tile.frameX == 18) ? 1 : 0));
1714 int num148 = ((tile.frameX >= 36) ? ((tile.frameX >= 72) ? 1 : (-1)) : 0);
1715 vector3 = new Vector2(i * 16 + 8 + 10 * num147, j * 16 + 8 + 10 * num148);
1716 float num149 = 3f;
1717 if (num138 == 0)
1718 {
1719 num139 = 98;
1720 damage3 = 20;
1721 num149 = 12f;
1722 }
1723 if (num138 == 1)
1724 {
1725 num139 = 184;
1726 damage3 = 40;
1727 num149 = 12f;
1728 }
1729 if (num138 == 2)
1730 {
1731 num139 = 187;
1732 damage3 = 40;
1733 num149 = 5f;
1734 }
1735 if (num138 == 5)
1736 {
1737 num139 = 980;
1738 damage3 = 30;
1739 num149 = 12f;
1740 }
1741 speedX = (float)num147 * num149;
1742 speedY = (float)num148 * num149;
1743 }
1744 break;
1745 case 3:
1746 {
1747 if (!CheckMech(i, j, 300))
1748 {
1749 break;
1750 }
1751 int num142 = 200;
1752 for (int num143 = 0; num143 < 1000; num143++)
1753 {
1754 if (Main.projectile[num143].active && Main.projectile[num143].type == num139)
1755 {
1756 float num144 = (new Vector2(i * 16 + 8, j * 18 + 8) - Main.projectile[num143].Center).Length();
1757 num142 = ((!(num144 < 50f)) ? ((!(num144 < 100f)) ? ((!(num144 < 200f)) ? ((!(num144 < 300f)) ? ((!(num144 < 400f)) ? ((!(num144 < 500f)) ? ((!(num144 < 700f)) ? ((!(num144 < 900f)) ? ((!(num144 < 1200f)) ? (num142 - 1) : (num142 - 2)) : (num142 - 3)) : (num142 - 4)) : (num142 - 5)) : (num142 - 6)) : (num142 - 8)) : (num142 - 10)) : (num142 - 15)) : (num142 - 50));
1758 }
1759 }
1760 if (num142 > 0)
1761 {
1762 num139 = 185;
1763 damage3 = 40;
1764 int num145 = 0;
1765 int num146 = 0;
1766 switch (tile.frameX / 18)
1767 {
1768 case 0:
1769 case 1:
1770 num145 = 0;
1771 num146 = 1;
1772 break;
1773 case 2:
1774 num145 = 0;
1775 num146 = -1;
1776 break;
1777 case 3:
1778 num145 = -1;
1779 num146 = 0;
1780 break;
1781 case 4:
1782 num145 = 1;
1783 num146 = 0;
1784 break;
1785 }
1786 speedX = (float)(4 * num145) + (float)Main.rand.Next(-20 + ((num145 == 1) ? 20 : 0), 21 - ((num145 == -1) ? 20 : 0)) * 0.05f;
1787 speedY = (float)(4 * num146) + (float)Main.rand.Next(-20 + ((num146 == 1) ? 20 : 0), 21 - ((num146 == -1) ? 20 : 0)) * 0.05f;
1788 vector3 = new Vector2(i * 16 + 8 + 14 * num145, j * 16 + 8 + 14 * num146);
1789 }
1790 break;
1791 }
1792 case 4:
1793 if (CheckMech(i, j, 90))
1794 {
1795 int num140 = 0;
1796 int num141 = 0;
1797 switch (tile.frameX / 18)
1798 {
1799 case 0:
1800 case 1:
1801 num140 = 0;
1802 num141 = 1;
1803 break;
1804 case 2:
1805 num140 = 0;
1806 num141 = -1;
1807 break;
1808 case 3:
1809 num140 = -1;
1810 num141 = 0;
1811 break;
1812 case 4:
1813 num140 = 1;
1814 num141 = 0;
1815 break;
1816 }
1817 speedX = 8 * num140;
1818 speedY = 8 * num141;
1819 damage3 = 60;
1820 num139 = 186;
1821 vector3 = new Vector2(i * 16 + 8 + 18 * num140, j * 16 + 8 + 18 * num141);
1822 }
1823 break;
1824 }
1825 switch (num138)
1826 {
1827 case -10:
1828 if (CheckMech(i, j, 200))
1829 {
1830 int num154 = -1;
1831 if (tile.frameX != 0)
1832 {
1833 num154 = 1;
1834 }
1835 speedX = 12 * num154;
1836 damage3 = 20;
1837 num139 = 98;
1838 vector3 = new Vector2(i * 16 + 8, j * 16 + 7);
1839 vector3.X += 10 * num154;
1840 vector3.Y += 2f;
1841 }
1842 break;
1843 case -9:
1844 if (CheckMech(i, j, 200))
1845 {
1846 int num150 = -1;
1847 if (tile.frameX != 0)
1848 {
1849 num150 = 1;
1850 }
1851 speedX = 12 * num150;
1852 damage3 = 40;
1853 num139 = 184;
1854 vector3 = new Vector2(i * 16 + 8, j * 16 + 7);
1855 vector3.X += 10 * num150;
1856 vector3.Y += 2f;
1857 }
1858 break;
1859 case -8:
1860 if (CheckMech(i, j, 200))
1861 {
1862 int num155 = -1;
1863 if (tile.frameX != 0)
1864 {
1865 num155 = 1;
1866 }
1867 speedX = 5 * num155;
1868 damage3 = 40;
1869 num139 = 187;
1870 vector3 = new Vector2(i * 16 + 8, j * 16 + 7);
1871 vector3.X += 10 * num155;
1872 vector3.Y += 2f;
1873 }
1874 break;
1875 case -7:
1876 {
1877 if (!CheckMech(i, j, 300))
1878 {
1879 break;
1880 }
1881 num139 = 185;
1882 int num151 = 200;
1883 for (int num152 = 0; num152 < 1000; num152++)
1884 {
1885 if (Main.projectile[num152].active && Main.projectile[num152].type == num139)
1886 {
1887 float num153 = (new Vector2(i * 16 + 8, j * 18 + 8) - Main.projectile[num152].Center).Length();
1888 num151 = ((!(num153 < 50f)) ? ((!(num153 < 100f)) ? ((!(num153 < 200f)) ? ((!(num153 < 300f)) ? ((!(num153 < 400f)) ? ((!(num153 < 500f)) ? ((!(num153 < 700f)) ? ((!(num153 < 900f)) ? ((!(num153 < 1200f)) ? (num151 - 1) : (num151 - 2)) : (num151 - 3)) : (num151 - 4)) : (num151 - 5)) : (num151 - 6)) : (num151 - 8)) : (num151 - 10)) : (num151 - 15)) : (num151 - 50));
1889 }
1890 }
1891 if (num151 > 0)
1892 {
1893 speedX = (float)Main.rand.Next(-20, 21) * 0.05f;
1894 speedY = 4f + (float)Main.rand.Next(0, 21) * 0.05f;
1895 damage3 = 40;
1896 vector3 = new Vector2(i * 16 + 8, j * 16 + 16);
1897 vector3.Y += 6f;
1899 }
1900 break;
1901 }
1902 case -6:
1903 if (CheckMech(i, j, 90))
1904 {
1905 speedX = 0f;
1906 speedY = 8f;
1907 damage3 = 60;
1908 num139 = 186;
1909 vector3 = new Vector2(i * 16 + 8, j * 16 + 16);
1910 vector3.Y += 10f;
1911 }
1912 break;
1913 }
1914 if (num139 != 0)
1915 {
1917 }
1918 break;
1919 }
1920 case 443:
1921 GeyserTrap(i, j);
1922 break;
1923 case 531:
1924 {
1925 int num126 = tile.frameX / 36;
1926 int num127 = tile.frameY / 54;
1927 int num128 = i - (tile.frameX - num126 * 36) / 18;
1928 int num129 = j - (tile.frameY - num127 * 54) / 18;
1929 if (CheckMech(num128, num129, 900))
1930 {
1931 Vector2 vector2 = new Vector2(num128 + 1, num129) * 16f;
1932 vector2.Y += 28f;
1933 int num130 = 99;
1934 int damage2 = 70;
1935 float knockBack2 = 10f;
1936 if (num130 != 0)
1937 {
1939 }
1940 }
1941 break;
1942 }
1943 case 35:
1944 case 139:
1945 WorldGen.SwitchMB(i, j);
1946 break;
1947 case 207:
1949 break;
1950 case 410:
1951 case 480:
1952 case 509:
1953 case 657:
1954 case 658:
1956 break;
1957 case 455:
1959 break;
1960 case 141:
1961 WorldGen.KillTile(i, j, fail: false, effectOnly: false, noItem: true);
1962 NetMessage.SendTileSquare(-1, i, j);
1963 Projectile.NewProjectile(GetProjectileSource(i, j), i * 16 + 8, j * 16 + 8, 0f, 0f, 108, 500, 10f, Main.myPlayer);
1964 break;
1965 case 210:
1966 WorldGen.ExplodeMine(i, j, fromWiring: true);
1967 break;
1968 case 142:
1969 case 143:
1970 {
1971 int num92 = j - tile.frameY / 18;
1972 int num93 = tile.frameX / 18;
1973 if (num93 > 1)
1974 {
1975 num93 -= 2;
1976 }
1977 num93 = i - num93;
1979 SkipWire(num93, num92 + 1);
1980 SkipWire(num93 + 1, num92);
1981 SkipWire(num93 + 1, num92 + 1);
1982 if (type == 142)
1983 {
1984 for (int num94 = 0; num94 < 4; num94++)
1985 {
1986 if (_numInPump >= 19)
1987 {
1988 break;
1989 }
1990 int num95;
1991 int num96;
1992 switch (num94)
1993 {
1994 case 0:
1995 num95 = num93;
1996 num96 = num92 + 1;
1997 break;
1998 case 1:
1999 num95 = num93 + 1;
2000 num96 = num92 + 1;
2001 break;
2002 case 2:
2003 num95 = num93;
2004 num96 = num92;
2005 break;
2006 default:
2007 num95 = num93 + 1;
2008 num96 = num92;
2009 break;
2010 }
2013 _numInPump++;
2014 }
2015 break;
2016 }
2017 for (int num97 = 0; num97 < 4; num97++)
2018 {
2019 if (_numOutPump >= 19)
2020 {
2021 break;
2022 }
2023 int num95;
2024 int num96;
2025 switch (num97)
2026 {
2027 case 0:
2028 num95 = num93;
2029 num96 = num92 + 1;
2030 break;
2031 case 1:
2032 num95 = num93 + 1;
2033 num96 = num92 + 1;
2034 break;
2035 case 2:
2036 num95 = num93;
2037 num96 = num92;
2038 break;
2039 default:
2040 num95 = num93 + 1;
2041 num96 = num92;
2042 break;
2043 }
2046 _numOutPump++;
2047 }
2048 break;
2049 }
2050 case 105:
2051 {
2052 int num108 = j - tile.frameY / 18;
2053 int num109 = tile.frameX / 18;
2054 int num110 = 0;
2055 while (num109 >= 2)
2056 {
2057 num109 -= 2;
2058 num110++;
2059 }
2060 num109 = i - num109;
2061 num109 = i - tile.frameX % 36 / 18;
2062 num108 = j - tile.frameY % 54 / 18;
2063 int num111 = tile.frameY / 54;
2064 num111 %= 3;
2065 num110 = tile.frameX / 36 + num111 * 55;
2067 SkipWire(num109, num108 + 1);
2068 SkipWire(num109, num108 + 2);
2069 SkipWire(num109 + 1, num108);
2070 SkipWire(num109 + 1, num108 + 1);
2071 SkipWire(num109 + 1, num108 + 2);
2072 int num112 = num109 * 16 + 16;
2073 int num113 = (num108 + 3) * 16;
2074 int num114 = -1;
2075 int num115 = -1;
2076 bool flag11 = true;
2077 bool flag12 = false;
2078 switch (num110)
2079 {
2080 case 5:
2081 num115 = 73;
2082 break;
2083 case 13:
2084 num115 = 24;
2085 break;
2086 case 30:
2087 num115 = 6;
2088 break;
2089 case 35:
2090 num115 = 2;
2091 break;
2092 case 51:
2093 num115 = Utils.SelectRandom(Main.rand, new short[2] { 299, 538 });
2094 break;
2095 case 52:
2096 num115 = 356;
2097 break;
2098 case 53:
2099 num115 = 357;
2100 break;
2101 case 54:
2102 num115 = Utils.SelectRandom(Main.rand, new short[2] { 355, 358 });
2103 break;
2104 case 55:
2105 num115 = Utils.SelectRandom(Main.rand, new short[2] { 367, 366 });
2106 break;
2107 case 56:
2108 num115 = Utils.SelectRandom(Main.rand, new short[5] { 359, 359, 359, 359, 360 });
2109 break;
2110 case 57:
2111 num115 = 377;
2112 break;
2113 case 58:
2114 num115 = 300;
2115 break;
2116 case 59:
2117 num115 = Utils.SelectRandom(Main.rand, new short[2] { 364, 362 });
2118 break;
2119 case 60:
2120 num115 = 148;
2121 break;
2122 case 61:
2123 num115 = 361;
2124 break;
2125 case 62:
2126 num115 = Utils.SelectRandom(Main.rand, new short[3] { 487, 486, 485 });
2127 break;
2128 case 63:
2129 num115 = 164;
2130 flag11 &= NPC.MechSpawn(num112, num113, 165);
2131 break;
2132 case 64:
2133 num115 = 86;
2134 flag12 = true;
2135 break;
2136 case 65:
2137 num115 = 490;
2138 break;
2139 case 66:
2140 num115 = 82;
2141 break;
2142 case 67:
2143 num115 = 449;
2144 break;
2145 case 68:
2146 num115 = 167;
2147 break;
2148 case 69:
2149 num115 = 480;
2150 break;
2151 case 70:
2152 num115 = 48;
2153 break;
2154 case 71:
2155 num115 = Utils.SelectRandom(Main.rand, new short[3] { 170, 180, 171 });
2156 flag12 = true;
2157 break;
2158 case 72:
2159 num115 = 481;
2160 break;
2161 case 73:
2162 num115 = 482;
2163 break;
2164 case 74:
2165 num115 = 430;
2166 break;
2167 case 75:
2168 num115 = 489;
2169 break;
2170 case 76:
2171 num115 = 611;
2172 break;
2173 case 77:
2174 num115 = 602;
2175 break;
2176 case 78:
2177 num115 = Utils.SelectRandom(Main.rand, new short[6] { 595, 596, 599, 597, 600, 598 });
2178 break;
2179 case 79:
2180 num115 = Utils.SelectRandom(Main.rand, new short[2] { 616, 617 });
2181 break;
2182 case 80:
2183 num115 = Utils.SelectRandom(Main.rand, new short[2] { 671, 672 });
2184 break;
2185 case 81:
2186 num115 = 673;
2187 break;
2188 case 82:
2189 num115 = Utils.SelectRandom(Main.rand, new short[2] { 674, 675 });
2190 break;
2191 }
2192 if (num115 != -1 && CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, num115) && flag11)
2193 {
2194 if (!flag12 || !Collision.SolidTiles(num109 - 2, num109 + 3, num108, num108 + 2))
2195 {
2196 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113, num115);
2197 }
2198 else
2199 {
2200 Vector2 position = new Vector2(num112 - 4, num113 - 22) - new Vector2(10f);
2201 Utils.PoofOfSmoke(position);
2202 NetMessage.SendData(106, -1, -1, null, (int)position.X, position.Y);
2203 }
2204 }
2205 if (num114 <= -1)
2206 {
2207 switch (num110)
2208 {
2209 case 4:
2210 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 1))
2211 {
2212 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, 1);
2213 }
2214 break;
2215 case 7:
2216 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 49))
2217 {
2218 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112 - 4, num113 - 6, 49);
2219 }
2220 break;
2221 case 8:
2222 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 55))
2223 {
2224 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, 55);
2225 }
2226 break;
2227 case 9:
2228 {
2229 int type4 = 46;
2231 {
2232 type4 = 540;
2233 }
2234 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, type4))
2235 {
2236 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, type4);
2237 }
2238 break;
2239 }
2240 case 10:
2241 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 21))
2242 {
2243 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113, 21);
2244 }
2245 break;
2246 case 16:
2247 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 42))
2248 {
2249 if (!Collision.SolidTiles(num109 - 1, num109 + 1, num108, num108 + 1))
2250 {
2251 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, 42);
2252 break;
2253 }
2254 Vector2 position3 = new Vector2(num112 - 4, num113 - 22) - new Vector2(10f);
2255 Utils.PoofOfSmoke(position3);
2256 NetMessage.SendData(106, -1, -1, null, (int)position3.X, position3.Y);
2257 }
2258 break;
2259 case 18:
2260 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 67))
2261 {
2262 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, 67);
2263 }
2264 break;
2265 case 23:
2266 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 63))
2267 {
2268 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, 63);
2269 }
2270 break;
2271 case 27:
2272 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 85))
2273 {
2274 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112 - 9, num113, 85);
2275 }
2276 break;
2277 case 28:
2278 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 74))
2279 {
2280 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, Utils.SelectRandom(Main.rand, new short[3] { 74, 297, 298 }));
2281 }
2282 break;
2283 case 34:
2284 {
2285 for (int num124 = 0; num124 < 2; num124++)
2286 {
2287 for (int num125 = 0; num125 < 3; num125++)
2288 {
2290 tile2.type = 349;
2291 tile2.frameX = (short)(num124 * 18 + 216);
2292 tile2.frameY = (short)(num125 * 18);
2293 }
2294 }
2296 if (Main.netMode == 2)
2297 {
2299 }
2300 break;
2301 }
2302 case 42:
2303 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 58))
2304 {
2305 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, 58);
2306 }
2307 break;
2308 case 37:
2309 if (CheckMech(num109, num108, 600) && Item.MechSpawn(num112, num113, 58) && Item.MechSpawn(num112, num113, 1734) && Item.MechSpawn(num112, num113, 1867))
2310 {
2311 Item.NewItem(GetItemSource(num112, num113), num112, num113 - 16, 0, 0, 58);
2312 }
2313 break;
2314 case 50:
2315 if (CheckMech(num109, num108, 30) && NPC.MechSpawn(num112, num113, 65))
2316 {
2317 if (!Collision.SolidTiles(num109 - 2, num109 + 3, num108, num108 + 2))
2318 {
2319 num114 = NPC.NewNPC(GetNPCSource(num109, num108), num112, num113 - 12, 65);
2320 break;
2321 }
2322 Vector2 position2 = new Vector2(num112 - 4, num113 - 22) - new Vector2(10f);
2323 Utils.PoofOfSmoke(position2);
2324 NetMessage.SendData(106, -1, -1, null, (int)position2.X, position2.Y);
2325 }
2326 break;
2327 case 2:
2328 if (CheckMech(num109, num108, 600) && Item.MechSpawn(num112, num113, 184) && Item.MechSpawn(num112, num113, 1735) && Item.MechSpawn(num112, num113, 1868))
2329 {
2330 Item.NewItem(GetItemSource(num112, num113), num112, num113 - 16, 0, 0, 184);
2331 }
2332 break;
2333 case 17:
2334 if (CheckMech(num109, num108, 600) && Item.MechSpawn(num112, num113, 166))
2335 {
2336 Item.NewItem(GetItemSource(num112, num113), num112, num113 - 20, 0, 0, 166);
2337 }
2338 break;
2339 case 40:
2340 {
2341 if (!CheckMech(num109, num108, 300))
2342 {
2343 break;
2344 }
2345 int num120 = 50;
2346 int[] array2 = new int[num120];
2347 int num121 = 0;
2348 for (int num122 = 0; num122 < 200; num122++)
2349 {
2350 if (Main.npc[num122].active && (Main.npc[num122].type == 17 || Main.npc[num122].type == 19 || Main.npc[num122].type == 22 || Main.npc[num122].type == 38 || Main.npc[num122].type == 54 || Main.npc[num122].type == 107 || Main.npc[num122].type == 108 || Main.npc[num122].type == 142 || Main.npc[num122].type == 160 || Main.npc[num122].type == 207 || Main.npc[num122].type == 209 || Main.npc[num122].type == 227 || Main.npc[num122].type == 228 || Main.npc[num122].type == 229 || Main.npc[num122].type == 368 || Main.npc[num122].type == 369 || Main.npc[num122].type == 550 || Main.npc[num122].type == 441 || Main.npc[num122].type == 588))
2351 {
2352 array2[num121] = num122;
2353 num121++;
2354 if (num121 >= num120)
2355 {
2356 break;
2357 }
2358 }
2359 }
2360 if (num121 > 0)
2361 {
2362 int num123 = array2[Main.rand.Next(num121)];
2363 Main.npc[num123].position.X = num112 - Main.npc[num123].width / 2;
2364 Main.npc[num123].position.Y = num113 - Main.npc[num123].height - 1;
2365 NetMessage.SendData(23, -1, -1, null, num123);
2366 }
2367 break;
2368 }
2369 case 41:
2370 {
2371 if (!CheckMech(num109, num108, 300))
2372 {
2373 break;
2374 }
2375 int num116 = 50;
2376 int[] array = new int[num116];
2377 int num117 = 0;
2378 for (int num118 = 0; num118 < 200; num118++)
2379 {
2380 if (Main.npc[num118].active && (Main.npc[num118].type == 18 || Main.npc[num118].type == 20 || Main.npc[num118].type == 124 || Main.npc[num118].type == 178 || Main.npc[num118].type == 208 || Main.npc[num118].type == 353 || Main.npc[num118].type == 633 || Main.npc[num118].type == 663))
2381 {
2382 array[num117] = num118;
2383 num117++;
2384 if (num117 >= num116)
2385 {
2386 break;
2387 }
2388 }
2389 }
2390 if (num117 > 0)
2391 {
2392 int num119 = array[Main.rand.Next(num117)];
2393 Main.npc[num119].position.X = num112 - Main.npc[num119].width / 2;
2394 Main.npc[num119].position.Y = num113 - Main.npc[num119].height - 1;
2395 NetMessage.SendData(23, -1, -1, null, num119);
2396 }
2397 break;
2398 }
2399 }
2400 }
2401 if (num114 >= 0)
2402 {
2403 Main.npc[num114].value = 0f;
2404 Main.npc[num114].npcSlots = 0f;
2405 Main.npc[num114].SpawnedFromStatue = true;
2406 Main.npc[num114].CanBeReplacedByOtherNPCs = true;
2407 }
2408 break;
2409 }
2410 case 349:
2411 {
2412 int num86 = tile.frameY / 18;
2413 num86 %= 3;
2414 int num87 = j - num86;
2415 int num88;
2416 for (num88 = tile.frameX / 18; num88 >= 2; num88 -= 2)
2417 {
2418 }
2419 num88 = i - num88;
2420 SkipWire(num88, num87);
2421 SkipWire(num88, num87 + 1);
2422 SkipWire(num88, num87 + 2);
2423 SkipWire(num88 + 1, num87);
2424 SkipWire(num88 + 1, num87 + 1);
2425 SkipWire(num88 + 1, num87 + 2);
2426 short num89 = (short)((Main.tile[num88, num87].frameX != 0) ? (-216) : 216);
2427 for (int num90 = 0; num90 < 2; num90++)
2428 {
2429 for (int num91 = 0; num91 < 3; num91++)
2430 {
2431 Main.tile[num88 + num90, num87 + num91].frameX += num89;
2432 }
2433 }
2434 if (Main.netMode == 2)
2435 {
2437 }
2438 Animation.NewTemporaryAnimation((num89 <= 0) ? 1 : 0, 349, num88, num87);
2439 break;
2440 }
2441 case 506:
2442 {
2443 int num69 = tile.frameY / 18;
2444 num69 %= 3;
2445 int num70 = j - num69;
2446 int num71;
2447 for (num71 = tile.frameX / 18; num71 >= 2; num71 -= 2)
2448 {
2449 }
2450 num71 = i - num71;
2451 SkipWire(num71, num70);
2452 SkipWire(num71, num70 + 1);
2453 SkipWire(num71, num70 + 2);
2454 SkipWire(num71 + 1, num70);
2455 SkipWire(num71 + 1, num70 + 1);
2456 SkipWire(num71 + 1, num70 + 2);
2457 short num72 = (short)((Main.tile[num71, num70].frameX >= 72) ? (-72) : 72);
2458 for (int num73 = 0; num73 < 2; num73++)
2459 {
2460 for (int num74 = 0; num74 < 3; num74++)
2461 {
2462 Main.tile[num71 + num73, num70 + num74].frameX += num72;
2463 }
2464 }
2465 if (Main.netMode == 2)
2466 {
2468 }
2469 break;
2470 }
2471 case 546:
2472 tile.type = 557;
2474 NetMessage.SendTileSquare(-1, i, j);
2475 break;
2476 case 557:
2477 tile.type = 546;
2479 NetMessage.SendTileSquare(-1, i, j);
2480 break;
2481 }
2482 }
2483
2484 public static void ToggleHolidayLight(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
2485 {
2486 bool flag = tileCache.frameX >= 54;
2487 if (!forcedStateWhereTrueIsOn.HasValue || !forcedStateWhereTrueIsOn.Value != flag)
2488 {
2489 if (tileCache.frameX < 54)
2490 {
2491 tileCache.frameX += 54;
2492 }
2493 else
2494 {
2495 tileCache.frameX -= 54;
2496 }
2497 NetMessage.SendTileSquare(-1, i, j);
2498 }
2499 }
2500
2501 public static void ToggleHangingLantern(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
2502 {
2503 int num;
2504 for (num = tileCache.frameY / 18; num >= 2; num -= 2)
2505 {
2506 }
2507 int num2 = j - num;
2508 short num3 = 18;
2509 if (tileCache.frameX > 0)
2510 {
2511 num3 = -18;
2512 }
2513 bool flag = tileCache.frameX > 0;
2514 if (!forcedStateWhereTrueIsOn.HasValue || !forcedStateWhereTrueIsOn.Value != flag)
2515 {
2516 Main.tile[i, num2].frameX += num3;
2517 Main.tile[i, num2 + 1].frameX += num3;
2518 if (doSkipWires)
2519 {
2520 SkipWire(i, num2);
2521 SkipWire(i, num2 + 1);
2522 }
2523 NetMessage.SendTileSquare(-1, i, j, 1, 2);
2524 }
2525 }
2526
2527 public static void Toggle2x2Light(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
2528 {
2529 int num;
2530 for (num = tileCache.frameY / 18; num >= 2; num -= 2)
2531 {
2532 }
2533 num = j - num;
2534 int num2 = tileCache.frameX / 18;
2535 if (num2 > 1)
2536 {
2537 num2 -= 2;
2538 }
2539 num2 = i - num2;
2540 short num3 = 36;
2541 if (Main.tile[num2, num].frameX > 0)
2542 {
2543 num3 = -36;
2544 }
2545 bool flag = Main.tile[num2, num].frameX > 0;
2546 if (!forcedStateWhereTrueIsOn.HasValue || !forcedStateWhereTrueIsOn.Value != flag)
2547 {
2548 Main.tile[num2, num].frameX += num3;
2549 Main.tile[num2, num + 1].frameX += num3;
2550 Main.tile[num2 + 1, num].frameX += num3;
2551 Main.tile[num2 + 1, num + 1].frameX += num3;
2552 if (doSkipWires)
2553 {
2554 SkipWire(num2, num);
2555 SkipWire(num2 + 1, num);
2556 SkipWire(num2, num + 1);
2557 SkipWire(num2 + 1, num + 1);
2558 }
2559 NetMessage.SendTileSquare(-1, num2, num, 2, 2);
2560 }
2561 }
2562
2563 public static void ToggleLampPost(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
2564 {
2565 int num = j - tileCache.frameY / 18;
2566 short num2 = 18;
2567 if (tileCache.frameX > 0)
2568 {
2569 num2 = -18;
2570 }
2571 bool flag = tileCache.frameX > 0;
2572 if (forcedStateWhereTrueIsOn.HasValue && !forcedStateWhereTrueIsOn.Value == flag)
2573 {
2574 return;
2575 }
2576 for (int k = num; k < num + 6; k++)
2577 {
2578 Main.tile[i, k].frameX += num2;
2579 if (doSkipWires)
2580 {
2581 SkipWire(i, k);
2582 }
2583 }
2584 NetMessage.SendTileSquare(-1, i, num, 1, 6);
2585 }
2586
2587 public static void ToggleTorch(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
2588 {
2589 bool flag = tileCache.frameX >= 66;
2590 if (!forcedStateWhereTrueIsOn.HasValue || !forcedStateWhereTrueIsOn.Value != flag)
2591 {
2592 if (tileCache.frameX < 66)
2593 {
2594 tileCache.frameX += 66;
2595 }
2596 else
2597 {
2598 tileCache.frameX -= 66;
2599 }
2600 NetMessage.SendTileSquare(-1, i, j);
2601 }
2602 }
2603
2604 public static void ToggleCandle(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
2605 {
2606 short num = 18;
2607 if (tileCache.frameX > 0)
2608 {
2609 num = -18;
2610 }
2611 bool flag = tileCache.frameX > 0;
2612 if (!forcedStateWhereTrueIsOn.HasValue || !forcedStateWhereTrueIsOn.Value != flag)
2613 {
2614 tileCache.frameX += num;
2615 NetMessage.SendTileSquare(-1, i, j, 3);
2616 }
2617 }
2618
2619 public static void ToggleLamp(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
2620 {
2621 int num;
2622 for (num = tileCache.frameY / 18; num >= 3; num -= 3)
2623 {
2624 }
2625 num = j - num;
2626 short num2 = 18;
2627 if (tileCache.frameX > 0)
2628 {
2629 num2 = -18;
2630 }
2631 bool flag = tileCache.frameX > 0;
2632 if (!forcedStateWhereTrueIsOn.HasValue || !forcedStateWhereTrueIsOn.Value != flag)
2633 {
2634 Main.tile[i, num].frameX += num2;
2635 Main.tile[i, num + 1].frameX += num2;
2636 Main.tile[i, num + 2].frameX += num2;
2637 if (doSkipWires)
2638 {
2639 SkipWire(i, num);
2640 SkipWire(i, num + 1);
2641 SkipWire(i, num + 2);
2642 }
2643 NetMessage.SendTileSquare(-1, i, num, 1, 3);
2644 }
2645 }
2646
2647 public static void ToggleChandelier(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
2648 {
2649 int num;
2650 for (num = tileCache.frameY / 18; num >= 3; num -= 3)
2651 {
2652 }
2653 int num2 = j - num;
2654 int num3 = tileCache.frameX % 108 / 18;
2655 if (num3 > 2)
2656 {
2657 num3 -= 3;
2658 }
2659 num3 = i - num3;
2660 short num4 = 54;
2661 if (Main.tile[num3, num2].frameX % 108 > 0)
2662 {
2663 num4 = -54;
2664 }
2665 bool flag = Main.tile[num3, num2].frameX % 108 > 0;
2666 if (forcedStateWhereTrueIsOn.HasValue && !forcedStateWhereTrueIsOn.Value == flag)
2667 {
2668 return;
2669 }
2670 for (int k = num3; k < num3 + 3; k++)
2671 {
2672 for (int l = num2; l < num2 + 3; l++)
2673 {
2674 Main.tile[k, l].frameX += num4;
2675 if (doSkipWires)
2676 {
2677 SkipWire(k, l);
2678 }
2679 }
2680 }
2681 NetMessage.SendTileSquare(-1, num3 + 1, num2 + 1, 3);
2682 }
2683
2684 public static void ToggleCampFire(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
2685 {
2686 int num = tileCache.frameX % 54 / 18;
2687 int num2 = tileCache.frameY % 36 / 18;
2688 int num3 = i - num;
2689 int num4 = j - num2;
2690 bool flag = Main.tile[num3, num4].frameY >= 36;
2691 if (forcedStateWhereTrueIsOn.HasValue && !forcedStateWhereTrueIsOn.Value == flag)
2692 {
2693 return;
2694 }
2695 int num5 = 36;
2696 if (Main.tile[num3, num4].frameY >= 36)
2697 {
2698 num5 = -36;
2699 }
2700 for (int k = num3; k < num3 + 3; k++)
2701 {
2702 for (int l = num4; l < num4 + 2; l++)
2703 {
2704 if (doSkipWires)
2705 {
2706 SkipWire(k, l);
2707 }
2708 Main.tile[k, l].frameY = (short)(Main.tile[k, l].frameY + num5);
2709 }
2710 }
2711 NetMessage.SendTileSquare(-1, num3, num4, 3, 2);
2712 }
2713
2714 public static void ToggleFirePlace(int i, int j, Tile theBlock, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
2715 {
2716 int num = theBlock.frameX % 54 / 18;
2717 int num2 = theBlock.frameY % 36 / 18;
2718 int num3 = i - num;
2719 int num4 = j - num2;
2720 bool flag = Main.tile[num3, num4].frameX >= 54;
2721 if (forcedStateWhereTrueIsOn.HasValue && !forcedStateWhereTrueIsOn.Value == flag)
2722 {
2723 return;
2724 }
2725 int num5 = 54;
2726 if (Main.tile[num3, num4].frameX >= 54)
2727 {
2728 num5 = -54;
2729 }
2730 for (int k = num3; k < num3 + 3; k++)
2731 {
2732 for (int l = num4; l < num4 + 2; l++)
2733 {
2734 if (doSkipWires)
2735 {
2736 SkipWire(k, l);
2737 }
2738 Main.tile[k, l].frameX = (short)(Main.tile[k, l].frameX + num5);
2739 }
2740 }
2741 NetMessage.SendTileSquare(-1, num3, num4, 3, 2);
2742 }
2743
2744 private static void GeyserTrap(int i, int j)
2745 {
2746 Tile tile = Main.tile[i, j];
2747 if (tile.type != 443)
2748 {
2749 return;
2750 }
2751 int num = tile.frameX / 36;
2752 int num2 = i - (tile.frameX - num * 36) / 18;
2753 if (CheckMech(num2, j, 200))
2754 {
2757 int num3 = 654;
2758 int damage = 20;
2759 if (num < 2)
2760 {
2761 zero = new Vector2(num2 + 1, j) * 16f;
2762 zero2 = new Vector2(0f, -8f);
2763 }
2764 else
2765 {
2766 zero = new Vector2(num2 + 1, j + 1) * 16f;
2767 zero2 = new Vector2(0f, 8f);
2768 }
2769 if (num3 != 0)
2770 {
2771 Projectile.NewProjectile(GetProjectileSource(num2, j), (int)zero.X, (int)zero.Y, zero2.X, zero2.Y, num3, damage, 2f, Main.myPlayer);
2772 }
2773 }
2774 }
2775
2776 private static void Teleport()
2777 {
2778 if (_teleport[0].X < _teleport[1].X + 3f && _teleport[0].X > _teleport[1].X - 3f && _teleport[0].Y > _teleport[1].Y - 3f && _teleport[0].Y < _teleport[1].Y)
2779 {
2780 return;
2781 }
2782 Rectangle[] array = new Rectangle[2];
2783 array[0].X = (int)(_teleport[0].X * 16f);
2784 array[0].Width = 48;
2785 array[0].Height = 48;
2786 array[0].Y = (int)(_teleport[0].Y * 16f - (float)array[0].Height);
2787 array[1].X = (int)(_teleport[1].X * 16f);
2788 array[1].Width = 48;
2789 array[1].Height = 48;
2790 array[1].Y = (int)(_teleport[1].Y * 16f - (float)array[1].Height);
2791 for (int i = 0; i < 2; i++)
2792 {
2793 Vector2 vector = new Vector2(array[1].X - array[0].X, array[1].Y - array[0].Y);
2794 if (i == 1)
2795 {
2796 vector = new Vector2(array[0].X - array[1].X, array[0].Y - array[1].Y);
2797 }
2798 if (!blockPlayerTeleportationForOneIteration)
2799 {
2800 for (int j = 0; j < 255; j++)
2801 {
2802 if (Main.player[j].active && !Main.player[j].dead && !Main.player[j].teleporting && TeleporterHitboxIntersects(array[i], Main.player[j].Hitbox))
2803 {
2804 Vector2 vector2 = Main.player[j].position + vector;
2805 Main.player[j].teleporting = true;
2806 if (Main.netMode == 2)
2807 {
2809 }
2810 Main.player[j].Teleport(vector2);
2811 if (Main.netMode == 2)
2812 {
2813 NetMessage.SendData(65, -1, -1, null, 0, j, vector2.X, vector2.Y);
2814 }
2815 }
2816 }
2817 }
2818 for (int k = 0; k < 200; k++)
2819 {
2820 if (Main.npc[k].active && !Main.npc[k].teleporting && Main.npc[k].lifeMax > 5 && !Main.npc[k].boss && !Main.npc[k].noTileCollide)
2821 {
2822 int type = Main.npc[k].type;
2823 if (!NPCID.Sets.TeleportationImmune[type] && TeleporterHitboxIntersects(array[i], Main.npc[k].Hitbox))
2824 {
2825 Main.npc[k].teleporting = true;
2826 Main.npc[k].Teleport(Main.npc[k].position + vector);
2827 }
2828 }
2829 }
2830 }
2831 for (int l = 0; l < 255; l++)
2832 {
2833 Main.player[l].teleporting = false;
2834 }
2835 for (int m = 0; m < 200; m++)
2836 {
2837 Main.npc[m].teleporting = false;
2838 }
2839 }
2840
2842 {
2844 if (rectangle.Width <= teleporter.Width + entity.Width)
2845 {
2846 return rectangle.Height <= teleporter.Height + entity.Height;
2847 }
2848 return false;
2849 }
2850
2851 private static void DeActive(int i, int j)
2852 {
2853 if (!Main.tile[i, j].active() || (Main.tile[i, j].type == 226 && (double)j > Main.worldSurface && !NPC.downedPlantBoss))
2854 {
2855 return;
2856 }
2857 bool flag = Main.tileSolid[Main.tile[i, j].type] && !TileID.Sets.NotReallySolid[Main.tile[i, j].type];
2858 ushort type = Main.tile[i, j].type;
2859 if (type == 314 || (uint)(type - 386) <= 3u || type == 476)
2860 {
2861 flag = false;
2862 }
2863 if (flag && (!Main.tile[i, j - 1].active() || (!TileID.Sets.BasicChest[Main.tile[i, j - 1].type] && Main.tile[i, j - 1].type != 26 && Main.tile[i, j - 1].type != 77 && Main.tile[i, j - 1].type != 88 && Main.tile[i, j - 1].type != 470 && Main.tile[i, j - 1].type != 475 && Main.tile[i, j - 1].type != 237 && Main.tile[i, j - 1].type != 597 && WorldGen.CanKillTile(i, j))))
2864 {
2865 Main.tile[i, j].inActive(inActive: true);
2867 if (Main.netMode != 1)
2868 {
2869 NetMessage.SendTileSquare(-1, i, j);
2870 }
2871 }
2872 }
2873
2874 private static void ReActive(int i, int j)
2875 {
2876 Main.tile[i, j].inActive(inActive: false);
2878 if (Main.netMode != 1)
2879 {
2880 NetMessage.SendTileSquare(-1, i, j);
2881 }
2882 }
2883
2885 {
2886 Math.Abs(ps.X - pe.X);
2887 Math.Abs(ps.Y - pe.Y);
2888 int num = Math.Sign(pe.X - ps.X);
2889 int num2 = Math.Sign(pe.Y - ps.Y);
2891 Point pt = default(Point);
2892 bool flag = false;
2895 bool flag2 = dir;
2896 int num3;
2897 int num4;
2898 int num5;
2899 if (flag2)
2900 {
2901 pt.X = ps.X;
2902 num3 = ps.Y;
2903 num4 = pe.Y;
2904 num5 = num2;
2905 }
2906 else
2907 {
2908 pt.Y = ps.Y;
2909 num3 = ps.X;
2910 num4 = pe.X;
2911 num5 = num;
2912 }
2913 for (int i = num3; i != num4; i += num5)
2914 {
2915 if (flag)
2916 {
2917 break;
2918 }
2919 if (flag2)
2920 {
2921 pt.Y = i;
2922 }
2923 else
2924 {
2925 pt.X = i;
2926 }
2927 bool? flag3 = MassWireOperationStep(user, pt, toolMode, ref wireCount, ref actuatorCount);
2928 if (flag3.HasValue && !flag3.Value)
2929 {
2930 flag = true;
2931 break;
2932 }
2933 }
2934 if (flag2)
2935 {
2936 pt.Y = pe.Y;
2937 num3 = ps.X;
2938 num4 = pe.X;
2939 num5 = num;
2940 }
2941 else
2942 {
2943 pt.X = pe.X;
2944 num3 = ps.Y;
2945 num4 = pe.Y;
2946 num5 = num2;
2947 }
2948 for (int j = num3; j != num4; j += num5)
2949 {
2950 if (flag)
2951 {
2952 break;
2953 }
2954 if (!flag2)
2955 {
2956 pt.Y = j;
2957 }
2958 else
2959 {
2960 pt.X = j;
2961 }
2962 bool? flag4 = MassWireOperationStep(user, pt, toolMode, ref wireCount, ref actuatorCount);
2963 if (flag4.HasValue && !flag4.Value)
2964 {
2965 flag = true;
2966 break;
2967 }
2968 }
2969 if (!flag)
2970 {
2971 MassWireOperationStep(user, pe, toolMode, ref wireCount, ref actuatorCount);
2972 }
2974 Item.DropCache(reason, dropPoint, Vector2.Zero, 530);
2975 Item.DropCache(reason, dropPoint, Vector2.Zero, 849);
2976 }
2977
2979 {
2980 if (!WorldGen.InWorld(pt.X, pt.Y, 1))
2981 {
2982 return null;
2983 }
2984 Tile tile = Main.tile[pt.X, pt.Y];
2985 if (tile == null)
2986 {
2987 return null;
2988 }
2989 if (user != null && !user.CanDoWireStuffHere(pt.X, pt.Y))
2990 {
2991 return null;
2992 }
2993 if (!mode.HasFlag(WiresUI.Settings.MultiToolMode.Cutter))
2994 {
2995 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Red) && !tile.wire())
2996 {
2997 if (wiresLeftToConsume <= 0)
2998 {
2999 return false;
3000 }
3002 WorldGen.PlaceWire(pt.X, pt.Y);
3003 NetMessage.SendData(17, -1, -1, null, 5, pt.X, pt.Y);
3004 }
3005 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Green) && !tile.wire3())
3006 {
3007 if (wiresLeftToConsume <= 0)
3008 {
3009 return false;
3010 }
3012 WorldGen.PlaceWire3(pt.X, pt.Y);
3013 NetMessage.SendData(17, -1, -1, null, 12, pt.X, pt.Y);
3014 }
3015 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Blue) && !tile.wire2())
3016 {
3017 if (wiresLeftToConsume <= 0)
3018 {
3019 return false;
3020 }
3022 WorldGen.PlaceWire2(pt.X, pt.Y);
3023 NetMessage.SendData(17, -1, -1, null, 10, pt.X, pt.Y);
3024 }
3025 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Yellow) && !tile.wire4())
3026 {
3027 if (wiresLeftToConsume <= 0)
3028 {
3029 return false;
3030 }
3032 WorldGen.PlaceWire4(pt.X, pt.Y);
3033 NetMessage.SendData(17, -1, -1, null, 16, pt.X, pt.Y);
3034 }
3035 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Actuator) && !tile.actuator())
3036 {
3037 if (actuatorsLeftToConstume <= 0)
3038 {
3039 return false;
3040 }
3043 NetMessage.SendData(17, -1, -1, null, 8, pt.X, pt.Y);
3044 }
3045 }
3046 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Cutter))
3047 {
3048 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Red) && tile.wire() && WorldGen.KillWire(pt.X, pt.Y))
3049 {
3050 NetMessage.SendData(17, -1, -1, null, 6, pt.X, pt.Y);
3051 }
3052 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Green) && tile.wire3() && WorldGen.KillWire3(pt.X, pt.Y))
3053 {
3054 NetMessage.SendData(17, -1, -1, null, 13, pt.X, pt.Y);
3055 }
3056 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Blue) && tile.wire2() && WorldGen.KillWire2(pt.X, pt.Y))
3057 {
3058 NetMessage.SendData(17, -1, -1, null, 11, pt.X, pt.Y);
3059 }
3060 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Yellow) && tile.wire4() && WorldGen.KillWire4(pt.X, pt.Y))
3061 {
3062 NetMessage.SendData(17, -1, -1, null, 17, pt.X, pt.Y);
3063 }
3064 if (mode.HasFlag(WiresUI.Settings.MultiToolMode.Actuator) && tile.actuator() && WorldGen.KillActuator(pt.X, pt.Y))
3065 {
3066 NetMessage.SendData(17, -1, -1, null, 9, pt.X, pt.Y);
3067 }
3068 }
3069 return true;
3070 }
3071}
static double Sqrt(double d)
static double IEEERemainder(double x, double y)
Definition Math.cs:679
static double Abs(double value)
static int Sign(decimal value)
Definition Math.cs:1202
static void NewTemporaryAnimation(int type, ushort tileType, int x, int y)
Definition Animation.cs:102
static void PlaySound(int type, Vector2 position, int style=1)
static bool SolidTiles(Vector2 position, int width, int height)
Vector2 Center
Definition Entity.cs:43
static Tile GetTileSafely(Vector2 position)
Definition Framing.cs:419
static bool[] TeleportationImmune
Definition NPCID.cs:4168
static bool[] NotReallySolid
Definition TileID.cs:257
static bool[] BasicChest
Definition TileID.cs:223
static bool[] BasicChestFake
Definition TileID.cs:225
static void StartCachingType(int t)
Definition Item.cs:429
int stack
Definition Item.cs:149
static bool MechSpawn(float x, float y, int type)
Definition Item.cs:47948
static void DropCache(IEntitySource reason, Vector2 pos, Vector2 spread, int t, bool stopCaching=true)
Definition Item.cs:437
static int NewItem(IEntitySource source, Vector2 pos, Vector2 randomBox, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
Definition Item.cs:49697
static NetworkText FromLiteral(string text)
static int AnnouncementBoxRange
Definition Main.cs:309
static int maxTilesY
Definition Main.cs:1116
static double worldSurface
Definition Main.cs:1272
static int myPlayer
Definition Main.cs:1801
static int netMode
Definition Main.cs:2095
static void Sundialing()
Definition Main.cs:5730
static int maxTilesX
Definition Main.cs:1114
static bool[] tileSolid
Definition Main.cs:1471
static Tile[,] tile
Definition Main.cs:1675
static int moondialCooldown
Definition Main.cs:2287
static bool fastForwardTimeToDawn
Definition Main.cs:2281
static Projectile[] projectile
Definition Main.cs:1691
static void Moondialing()
Definition Main.cs:5745
static UnifiedRandom rand
Definition Main.cs:1387
static NPC[] npc
Definition Main.cs:1685
static void NewTextMultiline(string text, bool force=false, Microsoft.Xna.Framework.Color c=default(Microsoft.Xna.Framework.Color), int WidthLimit=-1)
Definition Main.cs:61435
static bool AnnouncementBoxDisabled
Definition Main.cs:307
static int sundialCooldown
Definition Main.cs:2283
static Sign[] sign
Definition Main.cs:1701
static Player[] player
Definition Main.cs:1803
static bool fastForwardTimeToDusk
Definition Main.cs:2285
static void FlipSwitchTrack(int i, int j)
Definition Minecart.cs:1288
static bool MechSpawn(float x, float y, int type)
Definition NPC.cs:1561
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
static bool downedPlantBoss
Definition NPC.cs:363
static void SendData(int msgType, int remoteClient=-1, int ignoreClient=-1, NetworkText text=null, int number=0, float number2=0f, float number3=0f, float number4=0f, int number5=0, int number6=0, int number7=0)
Definition NetMessage.cs:88
static void SendTileSquare(int whoAmi, int tileX, int tileY, int xSize, int ySize, TileChangeType changeType=TileChangeType.None)
static void SendTemporaryAnimation(int whoAmi, int animationType, int tileType, int xCoord, int yCoord)
bool ConsumeItem(int type, bool reverseOrder=false, bool includeVoidBag=false)
Definition Player.cs:8514
Item[] inventory
Definition Player.cs:1257
static int NewProjectile(IEntitySource spawnSource, Vector2 position, Vector2 velocity, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)
static void CheckSection(int playerIndex, Vector2 position, int fluff=1)
static int ReadSign(int i, int j, bool CreateIfMissing=true)
Definition Sign.cs:24
bool wire4()
Definition Tile.cs:413
bool wire3()
Definition Tile.cs:633
bool inActive()
Definition Tile.cs:582
short frameY
Definition Tile.cs:24
ushort type
Definition Tile.cs:8
short frameX
Definition Tile.cs:22
bool active()
Definition Tile.cs:565
ushort wall
Definition Tile.cs:10
bool wire2()
Definition Tile.cs:616
bool actuator()
Definition Tile.cs:667
bool wire()
Definition Tile.cs:599
bool halfBrick()
Definition Tile.cs:650
static void PoofOfSmoke(Vector2 position)
Definition Utils.cs:695
static void ToggleCampFire(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2684
static void Toggle2x2Light(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2527
static DoubleStack< byte > _wireDirectionList
Definition Wiring.cs:23
static Queue< Point16 > _LampsToCheck
Definition Wiring.cs:29
static bool Actuate(int i, int j)
Definition Wiring.cs:363
static void ToggleLampPost(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2563
static void ToggleLamp(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2619
static void SkipWire(Point16 point)
Definition Wiring.cs:110
static void Initialize()
Definition Wiring.cs:80
static Dictionary< Point16, bool > _wireSkip
Definition Wiring.cs:19
static Dictionary< Point16, byte > _PixelBoxTriggers
Definition Wiring.cs:35
static void ToggleTorch(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
Definition Wiring.cs:2587
static int[] _inPumpY
Definition Wiring.cs:43
static int[] _inPumpX
Definition Wiring.cs:41
static void HitWire(DoubleStack< Point16 > next, int wireType)
Definition Wiring.cs:811
const int MaxMech
Definition Wiring.cs:53
static void ToggleFirePlace(int i, int j, Tile theBlock, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2714
static void Teleport()
Definition Wiring.cs:2776
static int _numMechs
Definition Wiring.cs:59
static int[] _outPumpX
Definition Wiring.cs:47
static int _numInPump
Definition Wiring.cs:45
static bool TeleporterHitboxIntersects(Rectangle teleporter, Rectangle entity)
Definition Wiring.cs:2841
static void PixelBoxPass()
Definition Wiring.cs:642
static bool CheckMech(int i, int j, int time)
Definition Wiring.cs:429
static void DeActive(int i, int j)
Definition Wiring.cs:2851
static void MassWireOperationInner(Player user, Point ps, Point pe, Vector2 dropPoint, bool dir, ref int wireCount, ref int actuatorCount)
Definition Wiring.cs:2884
static void LogicGatePass()
Definition Wiring.cs:656
static bool running
Definition Wiring.cs:17
static DoubleStack< Point16 > _wireList
Definition Wiring.cs:21
static void ClearAll()
Definition Wiring.cs:115
static int[] _mechX
Definition Wiring.cs:55
const int MaxPump
Definition Wiring.cs:39
static IEntitySource GetProjectileSource(int sourceTileX, int sourceTileY)
Definition Wiring.cs:955
static Queue< Point16 > _GatesCurrent
Definition Wiring.cs:27
static void ToggleCandle(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
Definition Wiring.cs:2604
static void MassWireOperation(Point ps, Point pe, Player master)
Definition Wiring.cs:393
static void PokeLogicGate(int lampX, int lampY)
Definition Wiring.cs:354
static Vector2[] _teleport
Definition Wiring.cs:37
static void ToggleHolidayLight(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
Definition Wiring.cs:2484
static void ActuateForced(int i, int j)
Definition Wiring.cs:381
static void ToggleHangingLantern(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2501
static int[] _mechTime
Definition Wiring.cs:61
static IEntitySource GetItemSource(int sourceTileX, int sourceTileY)
Definition Wiring.cs:965
static void ToggleChandelier(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2647
static void SkipWire(int x, int y)
Definition Wiring.cs:105
static int[] _mechY
Definition Wiring.cs:57
static void CheckLogicGate(int lampX, int lampY)
Definition Wiring.cs:694
static Dictionary< Point16, bool > _GatesDone
Definition Wiring.cs:33
static void SetCurrentUser(int plr=-1)
Definition Wiring.cs:67
static void UpdateMech()
Definition Wiring.cs:135
static Dictionary< Point16, byte > _toProcess
Definition Wiring.cs:25
static int CurrentUser
Definition Wiring.cs:65
static void TripWire(int left, int top, int width, int height)
Definition Wiring.cs:499
static void HitSwitch(int i, int j)
Definition Wiring.cs:237
static void ReActive(int i, int j)
Definition Wiring.cs:2874
static Queue< Point16 > _GatesNext
Definition Wiring.cs:31
static int _numOutPump
Definition Wiring.cs:51
static void XferWater()
Definition Wiring.cs:449
static void GeyserTrap(int i, int j)
Definition Wiring.cs:2744
static int _currentWireColor
Definition Wiring.cs:63
static int[] _outPumpY
Definition Wiring.cs:49
static void HitWireSingle(int i, int j)
Definition Wiring.cs:970
static bool blockPlayerTeleportationForOneIteration
Definition Wiring.cs:15
static ? bool MassWireOperationStep(Player user, Point pt, WiresUI.Settings.MultiToolMode mode, ref int wiresLeftToConsume, ref int actuatorsLeftToConstume)
Definition Wiring.cs:2978
static IEntitySource GetNPCSource(int sourceTileX, int sourceTileY)
Definition Wiring.cs:960
static void SwitchMonolith(int i, int j)
static bool PlaceWire2(int i, int j)
static bool OpenDoor(int i, int j, int direction)
static void SwitchMB(int i, int j)
static void LaunchRocketSmall(int x, int y, bool fromWiring)
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static bool KillWire3(int i, int j)
static bool CloseDoor(int i, int j, bool forced=false)
static bool ShiftTallGate(int x, int y, bool closing, bool forced=false)
static bool CanKillTile(int i, int j, SpecialKillTileContext context)
static bool KillWire4(int i, int j)
static bool PlaceWire3(int i, int j)
static bool ShiftTrapdoor(int x, int y, bool playerAbove, int onlyCloseOrOpen=-1)
static bool KillWire(int i, int j)
static bool PlaceWire4(int i, int j)
static void SwitchFountain(int i, int j)
static void TileFrame(int i, int j, bool resetFrame=false, bool noBreak=false)
static bool KillWire2(int i, int j)
static void LaunchRocket(int x, int y, bool fromWiring)
static bool PlaceWire(int i, int j)
static void ExplodeMine(int i, int j, bool fromWiring)
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816
static void ShootFromCannon(int x, int y, int angle, int ammo, int Damage, float KnockBack, int owner, bool fromWire)
static bool PlaceActuator(int i, int j)
static void SquareTileFrame(int i, int j, bool resetFrame=true)
static bool KillActuator(int i, int j)
static Rectangle Union(Rectangle value1, Rectangle value2)
Definition Rectangle.cs:197