public void OOf(Projectile projectile) { PlayerController player = this.gun.CurrentOwner as PlayerController; { IPlayerInteractable nearestInteractable = player.CurrentRoom.GetNearestInteractable(projectile.sprite.WorldCenter, 1f, player); if (nearestInteractable is InteractableLock || nearestInteractable is Chest || nearestInteractable is DungeonDoorController) { if (nearestInteractable is InteractableLock) { InteractableLock interactableLock = nearestInteractable as InteractableLock; if (interactableLock.lockMode == InteractableLock.InteractableLockMode.NORMAL) { { AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", base.gameObject); interactableLock.BreakLock(); } } return; } if (nearestInteractable is DungeonDoorController) { DungeonDoorController dungeonDoorController = nearestInteractable as DungeonDoorController; if (dungeonDoorController != null && dungeonDoorController.Mode == DungeonDoorController.DungeonDoorMode.COMPLEX && dungeonDoorController.isLocked) { { AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", base.gameObject); dungeonDoorController.BreakLock(); } } } else if (nearestInteractable is Chest) { Chest chest = nearestInteractable as Chest; if (chest.IsLocked) { if (!chest.IsLockBroken) { AkSoundEngine.PostEvent("Play_WPN_gun_empty_01", base.gameObject); chest.BreakLock(); return; } } } } } }
protected override void DoEffect(PlayerController user) { IPlayerInteractable nearestInteractable = user.CurrentRoom.GetNearestInteractable(user.CenterPosition, 1f, user); if (!(nearestInteractable is Chest)) { return; } AkSoundEngine.PostEvent("Play_ENM_electric_charge_01", user.gameObject); Chest rerollChest = nearestInteractable as Chest; int selected = UnityEngine.Random.Range(1, 15); ETGModConsole.Log(selected.ToString()); VFXToolbox.GlitchScreenForSeconds(1.5f); switch (selected) { case 1: //Blow up chest if (user.PlayerHasActiveSynergy("KEYGEN")) { SpareChest(rerollChest); } else { Exploder.DoDefaultExplosion(rerollChest.specRigidbody.UnitCenter, Vector2.zero); if (rerollChest.IsMimic) { OMITBReflectionHelpers.ReflectSetField <bool>(typeof(Chest), "m_isMimic", false, rerollChest); } rerollChest.majorBreakable.Break(Vector2.zero); if (rerollChest.GetChestTier() == ChestToolbox.ChestTier.RAT) { UnityEngine.Object.Destroy(rerollChest.gameObject); } } break; case 2: //Open Chest rerollChest.ForceOpen(user); break; case 3: //Break Lock if (user.PlayerHasActiveSynergy("KEYGEN")) { SpareChest(rerollChest); } else { if (rerollChest.IsLocked) { rerollChest.BreakLock(); } else { rerollChest.majorBreakable.Break(Vector2.zero); } } break; case 4: //Duplicate Chest DupeChest(rerollChest, user); break; case 5: //Turn into mimic if (!rerollChest.IsMimic) { rerollChest.overrideMimicChance = 100; rerollChest.MaybeBecomeMimic(); } rerollChest.ForceOpen(user); break; case 6: //Englitch List <GlobalDungeonData.ValidTilesets> bannedGlitchFloors = new List <GlobalDungeonData.ValidTilesets>() { GlobalDungeonData.ValidTilesets.CATACOMBGEON, GlobalDungeonData.ValidTilesets.HELLGEON, GlobalDungeonData.ValidTilesets.OFFICEGEON, GlobalDungeonData.ValidTilesets.FORGEGEON, }; if (!bannedGlitchFloors.Contains(GameManager.Instance.Dungeon.tileIndices.tilesetId)) { rerollChest.BecomeGlitchChest(); } else { if (!rerollChest.IsMimic) { rerollChest.MaybeBecomeMimic(); } rerollChest.ForceOpen(user); } break; case 7: //Enrainbow if (UnityEngine.Random.value <= 0.65f) { UpgradeChest(rerollChest, user); } else { rerollChest.BecomeRainbowChest(); } break; case 8: //Reroll RerollChest(rerollChest, user); break; case 9: //Turn into pickups if (user.PlayerHasActiveSynergy("KEYGEN")) { SpareChest(rerollChest); } else { for (int i = 0; i < 5; i++) { LootEngine.SpawnItem(PickupObjectDatabase.GetById(BraveUtility.RandomElement(BabyGoodChanceKin.lootIDlist)).gameObject, rerollChest.sprite.WorldCenter, Vector2.zero, 0); } LootEngine.SpawnCurrency(rerollChest.sprite.WorldCenter, UnityEngine.Random.Range(5, 11)); user.CurrentRoom.DeregisterInteractable(rerollChest); rerollChest.DeregisterChestOnMinimap(); UnityEngine.Object.Destroy(rerollChest.gameObject); } break; case 10: //Fuse if (user.PlayerHasActiveSynergy("KEYGEN")) { SpareChest(rerollChest); } else { var type = typeof(Chest); var func = type.GetMethod("TriggerCountdownTimer", BindingFlags.Instance | BindingFlags.NonPublic); var ret = func.Invoke(rerollChest, null); AkSoundEngine.PostEvent("Play_OBJ_fuse_loop_01", rerollChest.gameObject); } break; case 11: //Unlock if (rerollChest.IsLocked) { rerollChest.ForceUnlock(); } else { rerollChest.ForceOpen(user); } break; case 12: //Enjam rerollChest.gameObject.GetOrAddComponent <JammedChestBehav>(); break; case 13: //TeleportChest TeleportChest(rerollChest, user); break; case 14: //Drill FauxDrill(rerollChest, user); break; } }