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

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

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

                if (WorldGen.ShiftTallGate(tileCoordsForToggling.X, tileCoordsForToggling.Y, flag))
                {
                    NetMessage.SendData(19, -1, -1, null, 4 + flag.ToInt(), tileCoordsForToggling.X, tileCoordsForToggling.Y);
                    return(true);
                }
                return(false);
            }
コード例 #3
0
 private void TryAutoOpeningDoor(Point tileCoords, PlayerInfoForOpeningDoors playerInfo)
 {
     if (TryGetHandler(tileCoords, out DoorAutoHandler infoProvider))
     {
         DoorOpenCloseTogglingInfo doorOpenCloseTogglingInfo = infoProvider.ProvideInfo(tileCoords);
         if (infoProvider.TryOpenDoor(doorOpenCloseTogglingInfo, playerInfo))
         {
             _ongoingOpenDoors.Add(doorOpenCloseTogglingInfo);
         }
     }
 }
コード例 #4
0
            public DoorOpenCloseTogglingInfo ProvideInfo(Point tileCoords)
            {
                Tile  tile = Main.tile[tileCoords.X, tileCoords.Y];
                Point tileCoordsForToggling = tileCoords;

                tileCoordsForToggling.Y -= tile.frameY % 54 / 18;
                DoorOpenCloseTogglingInfo result = default(DoorOpenCloseTogglingInfo);

                result.handler = this;
                result.tileCoordsForToggling = tileCoordsForToggling;
                return(result);
            }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
            public bool TryOpenDoor(DoorOpenCloseTogglingInfo doorInfo, PlayerInfoForOpeningDoors playerInfo)
            {
                Point     tileCoordsForToggling    = doorInfo.tileCoordsForToggling;
                int       intendedOpeningDirection = playerInfo.intendedOpeningDirection;
                Rectangle rectangle = new Rectangle(doorInfo.tileCoordsForToggling.X * 16, doorInfo.tileCoordsForToggling.Y * 16, 16, 48);

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

                case -1:
                    rectangle.Y      -= 16;
                    rectangle.Height += 16;
                    break;
                }
                if (!rectangle.Intersects(playerInfo.hitboxToOpenDoor))
                {
                    return(false);
                }
                if (playerInfo.hitboxToOpenDoor.Top < rectangle.Top || playerInfo.hitboxToOpenDoor.Bottom > rectangle.Bottom)
                {
                    return(false);
                }
                WorldGen.OpenDoor(tileCoordsForToggling.X, tileCoordsForToggling.Y, intendedOpeningDirection);
                if (Main.tile[tileCoordsForToggling.X, tileCoordsForToggling.Y].type != 10)
                {
                    NetMessage.SendData(19, -1, -1, null, 0, tileCoordsForToggling.X, tileCoordsForToggling.Y, intendedOpeningDirection);
                    return(true);
                }
                WorldGen.OpenDoor(tileCoordsForToggling.X, tileCoordsForToggling.Y, -intendedOpeningDirection);
                if (Main.tile[tileCoordsForToggling.X, tileCoordsForToggling.Y].type != 10)
                {
                    NetMessage.SendData(19, -1, -1, null, 0, tileCoordsForToggling.X, tileCoordsForToggling.Y, -intendedOpeningDirection);
                    return(true);
                }
                return(false);
            }
コード例 #7
0
            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);
            }