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

◆ TryCloseDoor()

DoorCloseAttemptResult Terraria.GameContent.DoorOpeningHelper.CommonDoorOpeningInfoProvider.TryCloseDoor ( DoorOpenCloseTogglingInfo info,
PlayerInfoForClosingDoors playerInfo )
inline

Implements Terraria.GameContent.DoorOpeningHelper.DoorAutoHandler.

Definition at line 108 of file DoorOpeningHelper.cs.

109 {
110 Point tileCoordsForToggling = info.tileCoordsForToggling;
111 Tile tile = Main.tile[tileCoordsForToggling.X, tileCoordsForToggling.Y];
112 if (!tile.active() || tile.type != 11)
113 {
114 return DoorCloseAttemptResult.DoorIsInvalidated;
115 }
116 int num = tile.frameX % 72 / 18;
117 Rectangle value = new Rectangle(tileCoordsForToggling.X * 16, tileCoordsForToggling.Y * 16, 16, 48);
118 switch (num)
119 {
120 case 1:
121 value.X -= 16;
122 break;
123 case 2:
124 value.X += 16;
125 break;
126 }
127 value.Inflate(1, 0);
128 Rectangle rectangle = Rectangle.Intersect(value, playerInfo.hitboxToNotCloseDoor);
129 if (rectangle.Width > 0 || rectangle.Height > 0)
130 {
131 return DoorCloseAttemptResult.StillInDoorArea;
132 }
133 if (WorldGen.CloseDoor(tileCoordsForToggling.X, tileCoordsForToggling.Y))
134 {
135 NetMessage.SendData(13, -1, -1, null, Main.myPlayer);
136 NetMessage.SendData(19, -1, -1, null, 1, tileCoordsForToggling.X, tileCoordsForToggling.Y, 1f);
137 return DoorCloseAttemptResult.ClosedDoor;
138 }
139 return DoorCloseAttemptResult.FailedToCloseDoor;
140 }
static Rectangle Intersect(Rectangle value1, Rectangle value2)
Definition Rectangle.cs:143

References Terraria.Tile.active(), Terraria.WorldGen.CloseDoor(), System.info, Microsoft.Xna.Framework.Rectangle.Intersect(), Terraria.Main.myPlayer, Terraria.NetMessage.SendData(), Terraria.Main.tile, Terraria.Tile.type, System.value, Microsoft.Xna.Framework.Point.X, and Microsoft.Xna.Framework.Point.Y.