Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of BalancedFasterInteractables v1.3.2
BalancedFasterInteractables.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using EntityStates; using EntityStates.Barrel; using EntityStates.Duplicator; using EntityStates.Scrapper; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using RoR2.EntityLogic; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.2.0")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RiskOfResources { [BepInPlugin("com.riskofresources.fast.interactable", "BalancedFasterInteractables", "1.3.2")] [BepInIncompatibility("riskofresources.FasterInteractableBalancer")] [BepInIncompatibility("FlyingComputer.ExchangeChanges")] [BepInIncompatibility("Felda.ActuallyFaster")] internal class BalancedFasterInteractables : BaseUnityPlugin { private class PurchaseDelay : MonoBehaviour { [CompilerGenerated] private sealed class <Initialize>d__6 : IEnumerable<PurchaseDelay>, IEnumerable, IEnumerator<PurchaseDelay>, IEnumerator, IDisposable { private int <>1__state; private PurchaseDelay <>2__current; private int <>l__initialThreadId; private PurchaseInteraction interaction; public PurchaseInteraction <>3__interaction; private List<PersistentCall>.Enumerator <>7__wrap1; PurchaseDelay IEnumerator<PurchaseDelay>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Initialize>d__6(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = ((UnityEventBase)interaction.onPurchase).m_PersistentCalls.m_Calls.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { PersistentCall current = <>7__wrap1.Current; if (current.target is DelayedEvent && current.methodName == "CallDelayed") { PurchaseDelay purchaseDelay = ((Component)interaction).gameObject.AddComponent<PurchaseDelay>(); purchaseDelay.delay = current.arguments; purchaseDelay.original = purchaseDelay.delay.floatArgument; <>2__current = purchaseDelay; <>1__state = 1; return true; } } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<PurchaseDelay> IEnumerable<PurchaseDelay>.GetEnumerator() { <Initialize>d__6 <Initialize>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <Initialize>d__ = this; } else { <Initialize>d__ = new <Initialize>d__6(0); } <Initialize>d__.interaction = <>3__interaction; return <Initialize>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<PurchaseDelay>)this).GetEnumerator(); } } private ArgumentCache delay; private float original; internal static void Set(PurchaseInteraction interaction, float multiplier, bool timed) { IEnumerable<PurchaseDelay> enumerable = ((Component)interaction).GetComponents<PurchaseDelay>(); if (!enumerable.Any()) { enumerable = Initialize(interaction); } float num = 0f; foreach (PurchaseDelay item in enumerable) { item.Update(multiplier); num = Mathf.Max(item.original, num); } if (timed) { UpdateStopwatch(num - num * multiplier); } ((UnityEventBase)interaction.onPurchase).DirtyPersistentCalls(); } internal static void Remove(PurchaseInteraction interaction) { PurchaseDelay[] components = ((Component)interaction).gameObject.GetComponents<PurchaseDelay>(); foreach (PurchaseDelay obj in components) { ((UnityEventBase)interaction.onPurchase).DirtyPersistentCalls(); obj.Reset(); Object.Destroy((Object)(object)obj); } } private void Update(float multiplier) { delay.floatArgument = original * multiplier; } private void Reset() { delay.floatArgument = original; } [IteratorStateMachine(typeof(<Initialize>d__6))] private static IEnumerable<PurchaseDelay> Initialize(PurchaseInteraction interaction) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Initialize>d__6(-2) { <>3__interaction = interaction }; } } public const string version = "1.3.2"; public const string identifier = "com.riskofresources.fast.interactable"; private static ConfigEntry<bool> teleporter; private static ConfigEntry<bool> penalty; private static ConfigEntry<float> speed; private static ConfigEntry<bool> printer; private static ConfigEntry<bool> scrapper; private static ConfigEntry<bool> shrine; private static ConfigEntry<bool> chest; private static ConfigEntry<bool> cradle; private static ConfigEntry<bool> pool; private static ConfigEntry<bool> cauldron; private static bool Idle { get { if (teleporter.Value) { TeleporterInteraction instance = TeleporterInteraction.instance; if (!(((instance != null) ? instance.currentState : null) is ChargedState)) { return CombatDirector.instancesList.Count > 0; } } return false; } } protected void Awake() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown teleporter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Only After Teleporter", true, "By default, this plugin will only take effect after the teleporter has been charged, or all combat directors have deactivated."); penalty = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Time Penalty", true, "Any time taken off the activation will be directly added to the game stopwatch."); speed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Speed", 75f, new ConfigDescription("Time to complete each interaction is reduced by this percentage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); printer = interactable("Printer"); scrapper = interactable("Scrapper"); shrine = interactable("Shrine of Chance"); chest = interactable("Chest"); cradle = interactable("Void Cradle"); pool = interactable("Cleansing Pool"); cauldron = interactable("Lunar Cauldron"); Harmony.CreateAndPatchAll(typeof(BalancedFasterInteractables), (string)null); ConfigEntry<bool> interactable(string key) { return ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", key, true, ""); } } [HarmonyPatch(typeof(Duplicating), "OnEnter")] [HarmonyPostfix] private static void PrintFaster(Duplicating __instance) { bool flag = !printer.Value || Idle; DelayedEvent val = default(DelayedEvent); if (((Component)((EntityState)__instance).outer).TryGetComponent<DelayedEvent>(ref val)) { ((Behaviour)val).enabled = flag; } if (!flag) { float num = speed.Value / 100f; if (Object.op_Implicit((Object)(object)val)) { ((EntityState)__instance).GetComponent<PurchaseInteraction>().SetUnavailableTemporarily(4f * (1f - num)); } num *= Duplicating.initialDelayDuration + Duplicating.timeBetweenStartAndDropDroplet; ((EntityState)__instance).fixedAge = ((EntityState)__instance).fixedAge + num; UpdateStopwatch(num); } } [HarmonyPatch(typeof(Duplicating), "BeginCooking")] [HarmonyPostfix] private static void ScaleAnimation(Duplicating __instance) { if (printer.Value && !Idle) { ((EntityState)__instance).GetModelAnimator().speed = 125f / (125f - speed.Value); } } [HarmonyPatch(typeof(ScrapperBaseState), "OnEnter")] [HarmonyPostfix] private static void ScrapQuickly(ScrapperBaseState __instance) { if (!scrapper.Value || Idle) { return; } float num = speed.Value / 100f; if (!(__instance is WaitToBeginScrapping)) { if (!(__instance is Scrapping)) { if (!(__instance is ScrappingToIdle)) { return; } num *= ScrappingToIdle.duration * 0.5f; } else { num *= Scrapping.duration; } } else { num *= WaitToBeginScrapping.duration; } ((EntityState)__instance).fixedAge = ((EntityState)__instance).fixedAge + num; UpdateStopwatch(num); } [HarmonyPatch(typeof(ShrineChanceBehavior), "AddShrineStack")] [HarmonyPostfix] private static void SpeedUpShrine(ShrineChanceBehavior __instance) { if (shrine.Value && !Idle) { float num = speed.Value / 100f * __instance.refreshTimer; __instance.refreshTimer -= num; UpdateStopwatch(num); } } [HarmonyPatch(typeof(Opening), "OnEnter")] [HarmonyPostfix] private static void OpenChest(EntityState __instance) { if (chest.Value && !Idle && __instance.GetComponent<ChestBehavior>() != null) { float num = speed.Value / 100f; UpdateStopwatch(0.45f * Opening.duration * num); num = ((num != 1f) ? (1f / (1f - num)) : float.MaxValue); __instance.GetModelAnimator().speed = num; } } [HarmonyPatch(typeof(OpeningLunar), "OnEnter")] [HarmonyPostfix] private static void CrackThatSuckerOpen(BaseState __instance) { if (cradle.Value && !Idle) { float num = speed.Value / 100f; float num2 = 1f - num; if (!Object.op_Implicit((Object)(object)((EntityState)__instance).GetComponent<ScriptedCombatEncounter>())) { num *= 0.125f; num2 += num; } num *= OpeningLunar.duration; num2 = ((num2 == 0f) ? float.MaxValue : (1f / num2)); ((EntityState)__instance).fixedAge = ((EntityState)__instance).fixedAge + num; UpdateStopwatch(num); ((EntityState)__instance).GetModelAnimator().speed = num2; } } [HarmonyPatch(typeof(PurchaseInteraction), "OnInteractionBegin")] [HarmonyPrefix] private static void TryToInfest(PurchaseInteraction __instance) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ScriptedCombatEncounter>())) { if (!cradle.Value || Idle) { PurchaseDelay.Remove(__instance); } else { PurchaseDelay.Set(__instance, 1f - speed.Value / 95f, timed: false); } } } [HarmonyPatch(typeof(PurchaseInteraction), "OnInteractionBegin")] [HarmonyPrefix] private static void CleanseRapidly(PurchaseInteraction __instance) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (__instance.isShrine && (int)__instance.costType == 9) { if (!pool.Value || Idle) { PurchaseDelay.Remove(__instance); } else { PurchaseDelay.Set(__instance, 1f - speed.Value / 100f, timed: true); } } } [HarmonyPatch(typeof(PurchaseInteraction), "OnInteractionBegin")] [HarmonyPrefix] private static void CookSoup(PurchaseInteraction __instance) { if (__instance.contextToken == "BAZAAR_CAULDRON_CONTEXT") { if (!cauldron.Value || Idle) { PurchaseDelay.Remove(__instance); } else { PurchaseDelay.Set(__instance, 1f - speed.Value / 100f, timed: true); } } } private static void UpdateStopwatch(float time) { Run instance = Run.instance; if (penalty.Value) { bool? flag = ((instance != null) ? new bool?(instance.isRunStopwatchPaused) : null); if (flag.HasValue && !flag.GetValueOrDefault() && NetworkServer.active) { instance.SetRunStopwatch(instance.GetRunStopwatch() + time); } } } } }