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

◆ HitWire()

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

Definition at line 811 of file Wiring.cs.

812 {
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 }
860 if (num2 < 2 || num2 >= Main.maxTilesX - 2 || num3 < 2 || num3 >= Main.maxTilesY - 2)
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 }
static DoubleStack< byte > _wireDirectionList
Definition Wiring.cs:23
static Dictionary< Point16, bool > _wireSkip
Definition Wiring.cs:19
static Dictionary< Point16, byte > _PixelBoxTriggers
Definition Wiring.cs:35
static void SkipWire(int x, int y)
Definition Wiring.cs:105
static Dictionary< Point16, byte > _toProcess
Definition Wiring.cs:25
static int _currentWireColor
Definition Wiring.cs:63
static void HitWireSingle(int i, int j)
Definition Wiring.cs:970

References Terraria.Wiring._currentWireColor, Terraria.Wiring._PixelBoxTriggers, Terraria.Wiring._toProcess, Terraria.Wiring._wireDirectionList, Terraria.Wiring._wireSkip, System.Collections.Generic.Dictionary< TKey, TValue >.Count, Terraria.Wiring.HitWireSingle(), System.key, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Wiring.SkipWire(), Terraria.Main.tile, Terraria.Tile.type, System.value, Terraria.Tile.wire(), Terraria.Tile.wire2(), Terraria.Tile.wire3(), and Terraria.Tile.wire4().

Referenced by Terraria.Wiring.TripWire().