TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ HitWire()

static void Terraria.Wiring.HitWire ( DoubleStack< Point16 > next,
int wireType )
inlinestaticprivate

Definition at line 947 of file Wiring.cs.

948 {
950 for (int i = 0; i < next.Count; i++)
951 {
952 Point16 point = next.PopFront();
953 SkipWire(point);
954 _toProcess.Add(point, 4);
955 next.PushBack(point);
956 _wireDirectionList.PushBack(0);
957 }
959 while (next.Count > 0)
960 {
961 Point16 key = next.PopFront();
962 int num = _wireDirectionList.PopFront();
963 int x = key.X;
964 int y = key.Y;
965 if (!_wireSkip.ContainsKey(key))
966 {
967 HitWireSingle(x, y);
968 }
969 for (int j = 0; j < 4; j++)
970 {
971 int num2;
972 int num3;
973 switch (j)
974 {
975 case 0:
976 num2 = x;
977 num3 = y + 1;
978 break;
979 case 1:
980 num2 = x;
981 num3 = y - 1;
982 break;
983 case 2:
984 num2 = x + 1;
985 num3 = y;
986 break;
987 case 3:
988 num2 = x - 1;
989 num3 = y;
990 break;
991 default:
992 num2 = x;
993 num3 = y + 1;
994 break;
995 }
996 if (num2 < 2 || num2 >= Main.maxTilesX - 2 || num3 < 2 || num3 >= Main.maxTilesY - 2)
997 {
998 continue;
999 }
1000 Tile tile = Main.tile[num2, num3];
1001 if (tile == null)
1002 {
1003 continue;
1004 }
1005 Tile tile2 = Main.tile[x, y];
1006 if (tile2 == null)
1007 {
1008 continue;
1009 }
1010 byte b = 3;
1011 if (tile.type == 424 || tile.type == 445)
1012 {
1013 b = 0;
1014 }
1015 if (tile2.type == 424)
1016 {
1017 switch (tile2.frameX / 18)
1018 {
1019 case 0:
1020 if (j != num)
1021 {
1022 continue;
1023 }
1024 break;
1025 case 1:
1026 if ((num != 0 || j != 3) && (num != 3 || j != 0) && (num != 1 || j != 2) && (num != 2 || j != 1))
1027 {
1028 continue;
1029 }
1030 break;
1031 case 2:
1032 if ((num != 0 || j != 2) && (num != 2 || j != 0) && (num != 1 || j != 3) && (num != 3 || j != 1))
1033 {
1034 continue;
1035 }
1036 break;
1037 }
1038 }
1039 if (tile2.type == 445)
1040 {
1041 if (j != num)
1042 {
1043 continue;
1044 }
1045 if (_PixelBoxTriggers.ContainsKey(key))
1046 {
1047 _PixelBoxTriggers[key] |= (byte)((j != 0 && j != 1) ? 1 : 2);
1048 }
1049 else
1050 {
1051 _PixelBoxTriggers[key] = (byte)((j != 0 && j != 1) ? 1u : 2u);
1052 }
1053 }
1054 if (wireType switch
1055 {
1056 1 => tile.wire() ? 1 : 0,
1057 2 => tile.wire2() ? 1 : 0,
1058 3 => tile.wire3() ? 1 : 0,
1059 4 => tile.wire4() ? 1 : 0,
1060 _ => 0,
1061 } == 0)
1062 {
1063 continue;
1064 }
1065 Point16 point2 = new Point16(num2, num3);
1066 if (_toProcess.TryGetValue(point2, out var value))
1067 {
1068 value--;
1069 if (value == 0)
1070 {
1071 _toProcess.Remove(point2);
1072 }
1073 else
1074 {
1075 _toProcess[point2] = value;
1076 }
1077 continue;
1078 }
1079 next.PushBack(point2);
1080 _wireDirectionList.PushBack((byte)j);
1081 if (b > 0)
1082 {
1083 _toProcess.Add(point2, b);
1084 }
1085 }
1086 }
1087 _wireSkip.Clear();
1088 _toProcess.Clear();
1089 }
static DoubleStack< byte > _wireDirectionList
Definition Wiring.cs:28
static Dictionary< Point16, bool > _wireSkip
Definition Wiring.cs:24
static Dictionary< Point16, byte > _PixelBoxTriggers
Definition Wiring.cs:40
static void SkipWire(int x, int y)
Use to prevent wire signals from running for the provided coordinates. Typically used in multi-tiles ...
Definition Wiring.cs:121
static Dictionary< Point16, byte > _toProcess
Definition Wiring.cs:30
static int _currentWireColor
Definition Wiring.cs:68
static void HitWireSingle(int i, int j)
Definition Wiring.cs:1106

References Terraria.Wiring._currentWireColor, Terraria.Wiring._PixelBoxTriggers, Terraria.Wiring._toProcess, Terraria.Wiring._wireDirectionList, Terraria.Wiring._wireSkip, Terraria.Wiring.HitWireSingle(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Wiring.SkipWire(), Terraria.Main.tile, Terraria.Tile.type, Terraria.Tile.wire(), Terraria.Tile.wire2(), Terraria.Tile.wire3(), Terraria.Tile.wire4(), Terraria.DataStructures.Point16.X, and Terraria.DataStructures.Point16.Y.

Referenced by Terraria.Wiring.TripWire().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: