private PlayerInfoForClosingDoors GetPlayerInfoForClosingDoor(Player player) { PlayerInfoForClosingDoors result = default(PlayerInfoForClosingDoors); result.hitboxToNotCloseDoor = player.Hitbox; return(result); }
public void LookForDoorsToClose(Player player) { PlayerInfoForClosingDoors playerInfoForClosingDoor = GetPlayerInfoForClosingDoor(player); for (int num = _ongoingOpenDoors.Count - 1; num >= 0; num--) { DoorOpenCloseTogglingInfo info = _ongoingOpenDoors[num]; if (info.handler.TryCloseDoor(info, playerInfoForClosingDoor) != 0) { _ongoingOpenDoors.RemoveAt(num); } } }
public DoorCloseAttemptResult TryCloseDoor(DoorOpenCloseTogglingInfo info, PlayerInfoForClosingDoors playerInfo) { Point tileCoordsForToggling = info.tileCoordsForToggling; Tile tile = Main.tile[tileCoordsForToggling.X, tileCoordsForToggling.Y]; if (!tile.active() || tile.type != 389) { return(DoorCloseAttemptResult.DoorIsInvalidated); } _ = tile.frameY % 90 / 18; Rectangle value = new Rectangle(tileCoordsForToggling.X * 16, tileCoordsForToggling.Y * 16, 16, 80); value.Inflate(1, 0); Rectangle rectangle = Rectangle.Intersect(value, playerInfo.hitboxToNotCloseDoor); if (rectangle.Width > 0 || rectangle.Height > 0) { return(DoorCloseAttemptResult.StillInDoorArea); } bool flag = true; if (WorldGen.ShiftTallGate(tileCoordsForToggling.X, tileCoordsForToggling.Y, flag)) { NetMessage.SendData(13, -1, -1, null, Main.myPlayer); NetMessage.SendData(19, -1, -1, null, 4 + flag.ToInt(), tileCoordsForToggling.X, tileCoordsForToggling.Y); return(DoorCloseAttemptResult.ClosedDoor); } return(DoorCloseAttemptResult.FailedToCloseDoor); }
public DoorCloseAttemptResult TryCloseDoor(DoorOpenCloseTogglingInfo info, PlayerInfoForClosingDoors playerInfo) { Point tileCoordsForToggling = info.tileCoordsForToggling; Tile tile = Main.tile[tileCoordsForToggling.X, tileCoordsForToggling.Y]; if (!tile.active() || tile.type != 11) { return(DoorCloseAttemptResult.DoorIsInvalidated); } int num = tile.frameX % 72 / 18; Rectangle value = new Rectangle(tileCoordsForToggling.X * 16, tileCoordsForToggling.Y * 16, 16, 48); switch (num) { case 1: value.X -= 16; break; case 2: value.X += 16; break; } value.Inflate(1, 0); Rectangle rectangle = Rectangle.Intersect(value, playerInfo.hitboxToNotCloseDoor); if (rectangle.Width > 0 || rectangle.Height > 0) { return(DoorCloseAttemptResult.StillInDoorArea); } if (WorldGen.CloseDoor(tileCoordsForToggling.X, tileCoordsForToggling.Y)) { NetMessage.SendData(13, -1, -1, null, Main.myPlayer); NetMessage.SendData(19, -1, -1, null, 1, tileCoordsForToggling.X, tileCoordsForToggling.Y, 1f); return(DoorCloseAttemptResult.ClosedDoor); } return(DoorCloseAttemptResult.FailedToCloseDoor); }