Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of JoshyStopwatch v1.3.0
ExamplePlugin.dll
Decompiled a year agousing System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using On.RoR2; using R2API; using Rewired.Utils; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; [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.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("ExamplePlugin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ExamplePlugin")] [assembly: AssemblyTitle("ExamplePlugin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ExamplePlugin; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Quickjoshy.JoshyModPack", "Joshy's ModPack", "1.0.0")] public class ExamplePlugin : BaseUnityPlugin { public const string PluginGUID = "Quickjoshy.JoshyModPack"; public const string PluginAuthor = "Quickjoshy"; public const string PluginName = "Joshy's ModPack"; public const string PluginVersion = "1.0.0"; public static ItemDef stopwatch; private int stopwatchTime = 60; private bool spreeActive = false; private Coroutine StopwatchCoroutine; public static PluginInfo PInfo { get; private set; } public void Awake() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown PInfo = ((BaseUnityPlugin)this).Info; Assets.Init(); Log.Init(((BaseUnityPlugin)this).Logger); stopwatch = ScriptableObject.CreateInstance<ItemDef>(); ((Object)stopwatch).name = "JOSHY_STOPWATCH"; stopwatch.nameToken = "Joshy's Stopwatch"; stopwatch.pickupToken = "At the beginning of each stage, gain 1 minute of free purchases per stopwatch"; stopwatch.descriptionToken = "At the beginning of each stage, gain 1 minute of free purchases per stopwatch"; stopwatch.loreToken = "Where's my stopwatch?"; stopwatch._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion(); stopwatch.pickupIconSprite = Assets.StopwatchIcon; stopwatch.pickupModelPrefab = Assets.StopwatchPrefab; stopwatch.canRemove = true; stopwatch.hidden = false; stopwatch.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)3 }; ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null); ItemAPI.Add(new CustomItem(stopwatch, val)); Stage.onServerStageBegin += stopwatch_stageBegin; PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(StopWatchPurchaseEvent); Stage.onServerStageComplete += Stopwatch_StageFinish; } private void Stopwatch_StageFinish(Stage stage) { if (!ExtensionMethods.IsNullOrDestroyed((object)StopwatchCoroutine)) { spreeActive = false; ((MonoBehaviour)this).StopCoroutine(StopwatchCoroutine); Log.Info("Stopwatch Coroutine stopped!"); } } private void StopWatchPurchaseEvent(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 int cost = self.cost; CharacterBody component = ((Component)activator).GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component) && component.inventory.GetItemCount(stopwatch.itemIndex) > 0 && ((int)self.costType == 1 || (int)self.costType == 3) && spreeActive) { self.cost = 0; } orig.Invoke(self, activator); } private void stopwatch_stageBegin(Stage stage) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) Log.Info("Log test 1"); CharacterMaster master = PlayerCharacterMasterController.instances[0].master; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { master = instance.master; int itemCount = master.inventory.GetItemCount(stopwatch.itemIndex); if (itemCount > 0) { StopwatchCoroutine = ((MonoBehaviour)this).StartCoroutine(stopwatch_CountDown(itemCount, master)); } } } private IEnumerator stopwatch_CountDown(int count, CharacterMaster master) { int time = count * stopwatchTime; master.money += 1000000000; float timer = 0f; spreeActive = true; for (; timer < (float)time; timer += Time.deltaTime) { yield return (object)new WaitForEndOfFrame(); } if (master.money < 1000000000) { master.money = 0u; } else { master.money -= 1000000000; } spreeActive = false; } private void Update() { } } public static class Assets { public static AssetBundle mainBundle; public const string bundleName = "stopwatchbundle"; public static GameObject StopwatchPrefab; public static Sprite StopwatchIcon; public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(ExamplePlugin.PInfo.Location), "stopwatchbundle"); public static void Init() { mainBundle = AssetBundle.LoadFromFile(AssetBundlePath); StopwatchPrefab = mainBundle.LoadAsset<GameObject>("Stopwatch.prefab"); StopwatchIcon = mainBundle.LoadAsset<Sprite>("StopwatchIcon.png"); } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } }