private void GeneratePitfallRoom() { m_createdRoom = ChaosUtility.Instance.AddCustomRuntimeRoom(targetPitFallRoom, true, false, true); GameObject ArrivalObject = GameObject.Find("Arrival(Clone)"); if (ArrivalObject != null) { ArrivalObject.name = "Arrival"; } if (targetRoomIsSpecialElevator) { ElevatorDepartureController targetElevator = null; if (FindObjectsOfType <ElevatorDepartureController>() != null) { foreach (ElevatorDepartureController elevator in FindObjectsOfType <ElevatorDepartureController>()) { if (elevator.gameObject.transform.position.GetAbsoluteRoom().GetRoomName().StartsWith(targetPitFallRoom.name)) { targetElevator = elevator; } } } if (targetElevator != null) { targetElevator.gameObject.AddComponent <ChaosElevatorDepartureManager>(); ChaosElevatorDepartureManager chaosElevatorComponent = targetElevator.gameObject.GetComponent <ChaosElevatorDepartureManager>(); chaosElevatorComponent.UsesOverrideTargetFloor = true; chaosElevatorComponent.OverrideTargetFloor = GlobalDungeonData.ValidTilesets.PHOBOSGEON; if (chaosElevatorComponent.gameObject.GetComponentsInChildren <tk2dBaseSprite>(true) != null) { foreach (tk2dBaseSprite baseSprite in chaosElevatorComponent.gameObject.GetComponentsInChildren <tk2dBaseSprite>()) { ChaosShaders.Instance.ApplyGlitchShader(null, baseSprite); } } /*targetElevator.UsesOverrideTargetFloor = true; * targetElevator.OverrideTargetFloor = GlobalDungeonData.ValidTilesets.PHOBOSGEON; * if (targetElevator.gameObject.GetComponentsInChildren<tk2dBaseSprite>(true) != null) { * foreach (tk2dBaseSprite baseSprite in targetElevator.gameObject.GetComponentsInChildren<tk2dBaseSprite>()) { * ChaosShaders.Instance.ApplyGlitchShader(null, baseSprite); * } * }*/ } } }
private void PlaceGlitchElevator(Dungeon dungeon) { GameManager.LevelOverrideState levelOverrideState = GameManager.Instance.CurrentLevelOverrideState; if (dungeon.IsGlitchDungeon | ChaosGlitchMod.isGlitchFloor | ChaosDungeonFlows.isGlitchFlow | ChaosConsole.elevatorHasBeenUsed) { return; } if (levelOverrideState == GameManager.LevelOverrideState.FOYER | levelOverrideState == GameManager.LevelOverrideState.TUTORIAL) { return; } if (levelOverrideState == GameManager.LevelOverrideState.CHARACTER_PAST | levelOverrideState == GameManager.LevelOverrideState.RESOURCEFUL_RAT) { return; } if (levelOverrideState == GameManager.LevelOverrideState.END_TIMES) { return; } if (GameManager.Instance.CurrentFloor >= 6) { return; } if (UnityEngine.Random.value > 0.1f) { return; } int MaxNumberOfElevators = 1; int ElevatorsPlaced = 0; int ElevatorLocations = 0; int SelectedRoom = 0; List <int> roomList = Enumerable.Range(0, dungeon.data.rooms.Count).ToList(); roomList = roomList.Shuffle(); List <IntVector2> validWalls = new List <IntVector2>(); while (SelectedRoom < roomList.Count && ElevatorsPlaced < MaxNumberOfElevators) { RoomHandler currentRoom = dungeon.data.rooms[roomList[SelectedRoom]]; if (!currentRoom.IsShop && !currentRoom.IsMaintenanceRoom() && !currentRoom.GetRoomName().ToLower().StartsWith("exit") && !currentRoom.GetRoomName().ToLower().StartsWith("tiny_exit") && !currentRoom.GetRoomName().ToLower().StartsWith("elevator") && !currentRoom.GetRoomName().ToLower().StartsWith("tiny_entrance") && !currentRoom.GetRoomName().ToLower().StartsWith("gungeon entrance") && !currentRoom.GetRoomName().ToLower().StartsWith("gungeon_rewardroom") && !currentRoom.GetRoomName().ToLower().StartsWith("reward room")) { if (!currentRoom.area.IsProceduralRoom || currentRoom.area.proceduralCells == null) { if (currentRoom.area.PrototypeRoomCategory != PrototypeDungeonRoom.RoomCategory.BOSS || (PlayerStats.GetTotalCurse() >= 5 && !BraveUtility.RandomBool())) { if (!currentRoom.GetRoomName().StartsWith("DraGunRoom")) { if (currentRoom.connectedRooms != null) { for (int i = 0; i < currentRoom.connectedRooms.Count; i++) { if (currentRoom.connectedRooms[i] == null || currentRoom.connectedRooms[i].area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS) { } } } validWalls.Clear(); for (int Width = -1; Width <= currentRoom.area.dimensions.x; Width++) { for (int Height = -1; Height <= currentRoom.area.dimensions.y; Height++) { int X = currentRoom.area.basePosition.x + Width; int Y = currentRoom.area.basePosition.y + Height; if (dungeon.data.isWall(X, Y)) { int WallCellCount = 0; if (!dungeon.data.isPlainEmptyCell(X - 3, Y + 6) && !dungeon.data.isPlainEmptyCell(X - 2, Y + 6) && !dungeon.data.isPlainEmptyCell(X - 1, Y + 6) && !dungeon.data.isPlainEmptyCell(X, Y + 6) && !dungeon.data.isPlainEmptyCell(X + 1, Y + 6) && !dungeon.data.isPlainEmptyCell(X + 2, Y + 6) && !dungeon.data.isPlainEmptyCell(X + 3, Y + 6) && !dungeon.data.isPlainEmptyCell(X + 4, Y + 6) && !dungeon.data.isPlainEmptyCell(X + 5, Y + 6) && !dungeon.data.isPlainEmptyCell(X - 3, Y + 5) && !dungeon.data.isPlainEmptyCell(X - 2, Y + 5) && !dungeon.data.isPlainEmptyCell(X - 1, Y + 5) && !dungeon.data.isPlainEmptyCell(X, Y + 5) && !dungeon.data.isPlainEmptyCell(X + 1, Y + 5) && !dungeon.data.isPlainEmptyCell(X + 2, Y + 5) && !dungeon.data.isPlainEmptyCell(X + 3, Y + 5) && !dungeon.data.isPlainEmptyCell(X + 4, Y + 5) && !dungeon.data.isPlainEmptyCell(X + 5, Y + 5) && !dungeon.data.isPlainEmptyCell(X - 3, Y + 4) && !dungeon.data.isPlainEmptyCell(X - 2, Y + 4) && !dungeon.data.isPlainEmptyCell(X - 1, Y + 4) && !dungeon.data.isPlainEmptyCell(X, Y + 4) && !dungeon.data.isPlainEmptyCell(X + 1, Y + 4) && !dungeon.data.isPlainEmptyCell(X + 2, Y + 4) && !dungeon.data.isPlainEmptyCell(X + 3, Y + 4) && !dungeon.data.isPlainEmptyCell(X + 4, Y + 4) && !dungeon.data.isPlainEmptyCell(X + 5, Y + 4) && !dungeon.data.isPlainEmptyCell(X - 3, Y + 3) && !dungeon.data.isPlainEmptyCell(X - 2, Y + 3) && !dungeon.data.isPlainEmptyCell(X - 1, Y + 3) && !dungeon.data.isPlainEmptyCell(X, Y + 3) && !dungeon.data.isPlainEmptyCell(X + 1, Y + 3) && !dungeon.data.isPlainEmptyCell(X + 2, Y + 3) && !dungeon.data.isPlainEmptyCell(X + 3, Y + 3) && !dungeon.data.isPlainEmptyCell(X + 4, Y + 3) && !dungeon.data.isPlainEmptyCell(X + 5, Y + 3) && !dungeon.data.isPlainEmptyCell(X - 3, Y + 2) && !dungeon.data.isPlainEmptyCell(X - 2, Y + 2) && !dungeon.data.isPlainEmptyCell(X - 1, Y + 2) && !dungeon.data.isPlainEmptyCell(X, Y + 2) && !dungeon.data.isPlainEmptyCell(X + 1, Y + 2) && !dungeon.data.isPlainEmptyCell(X + 2, Y + 2) && !dungeon.data.isPlainEmptyCell(X + 3, Y + 2) && !dungeon.data.isPlainEmptyCell(X + 4, Y + 2) && !dungeon.data.isPlainEmptyCell(X + 5, Y + 2) && !dungeon.data.isPlainEmptyCell(X - 4, Y + 1) && dungeon.data.isWall(X - 3, Y + 1) && dungeon.data.isWall(X - 2, Y + 1) && dungeon.data.isWall(X - 1, Y + 1) && dungeon.data.isWall(X, Y + 1) && dungeon.data.isWall(X + 1, Y + 1) && dungeon.data.isWall(X + 2, Y + 1) && dungeon.data.isWall(X + 3, Y + 1) && dungeon.data.isWall(X + 4, Y + 1) && dungeon.data.isWall(X + 5, Y + 1) && dungeon.data.isWall(X + 6, Y + 1) && dungeon.data.isWall(X + 7, Y + 1) && !dungeon.data.isPlainEmptyCell(X + 8, Y + 1) && !dungeon.data.isPlainEmptyCell(X + 9, Y + 1) && !dungeon.data.isPlainEmptyCell(X - 4, Y) && dungeon.data.isWall(X - 3, Y) && dungeon.data.isWall(X - 2, Y) && dungeon.data.isWall(X - 1, Y) && dungeon.data.isWall(X, Y) && dungeon.data.isWall(X + 1, Y) && dungeon.data.isWall(X + 2, Y) && dungeon.data.isWall(X + 3, Y) && dungeon.data.isWall(X + 4, Y) && dungeon.data.isWall(X + 5, Y) && dungeon.data.isWall(X + 6, Y) && dungeon.data.isWall(X + 7, Y) && !dungeon.data.isPlainEmptyCell(X + 8, Y) && !dungeon.data.isPlainEmptyCell(X + 9, Y) && dungeon.data.isPlainEmptyCell(X - 3, Y - 1) && dungeon.data.isPlainEmptyCell(X - 2, Y - 1) && dungeon.data.isPlainEmptyCell(X - 1, Y - 1) && dungeon.data.isPlainEmptyCell(X, Y - 1) && dungeon.data.isPlainEmptyCell(X + 1, Y - 1) && dungeon.data.isPlainEmptyCell(X + 2, Y - 1) && dungeon.data.isPlainEmptyCell(X + 3, Y - 1) && dungeon.data.isPlainEmptyCell(X + 4, Y - 1) && dungeon.data.isPlainEmptyCell(X + 5, Y - 1) && dungeon.data.isPlainEmptyCell(X + 6, Y - 1) && dungeon.data.isPlainEmptyCell(X + 7, Y - 1) && dungeon.data.isPlainEmptyCell(X - 3, Y - 2) && dungeon.data.isPlainEmptyCell(X - 2, Y - 2) && dungeon.data.isPlainEmptyCell(X - 1, Y - 2) && dungeon.data.isPlainEmptyCell(X, Y - 2) && dungeon.data.isPlainEmptyCell(X + 1, Y - 2) && dungeon.data.isPlainEmptyCell(X + 2, Y - 2) && dungeon.data.isPlainEmptyCell(X + 3, Y - 2) && dungeon.data.isPlainEmptyCell(X + 4, Y - 2) && dungeon.data.isPlainEmptyCell(X + 5, Y - 2) && dungeon.data.isPlainEmptyCell(X + 6, Y - 2) && dungeon.data.isPlainEmptyCell(X + 7, Y - 2)) { validWalls.Add(new IntVector2(X, Y)); WallCellCount++; ElevatorLocations++; } if (WallCellCount > 0) { bool flag2 = true; int XPadding = -5; while (XPadding <= 5 && flag2) { int YPadding = -5; while (YPadding <= 5 && flag2) { int x = X + XPadding; int y = Y + YPadding; if (dungeon.data.CheckInBoundsAndValid(x, y)) { CellData cellData = dungeon.data[x, y]; if (cellData != null) { if (cellData.type == CellType.PIT || cellData.diagonalWallType != DiagonalWallType.NONE) { flag2 = false; } } } YPadding++; } XPadding++; } if (!flag2) { while (WallCellCount > 0) { validWalls.RemoveAt(validWalls.Count - 1); WallCellCount--; } } } } } } if (validWalls.Count > 0) { IntVector2 WallCell = (BraveUtility.RandomElement(validWalls) - currentRoom.area.basePosition); GameObject ElevatorObject = ChaosPrefabs.ElevatorDeparture.InstantiateObject(currentRoom, WallCell, false); ElevatorObject.AddComponent <ChaosElevatorDepartureManager>(); ChaosElevatorDepartureManager elevatorComponent = ElevatorObject.GetComponent <ChaosElevatorDepartureManager>(); elevatorComponent.OverrideTargetFloor = GlobalDungeonData.ValidTilesets.OFFICEGEON; elevatorComponent.UsesOverrideTargetFloor = true; if (elevatorComponent.gameObject.GetComponentsInChildren <tk2dBaseSprite>(true) != null) { foreach (tk2dBaseSprite baseSprite in elevatorComponent.gameObject.GetComponentsInChildren <tk2dBaseSprite>(true)) { ChaosShaders.Instance.ApplyGlitchShader(null, baseSprite); } } validWalls.Remove(WallCell); ElevatorsPlaced++; } } } } } SelectedRoom++; } if (ChaosConsole.debugMimicFlag) { ETGModConsole.Log("[DEBUG] Number of Valid Glitch Elevator locations found: " + ElevatorLocations, false); ETGModConsole.Log("[DEBUG] Number of Glitch Elevators placed: " + ElevatorsPlaced, false); } }