Exemple #1
0
            public DoorOpeningHelper.DoorCloseAttemptResult TryCloseDoor(
                DoorOpeningHelper.DoorOpenCloseTogglingInfo info,
                DoorOpeningHelper.PlayerInfoForClosingDoors playerInfo)
            {
                Point coordsForToggling = info.tileCoordsForToggling;
                Tile  tile = Main.tile[coordsForToggling.X, coordsForToggling.Y];

                if (!tile.active() || tile.type != (ushort)389)
                {
                    return(DoorOpeningHelper.DoorCloseAttemptResult.DoorIsInvalidated);
                }
                int       num        = (int)tile.frameY % 90 / 18;
                Rectangle rectangle1 = new Rectangle(coordsForToggling.X * 16, coordsForToggling.Y * 16, 16, 80);

                rectangle1.Inflate(1, 0);
                Rectangle rectangle2 = Rectangle.Intersect(rectangle1, playerInfo.hitboxToNotCloseDoor);

                if (rectangle2.Width > 0 || rectangle2.Height > 0)
                {
                    return(DoorOpeningHelper.DoorCloseAttemptResult.StillInDoorArea);
                }
                bool closing = true;

                if (!WorldGen.ShiftTallGate(coordsForToggling.X, coordsForToggling.Y, closing, false))
                {
                    return(DoorOpeningHelper.DoorCloseAttemptResult.FailedToCloseDoor);
                }
                NetMessage.SendData(13, -1, -1, (NetworkText)null, Main.myPlayer, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                NetMessage.SendData(19, -1, -1, (NetworkText)null, 4 + closing.ToInt(), (float)coordsForToggling.X, (float)coordsForToggling.Y, 0.0f, 0, 0, 0);
                return(DoorOpeningHelper.DoorCloseAttemptResult.ClosedDoor);
            }
Exemple #2
0
 public void LookForDoorsToClose(Player player)
 {
     DoorOpeningHelper.PlayerInfoForClosingDoors infoForClosingDoor = this.GetPlayerInfoForClosingDoor(player);
     for (int index = this._ongoingOpenDoors.Count - 1; index >= 0; --index)
     {
         DoorOpeningHelper.DoorOpenCloseTogglingInfo ongoingOpenDoor = this._ongoingOpenDoors[index];
         if (ongoingOpenDoor.handler.TryCloseDoor(ongoingOpenDoor, infoForClosingDoor) != DoorOpeningHelper.DoorCloseAttemptResult.StillInDoorArea)
         {
             this._ongoingOpenDoors.RemoveAt(index);
         }
     }
 }
Exemple #3
0
            public DoorOpeningHelper.DoorCloseAttemptResult TryCloseDoor(
                DoorOpeningHelper.DoorOpenCloseTogglingInfo info,
                DoorOpeningHelper.PlayerInfoForClosingDoors playerInfo)
            {
                Point coordsForToggling = info.tileCoordsForToggling;
                Tile  tile = Main.tile[coordsForToggling.X, coordsForToggling.Y];

                if (!tile.active() || tile.type != (ushort)11)
                {
                    return(DoorOpeningHelper.DoorCloseAttemptResult.DoorIsInvalidated);
                }
                int       num        = (int)tile.frameX % 72 / 18;
                Rectangle rectangle1 = new Rectangle(coordsForToggling.X * 16, coordsForToggling.Y * 16, 16, 48);

                switch (num)
                {
                case 1:
                    rectangle1.X -= 16;
                    break;

                case 2:
                    rectangle1.X += 16;
                    break;
                }
                rectangle1.Inflate(1, 0);
                Rectangle rectangle2 = Rectangle.Intersect(rectangle1, playerInfo.hitboxToNotCloseDoor);

                if (rectangle2.Width > 0 || rectangle2.Height > 0)
                {
                    return(DoorOpeningHelper.DoorCloseAttemptResult.StillInDoorArea);
                }
                if (!WorldGen.CloseDoor(coordsForToggling.X, coordsForToggling.Y, false))
                {
                    return(DoorOpeningHelper.DoorCloseAttemptResult.FailedToCloseDoor);
                }
                NetMessage.SendData(13, -1, -1, (NetworkText)null, Main.myPlayer, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                NetMessage.SendData(19, -1, -1, (NetworkText)null, 1, (float)coordsForToggling.X, (float)coordsForToggling.Y, 1f, 0, 0, 0);
                return(DoorOpeningHelper.DoorCloseAttemptResult.ClosedDoor);
            }