private void SetupExitElevator() { if (m_DestinationDoor && !m_DestinationDoor.isHollowsElevator) { return; } ElevatorDepartureController targetElevator = null; if (FindObjectsOfType <ElevatorDepartureController>() != null) { foreach (ElevatorDepartureController elevator in FindObjectsOfType <ElevatorDepartureController>()) { if (elevator.gameObject.transform.position.GetAbsoluteRoom() != null && elevator.gameObject.transform.position.GetAbsoluteRoom() == m_parentRoom) { targetElevator = elevator; } } } if (targetElevator != null) { targetElevator.gameObject.AddComponent <ExpandElevatorDepartureManager>(); ExpandElevatorDepartureManager expandElevatorComponent = targetElevator.gameObject.GetComponent <ExpandElevatorDepartureManager>(); expandElevatorComponent.UsesOverrideTargetFloor = true; expandElevatorComponent.OverrideTargetFloor = GlobalDungeonData.ValidTilesets.WESTGEON; } return; }
public static void TransitionToDepartHook(System.Action <ElevatorDepartureController, tk2dSpriteAnimator, tk2dSpriteAnimationClip> orig, ElevatorDepartureController self, tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip) { if (self.ReturnToFoyerWithNewInstance) { GameManager.Instance.QuickRestart(); Module.Controller.TutorialComplete(); Module.TutorialDone = true; } else { orig(self, animator, clip); } }
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); * } * }*/ } } }
public void OnFloorDeparture(Action <ElevatorDepartureController> orig, ElevatorDepartureController self) { orig(self); }
public IEnumerator CorruptionRoomTime(PlayerController user) { RoomHandler currentRoom = user.CurrentRoom; Dungeon dungeon = GameManager.Instance.Dungeon; m_CachedScreenCapture = PortalTextureRender(); yield return(null); while (m_ScreenCapInProgress) { yield return(null); } if (currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear)) { StunEnemiesForTeleport(currentRoom, 1f); } TogglePlayerInput(user, true); m_cachedRoomPosition = user.transform.position; AkSoundEngine.PostEvent("Play_EX_CorruptionRoomTransition_01", gameObject); ExpandShaders.Instance.GlitchScreenForDuration(1, 1.4f, 0.1f); GameObject TempFXObject = new GameObject("EXScreenFXTemp") { }; TempFXObject.transform.SetParent(dungeon.gameObject.transform); TempFXObject.SetActive(false); yield return(null); ExpandGlitchScreenFXController fxController = TempFXObject.AddComponent <ExpandGlitchScreenFXController>(); fxController.shaderType = ExpandGlitchScreenFXController.ShaderType.Glitch; fxController.GlitchAmount = 0; yield return(null); TempFXObject.SetActive(true); while (fxController.GlitchAmount < 1) { fxController.GlitchAmount += (BraveTime.DeltaTime / 0.5f); yield return(null); } bool m_CopyCurrentRoom = false; if (!string.IsNullOrEmpty(currentRoom.GetRoomName())) { m_CopyCurrentRoom = (UnityEngine.Random.value < 0.05f); } PrototypeDungeonRoom SelectedPrototypeDungeonRoom = null; bool IsExitElevatorRoom = false; if (m_CopyCurrentRoom) { try { SelectedPrototypeDungeonRoom = RoomBuilder.GenerateRoomPrefabFromTexture2D(RoomDebug.DumpRoomAreaToTexture2D(currentRoom)); } catch (Exception ex) { if (ExpandSettings.debugMode) { ETGModConsole.Log("[ExpandTheGungeon.TheLeadKey] ERROR: Exception occured while building room!", true); Debug.LogException(ex); } AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", gameObject); TogglePlayerInput(user, false); ClearCooldowns(); yield break; } } else { float RoomSelectionSeed = UnityEngine.Random.value; bool GoingToSecretBoss = false; if (RoomSelectionSeed <= 0.01f) { GoingToSecretBoss = true; } if (!GoingToSecretBoss | ExpandSettings.HasSpawnedSecretBoss) { if (RoomSelectionSeed <= 0.05f && GameManager.Instance.CurrentFloor != 6 && GameManager.Instance.CurrentFloor != 5 && !ExpandSettings.phobosElevatorHasBeenUsed) { SelectedPrototypeDungeonRoom = BraveUtility.RandomElement(ExitElevatorRoomList); IsExitElevatorRoom = true; } else if (RoomSelectionSeed <= 0.25f) { SelectedPrototypeDungeonRoom = BraveUtility.RandomElement(RewardRoomList); } else if (RoomSelectionSeed <= 0.5f) { List <PrototypeDungeonRoom> m_SpecialRooms = new List <PrototypeDungeonRoom>(); m_SpecialRooms.Add(BraveUtility.RandomElement(NPCRoomList)); m_SpecialRooms.Add(BraveUtility.RandomElement(SecretRoomList)); m_SpecialRooms.Add(BraveUtility.RandomElement(ShrineRoomList)); SelectedPrototypeDungeonRoom = BraveUtility.RandomElement(m_SpecialRooms); } else { SelectedPrototypeDungeonRoom = BraveUtility.RandomElement(MainRoomlist); } } else { ExpandSettings.HasSpawnedSecretBoss = true; RoomHandler[] SecretBossRoomCluster = null; try { SecretBossRoomCluster = GenerateCorruptedBossRoomCluster(); } catch (Exception ex) { ETGModConsole.Log("[ExpandTheGungeon.TheLeadKey] ERROR: Exception occured while building room!", true); if (ExpandSettings.debugMode) { Debug.LogException(ex); } AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", gameObject); TogglePlayerInput(user, false); ClearCooldowns(); yield break; } yield return(null); if (SecretBossRoomCluster == null) { AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", gameObject); TogglePlayerInput(user, false); ClearCooldowns(); yield break; } ExpandPlaceCorruptTiles.PlaceCorruptTiles(dungeon, SecretBossRoomCluster[0], null, true, true); ExpandPlaceCorruptTiles.PlaceCorruptTiles(dungeon, SecretBossRoomCluster[1], null, true, true); TeleportToRoom(user, SecretBossRoomCluster[0]); while (m_IsTeleporting) { yield return(null); } GameObject m_PortalWarpObjectBossCluster = Instantiate(ExpandPrefabs.EX_GlitchPortal, (user.gameObject.transform.position + new Vector3(0.75f, 0)), Quaternion.identity); ExpandGlitchPortalController m_PortalControllerBossCluster = m_PortalWarpObjectBossCluster.GetComponent <ExpandGlitchPortalController>(); if (m_CachedScreenCapture) { m_PortalControllerBossCluster.renderer.material.SetTexture("_PortalTex", m_CachedScreenCapture); } m_PortalControllerBossCluster.CachedPosition = m_cachedRoomPosition; m_PortalControllerBossCluster.ParentRoom = SecretBossRoomCluster[0]; SecretBossRoomCluster[0].RegisterInteractable(m_PortalControllerBossCluster); while (fxController.GlitchAmount > 0) { fxController.GlitchAmount -= (BraveTime.DeltaTime / 0.5f); yield return(null); } TogglePlayerInput(user, false); m_PortalControllerBossCluster.Configured = true; Destroy(TempFXObject); m_InUse = false; yield break; } } if (SelectedPrototypeDungeonRoom == null) { AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", gameObject); TogglePlayerInput(user, false); ClearCooldowns(); yield break; } if (m_CopyCurrentRoom) { SelectedPrototypeDungeonRoom.overrideRoomVisualType = currentRoom.RoomVisualSubtype; } RoomHandler GlitchRoom = ExpandUtility.AddCustomRuntimeRoom(SelectedPrototypeDungeonRoom, IsExitElevatorRoom, false, allowProceduralLightFixtures: (true || m_CopyCurrentRoom)); if (GlitchRoom == null) { AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", gameObject); TogglePlayerInput(user, false); ClearCooldowns(); yield break; } if (!string.IsNullOrEmpty(GlitchRoom.GetRoomName())) { GlitchRoom.area.PrototypeRoomName = ("Corrupted " + GlitchRoom.GetRoomName()); } else { GlitchRoom.area.PrototypeRoomName = ("Corrupted Room"); } if (m_CopyCurrentRoom) { if (ExpandSettings.EnableGlitchFloorScreenShader && !dungeon.IsGlitchDungeon) { GameObject GlitchShaderObject = Instantiate(ExpandPrefabs.EXGlitchFloorScreenFX, GlitchRoom.area.UnitCenter, Quaternion.identity); ExpandGlitchScreenFXController FXController = GlitchShaderObject.GetComponent <ExpandGlitchScreenFXController>(); FXController.isRoomSpecific = true; FXController.ParentRoom = GlitchRoom; FXController.UseCorruptionAmbience = m_CopyCurrentRoom; GlitchShaderObject.transform.SetParent(dungeon.gameObject.transform); } GameObject[] Objects = FindObjectsOfType <GameObject>(); try { foreach (GameObject Object in Objects) { if (Object && Object.transform.parent == currentRoom.hierarchyParent && IsValidObject(Object)) { Vector3 OrigPosition = (Object.transform.position - currentRoom.area.basePosition.ToVector3()); Vector3 NewPosition = (OrigPosition + GlitchRoom.area.basePosition.ToVector3()); GameObject newObject = Instantiate(Object, NewPosition, Quaternion.identity); newObject.transform.SetParent(GlitchRoom.hierarchyParent); if (newObject.GetComponent <BaseShopController>()) { Destroy(newObject.GetComponent <BaseShopController>()); } if (newObject.GetComponent <PathingTrapController>()) { Destroy(newObject.GetComponent <PathingTrapController>()); } if (newObject.GetComponent <IPlaceConfigurable>() != null) { newObject.GetComponent <IPlaceConfigurable>().ConfigureOnPlacement(GlitchRoom); } if (newObject.GetComponent <TalkDoerLite>()) { newObject.GetComponent <TalkDoerLite>().SpeaksGleepGlorpenese = true; } if (newObject.GetComponent <IPlayerInteractable>() != null) { GlitchRoom.RegisterInteractable(newObject.GetComponent <IPlayerInteractable>()); } if (newObject.GetComponent <FlippableCover>()) { ExpandKickableObject kickableObject = newObject.AddComponent <ExpandKickableObject>(); newObject.GetComponent <ExpandKickableObject>().ConfigureOnPlacement(GlitchRoom); GlitchRoom.RegisterInteractable(kickableObject); } if (newObject && UnityEngine.Random.value <= 0.4f && !newObject.GetComponent <AIActor>() && !newObject.GetComponent <Chest>()) { if (!string.IsNullOrEmpty(newObject.name) && !newObject.name.ToLower().StartsWith("glitchtile") && !newObject.name.ToLower().StartsWith("ex secret door") && !newObject.name.ToLower().StartsWith("lock") && !newObject.name.ToLower().StartsWith("chest")) { float RandomIntervalFloat = UnityEngine.Random.Range(0.02f, 0.04f); float RandomDispFloat = UnityEngine.Random.Range(0.06f, 0.08f); float RandomDispIntensityFloat = UnityEngine.Random.Range(0.07f, 0.1f); float RandomColorProbFloat = UnityEngine.Random.Range(0.035f, 0.1f); float RandomColorIntensityFloat = UnityEngine.Random.Range(0.05f, 0.1f); ExpandShaders.Instance.BecomeGlitched(newObject, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorIntensityFloat); } } } } } catch (Exception ex) { if (ExpandSettings.debugMode) { ETGModConsole.Log("[ExpandTheGungeon.TheLeadKey] ERROR: Exception occured while duplicating objects for new room!", true); Debug.LogException(ex); } } IntVector2 ChestPosition = ExpandObjectDatabase.GetRandomAvailableCellForChest(dungeon, GlitchRoom, new List <IntVector2>()); if (ChestPosition != IntVector2.Zero) { GameObject newChest = Instantiate(ExpandPrefabs.SurpriseChestObject, ChestPosition.ToVector3(), Quaternion.identity); ExpandFakeChest fakeChest = newChest.GetComponent <ExpandFakeChest>(); fakeChest.ConfigureOnPlacement(GlitchRoom); GlitchRoom.RegisterInteractable(fakeChest); } } if (GlitchRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.SECRET && GlitchRoom.IsSecretRoom) { GlitchRoom.secretRoomManager.OpenDoor(); } if (m_CopyCurrentRoom) { ExpandPlaceCorruptTiles.PlaceCorruptTiles(dungeon, GlitchRoom, null, false, true, true); } else { ExpandPlaceCorruptTiles.PlaceCorruptTiles(dungeon, GlitchRoom, null, true, true, true); } if (IsExitElevatorRoom) { ElevatorDepartureController DepartureElevator = null; if (FindObjectsOfType <ElevatorDepartureController>() != null) { foreach (ElevatorDepartureController elevator in FindObjectsOfType <ElevatorDepartureController>()) { if (elevator.gameObject.transform.parent == GlitchRoom.hierarchyParent) { DepartureElevator = elevator; break; } } } if (DepartureElevator) { ExpandElevatorDepartureManager exElevator = DepartureElevator.gameObject.AddComponent <ExpandElevatorDepartureManager>(); exElevator.OverrideTargetFloor = GlobalDungeonData.ValidTilesets.PHOBOSGEON; } TeleportToRoom(user, GlitchRoom, false, m_CopyCurrentRoom, new Vector2(4, 2)); } else { TeleportToRoom(user, GlitchRoom, false, m_CopyCurrentRoom); } yield return(null); while (m_IsTeleporting) { yield return(null); } if (user.transform.position.GetAbsoluteRoom() != null) { if (user.CurrentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear)) { user.CurrentRoom.CompletelyPreventLeaving = true; } } if (GameManager.Instance.CurrentFloor == 1) { if (dungeon.data.Entrance != null) { dungeon.data.Entrance.AddProceduralTeleporterToRoom(); } } GameObject m_PortalWarpObject = Instantiate(ExpandPrefabs.EX_GlitchPortal, (user.gameObject.transform.position + new Vector3(0.75f, 0)), Quaternion.identity); ExpandGlitchPortalController m_PortalController = m_PortalWarpObject.GetComponent <ExpandGlitchPortalController>(); if (m_CachedScreenCapture) { m_PortalController.renderer.material.SetTexture("_PortalTex", m_CachedScreenCapture); } m_PortalController.CachedPosition = m_cachedRoomPosition; m_PortalController.ParentRoom = GlitchRoom; GlitchRoom.RegisterInteractable(m_PortalController); while (fxController.GlitchAmount > 0) { fxController.GlitchAmount -= (BraveTime.DeltaTime / 0.5f); yield return(null); } TogglePlayerInput(user, false); m_PortalController.Configured = true; Destroy(TempFXObject); m_InUse = false; yield break; }
private void Start() { ElevatorDepartureController departureComponent = gameObject.GetComponent <ElevatorDepartureController>(); if (departureComponent) { elevatorAnimator = departureComponent.elevatorAnimator; ceilingAnimator = departureComponent.ceilingAnimator; facewallAnimator = departureComponent.facewallAnimator; floorAnimator = departureComponent.floorAnimator; priorSprites = departureComponent.priorSprites; postSprites = departureComponent.postSprites; chunker = departureComponent.chunker; spawnTransform = departureComponent.spawnTransform; elevatorFloor = departureComponent.elevatorFloor; crumblyBumblyAnimator = departureComponent.crumblyBumblyAnimator; smokeAnimator = departureComponent.smokeAnimator; elevatorDescendAnimName = departureComponent.elevatorDescendAnimName; elevatorOpenAnimName = departureComponent.elevatorOpenAnimName; elevatorCloseAnimName = departureComponent.elevatorCloseAnimName; elevatorDepartAnimName = departureComponent.elevatorDepartAnimName; arrivalShake = departureComponent.arrivalShake; doorOpenShake = departureComponent.doorOpenShake; doorCloseShake = departureComponent.doorCloseShake; departureShake = departureComponent.departureShake; // Remove CryoButton. This version of the elevator won't support that. GameObject[] objects = FindObjectsOfType <GameObject>(); List <GameObject> CryoButtons = new List <GameObject>(); if (objects != null && objects.Length > 0) { foreach (GameObject targetObject in objects) { if (targetObject != null && targetObject.transform != null && !string.IsNullOrEmpty(targetObject.name)) { if (targetObject.name.StartsWith("CryoElevatorButton") && targetObject.transform.position.GetAbsoluteRoom() == GetAbsoluteParentRoom()) { float magnitude = (targetObject.transform.PositionVector2() - gameObject.transform.PositionVector2()).magnitude; if (magnitude <= 7) { CryoButtons.Add(targetObject); } } } } } if (CryoButtons.Count > 0) { for (int i = 0; i < CryoButtons.Count; i++) { Destroy(CryoButtons[i]); } } departureComponent.enabled = false; Destroy(departureComponent); Destroy(gameObject.GetComponent <ElevatorDepartureController>()); SpeculativeRigidbody component = elevatorFloor.GetComponent <SpeculativeRigidbody>(); if (component) { if (ConfigurationWasDeferred) { component.PrimaryPixelCollider.ManualOffsetY -= 8; component.PrimaryPixelCollider.ManualHeight += 8; component.Reinitialize(); } SpeculativeRigidbody speculativeRigidbody = component; speculativeRigidbody.OnTriggerCollision = (SpeculativeRigidbody.OnTriggerDelegate)Delegate.Combine(speculativeRigidbody.OnTriggerCollision, new SpeculativeRigidbody.OnTriggerDelegate(OnElevatorTriggerEnter)); } ToggleSprites(true); } else { if (ExpandSettings.debugMode) { ETGModConsole.Log("[DEBUG] ERROR: ElevatorDepatureComponent is null!"); Destroy(this); } } if (ConfigurationWasDeferred) { Material material = Instantiate(priorSprites[1].renderer.material); material.shader = ShaderCache.Acquire("Brave/Unity Transparent Cutout"); priorSprites[1].renderer.material = material; Material material2 = Instantiate(postSprites[2].renderer.material); material2.shader = ShaderCache.Acquire("Brave/Unity Transparent Cutout"); postSprites[2].renderer.material = material2; postSprites[1].HeightOffGround = postSprites[1].HeightOffGround - 0.0625f; postSprites[3].HeightOffGround = postSprites[3].HeightOffGround - 0.0625f; postSprites[1].UpdateZDepth(); } }