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

◆ CloseDoor()

static bool Terraria.WorldGen.CloseDoor ( int i,
int j,
bool forced = false )
inlinestatic

Definition at line 24830 of file WorldGen.cs.

24831 {
24832 int num = 0;
24833 int num2 = i;
24834 int num3 = j;
24835 if (Main.tile[i, j] == null)
24836 {
24837 Main.tile[i, j] = default(Tile);
24838 }
24839 int frameX = Main.tile[i, j].frameX;
24840 Tile tile = Main.tile[i, j];
24841 if (TileLoader.CloseDoorID(Main.tile[i, j]) < 0)
24842 {
24843 return false;
24844 }
24845 int num4 = tile.frameY;
24846 int num5 = 0;
24847 int num6 = 0;
24848 while (num4 >= 54)
24849 {
24850 num4 -= 54;
24851 num5++;
24852 }
24853 if (frameX >= 72)
24854 {
24855 num5 += 36 * (frameX / 72);
24856 num6 += 54 * (frameX / 72);
24857 }
24858 num3 = j - num4 / 18;
24859 switch (frameX % 72)
24860 {
24861 case 0:
24862 num2 = i;
24863 num = 1;
24864 break;
24865 case 18:
24866 num2 = i - 1;
24867 num = 1;
24868 break;
24869 case 36:
24870 num2 = i + 1;
24871 num = -1;
24872 break;
24873 case 54:
24874 num2 = i;
24875 num = -1;
24876 break;
24877 }
24878 int num7 = num2;
24879 if (num == -1)
24880 {
24881 num7 = num2 - 1;
24882 }
24883 if (!forced)
24884 {
24885 for (int k = num3; k < num3 + 3; k++)
24886 {
24887 if (!Collision.EmptyTile(num2, k, ignoreTiles: true))
24888 {
24889 return false;
24890 }
24891 }
24892 }
24893 ushort closeDoorID = (ushort)TileLoader.CloseDoorID(tile);
24894 for (int l = num7; l < num7 + 2; l++)
24895 {
24896 for (int m = num3; m < num3 + 3; m++)
24897 {
24898 if (l == num2)
24899 {
24900 if (Main.tile[l, m] == null)
24901 {
24902 Main.tile[l, m] = default(Tile);
24903 }
24904 Main.tile[l, m].type = closeDoorID;
24905 Main.tile[l, m].frameX = (short)(genRand.Next(3) * 18 + num6);
24906 }
24907 else
24908 {
24909 if (Main.tile[l, m] == null)
24910 {
24911 Main.tile[l, m] = default(Tile);
24912 }
24913 Main.tile[l, m].active(active: false);
24914 }
24915 }
24916 }
24917 if (Main.netMode != 1 && Wiring.running)
24918 {
24919 Wiring.SkipWire(num2, num3);
24920 Wiring.SkipWire(num2, num3 + 1);
24921 Wiring.SkipWire(num2, num3 + 2);
24922 }
24923 for (int n = num2 - 1; n <= num2 + 1; n++)
24924 {
24925 for (int num8 = num3 - 1; num8 <= num3 + 2; num8++)
24926 {
24927 TileFrame(n, num8);
24928 }
24929 }
24930 SoundEngine.PlaySound(9, i * 16, j * 16);
24931 return true;
24932 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
static int CloseDoorID(Tile tile)
This serves as the central class from which tile-related functions are supported and carried out.
Definition TileLoader.cs:23
static UnifiedRandom genRand
Definition WorldGen.cs:1455
static void TileFrame(int i, int j, bool resetFrame=false, bool noBreak=false)

References Terraria.ModLoader.TileLoader.CloseDoorID(), Terraria.Collision.EmptyTile(), Terraria.Tile.frameY, Terraria.Main.netMode, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Wiring.running, Terraria.Wiring.SkipWire(), and Terraria.Main.tile.

Referenced by Terraria.NPC.AI_007_TownEntities(), Terraria.MessageBuffer.GetData(), Terraria.Wiring.HitWireSingle(), Terraria.Player.TileInteractionsUse(), and Terraria.GameContent.DoorOpeningHelper.CommonDoorOpeningInfoProvider.TryCloseDoor().

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