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

◆ ShiftTrapdoor()

static bool Terraria.WorldGen.ShiftTrapdoor ( int x,
int y,
bool playerAbove,
int onlyCloseOrOpen = -1 )
inlinestatic

Definition at line 43017 of file WorldGen.cs.

43018 {
43019 Tile tileSafely = Framing.GetTileSafely(x, y);
43020 if (tileSafely.type == 386 && onlyCloseOrOpen != 1)
43021 {
43022 Point topLeftAndStyles = GetTopLeftAndStyles(ref x, ref y, 2, 2, 18, 18);
43023 if (topLeftAndStyles.X == 0)
43024 {
43025 if (Main.netMode != 1 && Wiring.running)
43026 {
43027 Wiring.SkipWire(x, y);
43028 Wiring.SkipWire(x, y + 1);
43029 Wiring.SkipWire(x + 1, y);
43030 Wiring.SkipWire(x + 1, y + 1);
43031 }
43032 if (!Collision.EmptyTile(x, y + 1, ignoreTiles: true) || !Collision.EmptyTile(x + 1, y + 1, ignoreTiles: true))
43033 {
43034 return false;
43035 }
43036 SoundEngine.PlaySound(8, x * 16 + 16, y * 16 + 16);
43037 for (int i = 0; i < 2; i++)
43038 {
43039 tileSafely = Framing.GetTileSafely(x + i, y);
43040 tileSafely.ClearTile();
43041 }
43042 for (int j = 0; j < 2; j++)
43043 {
43044 tileSafely = Framing.GetTileSafely(x + j, y + 1);
43045 tileSafely.type = 387;
43046 tileSafely.frameX = (short)(j * 18);
43047 tileSafely.frameY = (short)(topLeftAndStyles.Y * 18);
43048 }
43049 for (int k = -1; k < 3; k++)
43050 {
43051 for (int l = 0; l < 3; l++)
43052 {
43053 TileFrame(x + k, y + l);
43054 }
43055 }
43056 return true;
43057 }
43058 if (topLeftAndStyles.X == 1)
43059 {
43060 if (Main.netMode != 1 && Wiring.running)
43061 {
43062 Wiring.SkipWire(x, y - 1);
43063 Wiring.SkipWire(x, y);
43064 Wiring.SkipWire(x + 1, y - 1);
43065 Wiring.SkipWire(x + 1, y);
43066 }
43067 if (!Collision.EmptyTile(x, y, ignoreTiles: true) || !Collision.EmptyTile(x + 1, y, ignoreTiles: true))
43068 {
43069 return false;
43070 }
43071 SoundEngine.PlaySound(8, x * 16 + 16, y * 16);
43072 for (int m = 0; m < 2; m++)
43073 {
43074 tileSafely = Framing.GetTileSafely(x + m, y + 1);
43075 tileSafely.ClearTile();
43076 }
43077 for (int n = 0; n < 2; n++)
43078 {
43079 tileSafely = Framing.GetTileSafely(x + n, y);
43080 tileSafely.type = 387;
43081 tileSafely.frameX = (short)(n * 18);
43082 tileSafely.frameY = (short)(topLeftAndStyles.Y * 18);
43083 }
43084 for (int num = -1; num < 3; num++)
43085 {
43086 for (int num2 = -1; num2 < 2; num2++)
43087 {
43088 TileFrame(x + num, y + num2);
43089 }
43090 }
43091 return true;
43092 }
43093 }
43094 if (tileSafely.type == 387 && onlyCloseOrOpen != 0)
43095 {
43096 GetTopLeftAndStyles(ref x, ref y, 2, 1, 18, 18);
43097 int num3 = playerAbove.ToDirectionInt();
43098 for (int num4 = 0; num4 < 2; num4++)
43099 {
43100 tileSafely = Framing.GetTileSafely(x + num4, y + num3);
43101 if (tileSafely.active() && !Main.tileCut[tileSafely.type])
43102 {
43103 return false;
43104 }
43105 }
43106 if (Main.netMode != 1 && Wiring.running)
43107 {
43108 Wiring.SkipWire(x, y);
43109 Wiring.SkipWire(x, y + num3);
43110 Wiring.SkipWire(x + 1, y);
43111 Wiring.SkipWire(x + 1, y + num3);
43112 }
43113 SoundEngine.PlaySound(8, x * 16 + 16, y * 16);
43114 for (int num5 = 0; num5 < 2; num5++)
43115 {
43116 tileSafely = Framing.GetTileSafely(x + num5, y + num3);
43117 if (tileSafely.active() && Main.tileCut[tileSafely.type])
43118 {
43119 KillTile(x + num5, y + num3);
43120 }
43121 }
43122 for (int num6 = 0; num6 < 2; num6++)
43123 {
43124 tileSafely = Framing.GetTileSafely(x + num6, y);
43125 TileColorCache cache = tileSafely.BlockColorAndCoating();
43126 for (int num7 = 0; num7 < 2; num7++)
43127 {
43128 tileSafely = Framing.GetTileSafely(x + num6, y + num7 - (!playerAbove).ToInt());
43129 tileSafely.type = 386;
43130 tileSafely.frameX = (short)(num6 * 18 + playerAbove.ToInt() * 36);
43131 tileSafely.frameY = (short)(num7 * 18);
43132 tileSafely.UseBlockColors(cache);
43133 tileSafely.active(active: true);
43134 }
43135 }
43136 for (int num8 = -1; num8 < 3; num8++)
43137 {
43138 for (int num9 = -1; num9 < 3; num9++)
43139 {
43140 TileFrame(x + num8, y + num9 - (!playerAbove).ToInt() * 2);
43141 }
43142 }
43143 return true;
43144 }
43145 SoundEngine.PlaySound(9, x * 16, y * 16);
43146 return false;
43147 }
static void PlaySound(int type, Vector2 position, int style=1)
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static void TileFrame(int i, int j, bool resetFrame=false, bool noBreak=false)
static Point GetTopLeftAndStyles(ref int x, ref int y, int w, int h, int frameXinc, int frameYinc)

References Terraria.Collision.EmptyTile(), Terraria.Framing.GetTileSafely(), Terraria.Main.netMode, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Wiring.running, Terraria.Wiring.SkipWire(), and Terraria.Main.tileCut.

Referenced by Terraria.MessageBuffer.GetData(), Terraria.Wiring.HitWireSingle(), and Terraria.Player.TileInteractionsUse().