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

◆ TryOpenDoor()

bool Terraria.GameContent.DoorOpeningHelper.CommonDoorOpeningInfoProvider.TryOpenDoor ( DoorOpenCloseTogglingInfo doorInfo,
PlayerInfoForOpeningDoors playerInfo )
inline

Implements Terraria.GameContent.DoorOpeningHelper.DoorAutoHandler.

Definition at line 70 of file DoorOpeningHelper.cs.

71 {
72 Point tileCoordsForToggling = doorInfo.tileCoordsForToggling;
73 int intendedOpeningDirection = playerInfo.intendedOpeningDirection;
74 Rectangle rectangle = new Rectangle(doorInfo.tileCoordsForToggling.X * 16, doorInfo.tileCoordsForToggling.Y * 16, 16, 48);
75 switch (playerInfo.playerGravityDirection)
76 {
77 case 1:
78 rectangle.Height += 16;
79 break;
80 case -1:
81 rectangle.Y -= 16;
82 rectangle.Height += 16;
83 break;
84 }
85 if (!rectangle.Intersects(playerInfo.hitboxToOpenDoor))
86 {
87 return false;
88 }
89 if (playerInfo.hitboxToOpenDoor.Top < rectangle.Top || playerInfo.hitboxToOpenDoor.Bottom > rectangle.Bottom)
90 {
91 return false;
92 }
93 WorldGen.OpenDoor(tileCoordsForToggling.X, tileCoordsForToggling.Y, intendedOpeningDirection);
94 if (Main.tile[tileCoordsForToggling.X, tileCoordsForToggling.Y].type != 10)
95 {
96 NetMessage.SendData(19, -1, -1, null, 0, tileCoordsForToggling.X, tileCoordsForToggling.Y, intendedOpeningDirection);
97 return true;
98 }
99 WorldGen.OpenDoor(tileCoordsForToggling.X, tileCoordsForToggling.Y, -intendedOpeningDirection);
100 if (Main.tile[tileCoordsForToggling.X, tileCoordsForToggling.Y].type != 10)
101 {
102 NetMessage.SendData(19, -1, -1, null, 0, tileCoordsForToggling.X, tileCoordsForToggling.Y, -intendedOpeningDirection);
103 return true;
104 }
105 return false;
106 }

References Terraria.WorldGen.OpenDoor(), Terraria.NetMessage.SendData(), Terraria.Main.tile, Microsoft.Xna.Framework.Point.X, and Microsoft.Xna.Framework.Point.Y.