using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("REPOJP")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("REPOJP")] [assembly: AssemblyTitle("REPOJP")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace REPOJPPressYourLuckCrown { [BepInPlugin("REPOJP.PressYourLuckCrown", "PressYourLuckCrown", "2.0.0")] public class PressYourLuckCrownPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(ValuableObject), "DollarValueSetLogic")] private static class ValuableObject_DollarValueSetLogic_Patch { private static void Postfix(ValuableObject __instance) { try { if (!ModEnabled.Value || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } ClownTrap component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { int minValue = InitialClownValueMin.Value; int maxValue = InitialClownValueMax.Value; NormalizeMinMax(ref minValue, ref maxValue, 1); int num = Random.Range(minValue, maxValue + 1); SetDollarValues(__instance, num, num); if (DebugLogEnabled.Value) { LogSource.LogInfo((object)("[PressYourLuckCrown] InitialValue=$" + num + " Object=" + ((Object)((Component)component).gameObject).name)); } } } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] ValuableObject_DollarValueSetLogic_Patch failure\n" + ex)); } } } private sealed class TrapActivateState { public bool WasTriggered; } [HarmonyPatch(typeof(ClownTrap), "TrapActivate")] private static class ClownTrap_TrapActivate_Patch { private static void Prefix(ClownTrap __instance, out TrapActivateState __state) { __state = new TrapActivateState(); __state.WasTriggered = ((Trap)__instance).trapTriggered; } private static void Postfix(ClownTrap __instance, TrapActivateState __state) { try { if (ModEnabled.Value && __state != null && !__state.WasTriggered && ((Trap)__instance).trapTriggered) { ClownState orCreateState = GetOrCreateState(__instance); orCreateState.ValidPressCount++; int validPressCount = orCreateState.ValidPressCount; bool flag = ShouldJackpotForPress(__instance, validPressCount); TryApplyBonusHost(__instance, validPressCount, flag); TryPlayMegaNoise(__instance); if (flag) { orCreateState.HadJackpot = true; TryPlayJackpotVisualLocal(__instance); TryMakeUltraFragile(__instance); } } } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] ClownTrap_TrapActivate_Patch failure\n" + ex)); } } } [HarmonyPatch(typeof(ClownTrap), "TrapStop")] private static class ClownTrap_TrapStop_Patch { private static bool Prefix(ClownTrap __instance) { try { if (!ModEnabled.Value) { return true; } ExecuteCustomExplosion(__instance); return false; } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] ClownTrap_TrapStop_Patch failure\n" + ex)); return true; } } } internal sealed class ClownState { public int ValidPressCount; public bool HadJackpot; } [CompilerGenerated] private sealed class d__66 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Vector3 position; public int pulseCount; public float interval; public float range; public bool pathfindOnly; private int 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__66(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 0; break; case 1: <>1__state = -1; if (!SemiFunc.IsMasterClientOrSingleplayer()) { return false; } if ((Object)(object)EnemyDirector.instance == (Object)null) { return false; } EnemyDirector.instance.SetInvestigate(position, range, pathfindOnly); 5__1++; break; } if (5__1 < pulseCount) { <>2__current = (object)new WaitForSeconds(interval); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string PluginGuid = "REPOJP.PressYourLuckCrown"; public const string PluginName = "PressYourLuckCrown"; public const string PluginVersion = "2.0.0"; internal static PressYourLuckCrownPlugin Instance; internal static ManualLogSource LogSource; private Harmony harmony; internal static ConfigEntry ModEnabled; internal static ConfigEntry DebugLogEnabled; internal static ConfigEntry InitialClownValueMin; internal static ConfigEntry InitialClownValueMax; internal static ConfigEntry BonusEnabled; internal static ConfigEntry BonusValueMin; internal static ConfigEntry BonusValueMax; internal static ConfigEntry RoundBonusToHundreds; internal static ConfigEntry ApplyBonusOnFinalPress; internal static ConfigEntry PressMultiplierEnabled; internal static ConfigEntry Press1Multiplier; internal static ConfigEntry Press2Multiplier; internal static ConfigEntry Press3Multiplier; internal static ConfigEntry JackpotEnabled; internal static ConfigEntry JackpotChancePercent; internal static ConfigEntry JackpotValueMin; internal static ConfigEntry JackpotValueMax; internal static ConfigEntry JackpotUsesMultiplier; internal static ConfigEntry JackpotRoundToHundreds; internal static ConfigEntry JackpotUltraFragile; internal static ConfigEntry MegaNoiseEnabled; internal static ConfigEntry PressSoundVolumeMultiplier; internal static ConfigEntry PressSoundFalloffMultiplier; internal static ConfigEntry PressSoundOffscreenVolumeMultiplier; internal static ConfigEntry PressSoundOffscreenFalloffMultiplier; internal static ConfigEntry PressInvestigateRange; internal static ConfigEntry PressInvestigatePathfindOnly; internal static ConfigEntry ExtraInvestigatePulses; internal static ConfigEntry ExtraInvestigatePulseInterval; internal static ConfigEntry ExplosionDamageMultiplier; internal static ConfigEntry ExplosionKnockbackMultiplier; internal static ConfigEntry ExplosionValuableDamageMultiplier; internal static readonly FieldInfo ValuableDollarValueOriginalField = AccessTools.Field(typeof(ValuableObject), "dollarValueOriginal"); internal static readonly FieldInfo ValuableDollarValueCurrentField = AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent"); internal static readonly FieldInfo ValuableDollarValueSetField = AccessTools.Field(typeof(ValuableObject), "dollarValueSet"); internal static readonly FieldInfo ClownPreviousAudioSourceField = AccessTools.Field(typeof(ClownTrap), "previousAudioSource"); internal static readonly FieldInfo ImpactDetectorIndestructibleSpawnTimerField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "indestructibleSpawnTimer"); internal static readonly Dictionary ClownStates = new Dictionary(); private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown try { Instance = this; LogSource = ((BaseUnityPlugin)this).Logger; ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); SetupConfig(); harmony = new Harmony("REPOJP.PressYourLuckCrown"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[PressYourLuckCrown] Loaded"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[PressYourLuckCrown] Awake failure\n" + ex)); } } private void OnDestroy() { try { if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[PressYourLuckCrown] OnDestroy failure\n" + ex)); } } private void SetupConfig() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Expected O, but got Unknown //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Expected O, but got Unknown //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Expected O, but got Unknown //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Expected O, but got Unknown //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Expected O, but got Unknown //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Expected O, but got Unknown //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Expected O, but got Unknown //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Expected O, but got Unknown //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Expected O, but got Unknown //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Expected O, but got Unknown ModEnabled = ((BaseUnityPlugin)this).Config.Bind("1. General", "ModEnabled", true, "MOD enabled"); DebugLogEnabled = ((BaseUnityPlugin)this).Config.Bind("1. General", "DebugLogEnabled", false, "Enable debug logging"); InitialClownValueMin = ((BaseUnityPlugin)this).Config.Bind("2. Initial Value", "InitialClownValueMin", 1, new ConfigDescription("Initial clown value minimum", (AcceptableValueBase)(object)new AcceptableValueRange(1, 1000000), Array.Empty())); InitialClownValueMax = ((BaseUnityPlugin)this).Config.Bind("2. Initial Value", "InitialClownValueMax", 3000, new ConfigDescription("Initial clown value maximum", (AcceptableValueBase)(object)new AcceptableValueRange(1, 1000000), Array.Empty())); BonusEnabled = ((BaseUnityPlugin)this).Config.Bind("3. Bonus", "BonusEnabled", true, "Enable value bonus on valid clown nose press"); BonusValueMin = ((BaseUnityPlugin)this).Config.Bind("3. Bonus", "BonusValueMin", 100, new ConfigDescription("Minimum base bonus per press", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000000), Array.Empty())); BonusValueMax = ((BaseUnityPlugin)this).Config.Bind("3. Bonus", "BonusValueMax", 500, new ConfigDescription("Maximum base bonus per press", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000000), Array.Empty())); RoundBonusToHundreds = ((BaseUnityPlugin)this).Config.Bind("3. Bonus", "RoundBonusToHundreds", true, "Round normal bonus to nearest 100"); ApplyBonusOnFinalPress = ((BaseUnityPlugin)this).Config.Bind("3. Bonus", "ApplyBonusOnFinalPress", true, "Apply bonus even on the final press"); PressMultiplierEnabled = ((BaseUnityPlugin)this).Config.Bind("4. Multiplier", "PressMultiplierEnabled", true, "Enable multiplier by press count"); Press1Multiplier = ((BaseUnityPlugin)this).Config.Bind("4. Multiplier", "Press1Multiplier", 1f, new ConfigDescription("Multiplier for first valid press", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); Press2Multiplier = ((BaseUnityPlugin)this).Config.Bind("4. Multiplier", "Press2Multiplier", 1.5f, new ConfigDescription("Multiplier for second valid press", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); Press3Multiplier = ((BaseUnityPlugin)this).Config.Bind("4. Multiplier", "Press3Multiplier", 2.25f, new ConfigDescription("Multiplier for third valid press", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); JackpotEnabled = ((BaseUnityPlugin)this).Config.Bind("5. Jackpot", "JackpotEnabled", true, "Enable jackpot chance on valid press"); JackpotChancePercent = ((BaseUnityPlugin)this).Config.Bind("5. Jackpot", "JackpotChancePercent", 7.5f, new ConfigDescription("Jackpot chance percent", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); JackpotValueMin = ((BaseUnityPlugin)this).Config.Bind("5. Jackpot", "JackpotValueMin", 3000, new ConfigDescription("Minimum jackpot bonus", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000000), Array.Empty())); JackpotValueMax = ((BaseUnityPlugin)this).Config.Bind("5. Jackpot", "JackpotValueMax", 10000, new ConfigDescription("Maximum jackpot bonus", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000000), Array.Empty())); JackpotUsesMultiplier = ((BaseUnityPlugin)this).Config.Bind("5. Jackpot", "JackpotUsesMultiplier", true, "Apply press multiplier to jackpot value"); JackpotRoundToHundreds = ((BaseUnityPlugin)this).Config.Bind("5. Jackpot", "JackpotRoundToHundreds", true, "Round jackpot value to nearest 100"); JackpotUltraFragile = ((BaseUnityPlugin)this).Config.Bind("5. Jackpot", "JackpotUltraFragile", true, "Make the clown extremely fragile after jackpot"); MegaNoiseEnabled = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "MegaNoiseEnabled", true, "Enable mega loud extra nose sound and enemy investigate pulse"); PressSoundVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "PressSoundVolumeMultiplier", 3f, new ConfigDescription("Extra press sound volume multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 20f), Array.Empty())); PressSoundFalloffMultiplier = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "PressSoundFalloffMultiplier", 10f, new ConfigDescription("Extra press sound falloff multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 100f), Array.Empty())); PressSoundOffscreenVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "PressSoundOffscreenVolumeMultiplier", 1f, new ConfigDescription("Extra press sound offscreen volume multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 20f), Array.Empty())); PressSoundOffscreenFalloffMultiplier = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "PressSoundOffscreenFalloffMultiplier", 10f, new ConfigDescription("Extra press sound offscreen falloff multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 100f), Array.Empty())); PressInvestigateRange = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "PressInvestigateRange", 100f, new ConfigDescription("Enemy investigate range on valid press", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 999f), Array.Empty())); PressInvestigatePathfindOnly = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "PressInvestigatePathfindOnly", false, "Use pathfindOnly investigate mode"); ExtraInvestigatePulses = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "ExtraInvestigatePulses", 2, new ConfigDescription("Additional investigate pulses after the first one", (AcceptableValueBase)(object)new AcceptableValueRange(0, 20), Array.Empty())); ExtraInvestigatePulseInterval = ((BaseUnityPlugin)this).Config.Bind("6. Mega Noise", "ExtraInvestigatePulseInterval", 0.35f, new ConfigDescription("Interval between additional investigate pulses", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 10f), Array.Empty())); ExplosionDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind("7. Explosion", "ExplosionDamageMultiplier", 3f, new ConfigDescription("Explosion damage multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 10f), Array.Empty())); ExplosionKnockbackMultiplier = ((BaseUnityPlugin)this).Config.Bind("7. Explosion", "ExplosionKnockbackMultiplier", 3f, new ConfigDescription("Explosion knockback multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 10f), Array.Empty())); ExplosionValuableDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind("7. Explosion", "ExplosionValuableDamageMultiplier", 3f, new ConfigDescription("Explosion valuable damage multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 10f), Array.Empty())); } internal static int GetClownKey(ClownTrap clownTrap) { PhotonView component = ((Component)clownTrap).GetComponent(); if ((Object)(object)component != (Object)null && component.ViewID != 0) { return component.ViewID; } return ((Object)clownTrap).GetInstanceID(); } internal static ClownState GetOrCreateState(ClownTrap clownTrap) { int clownKey = GetClownKey(clownTrap); if (!ClownStates.TryGetValue(clownKey, out ClownState value)) { value = new ClownState(); ClownStates[clownKey] = value; } return value; } internal static void RemoveState(ClownTrap clownTrap) { ClownStates.Remove(GetClownKey(clownTrap)); } internal static void NormalizeMinMax(ref int minValue, ref int maxValue, int minClamp) { if (minValue < minClamp) { minValue = minClamp; } if (maxValue < minClamp) { maxValue = minClamp; } if (maxValue < minValue) { int num = minValue; minValue = maxValue; maxValue = num; } } internal static float GetPressMultiplier(int pressCount) { if (!PressMultiplierEnabled.Value) { return 1f; } if (pressCount <= 1) { return Mathf.Max(0f, Press1Multiplier.Value); } if (pressCount == 2) { return Mathf.Max(0f, Press2Multiplier.Value); } return Mathf.Max(0f, Press3Multiplier.Value); } internal static int GetStableSeed(ClownTrap clownTrap, int salt) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) int num = 17; PhotonView component = ((Component)clownTrap).GetComponent(); int num2 = (((Object)(object)component != (Object)null) ? component.ViewID : 0); num = num * 31 + num2; num = num * 31 + ((Object)((Component)clownTrap).gameObject).name.GetHashCode(); Vector3 position = ((Component)clownTrap).transform.position; num = num * 31 + Mathf.RoundToInt(position.x * 100f); num = num * 31 + Mathf.RoundToInt(position.y * 100f); num = num * 31 + Mathf.RoundToInt(position.z * 100f); return num * 31 + salt; } internal static Random CreateDeterministicRandom(ClownTrap clownTrap, int salt) { return new Random(GetStableSeed(clownTrap, salt)); } internal static int RollDeterministicInt(ClownTrap clownTrap, int salt, int minValue, int maxValue) { NormalizeMinMax(ref minValue, ref maxValue, (minValue > 0) ? 1 : 0); if (minValue == maxValue) { return minValue; } Random random = CreateDeterministicRandom(clownTrap, salt); return random.Next(minValue, maxValue + 1); } internal static float RollDeterministicPercent01(ClownTrap clownTrap, int salt) { Random random = CreateDeterministicRandom(clownTrap, salt); return (float)random.NextDouble(); } internal static bool GetDollarValueSet(ValuableObject valuableObject) { if (ValuableDollarValueSetField == null) { return false; } if (!(ValuableDollarValueSetField.GetValue(valuableObject) is bool result)) { return false; } return result; } internal static float GetDollarValueOriginal(ValuableObject valuableObject) { if (ValuableDollarValueOriginalField == null) { return 0f; } if (!(ValuableDollarValueOriginalField.GetValue(valuableObject) is float result)) { return 0f; } return result; } internal static float GetDollarValueCurrent(ValuableObject valuableObject) { if (ValuableDollarValueCurrentField == null) { return 0f; } if (!(ValuableDollarValueCurrentField.GetValue(valuableObject) is float result)) { return 0f; } return result; } internal static void EnsureDollarValueInitialized(ValuableObject valuableObject) { if (!GetDollarValueSet(valuableObject)) { valuableObject.DollarValueSetLogic(); } } internal static void SetDollarValues(ValuableObject valuableObject, float originalValue, float currentValue) { if (ValuableDollarValueOriginalField != null) { ValuableDollarValueOriginalField.SetValue(valuableObject, originalValue); } if (ValuableDollarValueCurrentField != null) { ValuableDollarValueCurrentField.SetValue(valuableObject, currentValue); } if (ValuableDollarValueSetField != null) { ValuableDollarValueSetField.SetValue(valuableObject, true); } } internal static void SyncDollarValueToOthers(ValuableObject valuableObject, float newValue) { if (SemiFunc.IsMultiplayer()) { PhotonView component = ((Component)valuableObject).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { newValue }); } } } internal static bool ShouldJackpotForPress(ClownTrap clownTrap, int pressCount) { if (!JackpotEnabled.Value) { return false; } if (pressCount >= 3) { return false; } float num = Mathf.Clamp(JackpotChancePercent.Value, 0f, 100f); if (num <= 0f) { return false; } float num2 = RollDeterministicPercent01(clownTrap, 7000 + pressCount) * 100f; return num2 < num; } internal static float CalculateBonusAmount(ClownTrap clownTrap, int pressCount, bool jackpot) { if (!BonusEnabled.Value) { return 0f; } int minValue; int maxValue; if (jackpot) { minValue = JackpotValueMin.Value; maxValue = JackpotValueMax.Value; NormalizeMinMax(ref minValue, ref maxValue, 0); } else { minValue = BonusValueMin.Value; maxValue = BonusValueMax.Value; NormalizeMinMax(ref minValue, ref maxValue, 0); } float num = RollDeterministicInt(clownTrap, (jackpot ? 8000 : 9000) + pressCount, minValue, maxValue); if (jackpot) { if (JackpotRoundToHundreds.Value) { num = Mathf.Round(num / 100f) * 100f; } if (JackpotUsesMultiplier.Value) { num *= GetPressMultiplier(pressCount); } } else { if (RoundBonusToHundreds.Value) { num = Mathf.Round(num / 100f) * 100f; } num *= GetPressMultiplier(pressCount); } return Mathf.Max(0f, Mathf.Round(num)); } internal static void TryApplyBonusHost(ClownTrap clownTrap, int pressCount, bool jackpot) { try { if (!ModEnabled.Value || !SemiFunc.IsMasterClientOrSingleplayer() || (pressCount >= 3 && !ApplyBonusOnFinalPress.Value)) { return; } float num = CalculateBonusAmount(clownTrap, pressCount, jackpot); if (num <= 0f) { return; } ValuableObject component = ((Component)clownTrap).GetComponent(); if (!((Object)(object)component == (Object)null)) { EnsureDollarValueInitialized(component); float dollarValueCurrent = GetDollarValueCurrent(component); float dollarValueOriginal = GetDollarValueOriginal(component); float originalValue = Mathf.Max(0f, dollarValueOriginal + num); float num2 = Mathf.Max(0f, dollarValueCurrent + num); SetDollarValues(component, originalValue, num2); SyncDollarValueToOthers(component, num2); if (DebugLogEnabled.Value) { LogSource.LogInfo((object)("[PressYourLuckCrown] Press=" + pressCount + " Jackpot=" + jackpot + " Bonus=$" + num + " NewValue=$" + num2 + " Object=" + ((Object)((Component)clownTrap).gameObject).name)); } } } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] TryApplyBonusHost failure\n" + ex)); } } internal static void TryPlayMegaNoise(ClownTrap clownTrap) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) try { if (!ModEnabled.Value || !MegaNoiseEnabled.Value) { return; } Vector3 bestSoundPosition = GetBestSoundPosition(clownTrap); if (clownTrap.NoseSqeak != null) { clownTrap.NoseSqeak.Play(bestSoundPosition, Mathf.Max(0f, PressSoundVolumeMultiplier.Value), Mathf.Max(0.1f, PressSoundFalloffMultiplier.Value), Mathf.Max(0f, PressSoundOffscreenVolumeMultiplier.Value), Mathf.Max(0.1f, PressSoundOffscreenFalloffMultiplier.Value)); } if (SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)EnemyDirector.instance != (Object)null && PressInvestigateRange.Value > 0f) { EnemyDirector.instance.SetInvestigate(bestSoundPosition, PressInvestigateRange.Value, PressInvestigatePathfindOnly.Value); int num = Mathf.Max(0, ExtraInvestigatePulses.Value); if (num > 0 && (Object)(object)Instance != (Object)null) { ((MonoBehaviour)Instance).StartCoroutine(InvestigatePulseCoroutine(bestSoundPosition, num, Mathf.Max(0.05f, ExtraInvestigatePulseInterval.Value), PressInvestigateRange.Value, PressInvestigatePathfindOnly.Value)); } } } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] TryPlayMegaNoise failure\n" + ex)); } } [IteratorStateMachine(typeof(d__66))] private static IEnumerator InvestigatePulseCoroutine(Vector3 position, int pulseCount, float interval, float range, bool pathfindOnly) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__66(0) { position = position, pulseCount = pulseCount, interval = interval, range = range, pathfindOnly = pathfindOnly }; } internal static void TryPlayJackpotVisualLocal(ClownTrap clownTrap) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) try { ParticleScriptExplosion component = ((Component)clownTrap).GetComponent(); if (!((Object)(object)component == (Object)null)) { Vector3 val = (((Object)(object)clownTrap.Center != (Object)null) ? clownTrap.Center.position : ((Component)clownTrap).transform.position); component.Spawn(val, 1.5f, 0, 0, 1f, true, false, 1f); } } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] TryPlayJackpotVisualLocal failure\n" + ex)); } } internal static void TryMakeUltraFragile(ClownTrap clownTrap) { try { if (!JackpotUltraFragile.Value) { return; } PhysGrabObjectImpactDetector component = ((Component)clownTrap).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.durability = 1f; component.fragility = 100f; component.fragilityMultiplier = 10f; component.destroyDisable = false; component.indestructibleBreakEffects = true; if (ImpactDetectorIndestructibleSpawnTimerField != null) { ImpactDetectorIndestructibleSpawnTimerField.SetValue(component, 0f); } } } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] TryMakeUltraFragile failure\n" + ex)); } } internal static void ExecuteCustomExplosion(ClownTrap clownTrap) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) try { ((Trap)clownTrap).trapActive = false; AudioSource val = null; if (ClownPreviousAudioSourceField != null) { object? value = ClownPreviousAudioSourceField.GetValue(clownTrap); val = (AudioSource)((value is AudioSource) ? value : null); } if ((Object)(object)val != (Object)null) { val.Stop(); } ParticleScriptExplosion component = ((Component)clownTrap).GetComponent(); PhysGrabObject component2 = ((Component)clownTrap).GetComponent(); Vector3 val2 = (((Object)(object)clownTrap.Center != (Object)null) ? clownTrap.Center.position : ((Component)clownTrap).transform.position); if ((Object)(object)component != (Object)null) { float num = Mathf.Clamp(ExplosionDamageMultiplier.Value, 0.01f, 10f); float num2 = Mathf.Clamp(ExplosionKnockbackMultiplier.Value, 0.01f, 10f); float num3 = Mathf.Clamp(ExplosionValuableDamageMultiplier.Value, 0.01f, 10f); int num4 = Mathf.Max(1, Mathf.RoundToInt(100f * num)); int num5 = Mathf.Max(1, Mathf.RoundToInt(300f * num)); ParticlePrefabExplosion val3 = component.Spawn(val2, 1.5f, num4, num5, 1f, false, false, 1f); if ((Object)(object)val3 != (Object)null) { val3.forceMultiplier *= num2; if ((Object)(object)val3.HurtCollider != (Object)null) { val3.HurtCollider.playerDamage = num4; val3.HurtCollider.enemyDamage = num5; HurtCollider hurtCollider = val3.HurtCollider; hurtCollider.playerHitForce *= num2; HurtCollider hurtCollider2 = val3.HurtCollider; hurtCollider2.playerTumbleForce *= num2; HurtCollider hurtCollider3 = val3.HurtCollider; hurtCollider3.playerTumbleTorque *= num2; HurtCollider hurtCollider4 = val3.HurtCollider; hurtCollider4.enemyHitForce *= num2; HurtCollider hurtCollider5 = val3.HurtCollider; hurtCollider5.enemyHitTorque *= num2; HurtCollider hurtCollider6 = val3.HurtCollider; hurtCollider6.physHitForce *= num3; } } } if ((Object)(object)component2 != (Object)null) { component2.dead = true; } RemoveState(clownTrap); } catch (Exception ex) { LogSource.LogError((object)("[PressYourLuckCrown] ExecuteCustomExplosion failure\n" + ex)); } } internal static Vector3 GetBestSoundPosition(ClownTrap clownTrap) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clownTrap.Center != (Object)null) { return clownTrap.Center.position; } PhysGrabObject component = ((Component)clownTrap).GetComponent(); if ((Object)(object)component != (Object)null) { return component.centerPoint; } return ((Component)clownTrap).transform.position; } } }