示例#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);
            }
示例#2
0
            public bool TryOpenDoor(
                DoorOpeningHelper.DoorOpenCloseTogglingInfo doorInfo,
                DoorOpeningHelper.PlayerInfoForOpeningDoors playerInfo)
            {
                Point     coordsForToggling = doorInfo.tileCoordsForToggling;
                Rectangle rectangle         = new Rectangle(doorInfo.tileCoordsForToggling.X * 16, doorInfo.tileCoordsForToggling.Y * 16, 16, 80);

                switch (playerInfo.playerGravityDirection)
                {
                case -1:
                    rectangle.Y      -= 16;
                    rectangle.Height += 16;
                    break;

                case 1:
                    rectangle.Height += 16;
                    break;
                }
                if (!rectangle.Intersects(playerInfo.hitboxToOpenDoor) || playerInfo.hitboxToOpenDoor.Top < rectangle.Top || playerInfo.hitboxToOpenDoor.Bottom > rectangle.Bottom)
                {
                    return(false);
                }
                bool closing = false;

                if (!WorldGen.ShiftTallGate(coordsForToggling.X, coordsForToggling.Y, closing, false))
                {
                    return(false);
                }
                NetMessage.SendData(19, -1, -1, (NetworkText)null, 4 + closing.ToInt(), (float)coordsForToggling.X, (float)coordsForToggling.Y, 0.0f, 0, 0, 0);
                return(true);
            }
示例#3
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);
         }
     }
 }
示例#4
0
 private void TryAutoOpeningDoor(
     Point tileCoords,
     DoorOpeningHelper.PlayerInfoForOpeningDoors playerInfo)
 {
     DoorOpeningHelper.DoorAutoHandler infoProvider;
     if (!this.TryGetHandler(tileCoords, out infoProvider))
     {
         return;
     }
     DoorOpeningHelper.DoorOpenCloseTogglingInfo info = infoProvider.ProvideInfo(tileCoords);
     if (!infoProvider.TryOpenDoor(info, playerInfo))
     {
         return;
     }
     this._ongoingOpenDoors.Add(info);
 }
示例#5
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);
            }
示例#6
0
            public bool TryOpenDoor(
                DoorOpeningHelper.DoorOpenCloseTogglingInfo doorInfo,
                DoorOpeningHelper.PlayerInfoForOpeningDoors playerInfo)
            {
                Point     coordsForToggling = doorInfo.tileCoordsForToggling;
                int       openingDirection  = playerInfo.intendedOpeningDirection;
                Rectangle rectangle         = new Rectangle(doorInfo.tileCoordsForToggling.X * 16, doorInfo.tileCoordsForToggling.Y * 16, 16, 48);

                switch (playerInfo.playerGravityDirection)
                {
                case -1:
                    rectangle.Y      -= 16;
                    rectangle.Height += 16;
                    break;

                case 1:
                    rectangle.Height += 16;
                    break;
                }
                if (!rectangle.Intersects(playerInfo.hitboxToOpenDoor) || playerInfo.hitboxToOpenDoor.Top < rectangle.Top || playerInfo.hitboxToOpenDoor.Bottom > rectangle.Bottom)
                {
                    return(false);
                }
                WorldGen.OpenDoor(coordsForToggling.X, coordsForToggling.Y, openingDirection);
                if (Main.tile[coordsForToggling.X, coordsForToggling.Y].type != (ushort)10)
                {
                    NetMessage.SendData(19, -1, -1, (NetworkText)null, 0, (float)coordsForToggling.X, (float)coordsForToggling.Y, (float)openingDirection, 0, 0, 0);
                    return(true);
                }
                WorldGen.OpenDoor(coordsForToggling.X, coordsForToggling.Y, -openingDirection);
                if (Main.tile[coordsForToggling.X, coordsForToggling.Y].type == (ushort)10)
                {
                    return(false);
                }
                NetMessage.SendData(19, -1, -1, (NetworkText)null, 0, (float)coordsForToggling.X, (float)coordsForToggling.Y, (float)-openingDirection, 0, 0, 0);
                return(true);
            }