Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ChooseYourKarma v0.1.1
ChooseYourKarma.dll
Decompiled a month agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using RoR2.UI; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 Prototype { [BepInPlugin("prototype.karma.unlock", "ChooseYourKarma", "0.1.1")] internal class ChooseYourKarma : BaseUnityPlugin { private class Icon : MonoBehaviour { internal GameObject parent; } public const string version = "0.1.1"; public const string identifier = "prototype.karma.unlock"; protected void Awake() { Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); } private void OnLoad() { Language english = Language.english; english.SetStringByToken("RULE_HEADER_KARMA_SUBTITLE", "Selecting a <style=cLunarObjective>Karma</style> level will make the final boss fight more challenging."); english.SetStringByToken("RULE_KARMAENABLED_CHOICE_OFF_DESC", "This choice is not available, as <style=cLunarObjective>Karma</style> no longer increases over the course of the run."); } [HarmonyPatch(typeof(KarmaManager), "SelectValidTriggers")] [HarmonyPostfix] private static void SelectValidTriggers(KarmaManager __instance) { __instance.DiscardAllTriggers(); KarmaManager.onKarmaChangedClient -= __instance.NotifyKarmaIncreaseClient; } [HarmonyPatch(typeof(KarmaManager), "SetKarmaServer")] [HarmonyPostfix] private static void SetKarmaServer(KarmaManager __instance, int value) { if (value == 0) { __instance.NetworkisKarmaEnabled = false; } } [HarmonyPatch(typeof(RuleDef), "FromKarma")] [HarmonyPostfix] private static void FromKarma(RuleDef __result) { foreach (RuleChoiceDef choice in __result.choices) { object extraData = choice.extraData; if (extraData is int && (int)extraData == -1) { choice.excludeByDefault = true; } else { choice.requiredUnlockable = null; } } } [HarmonyPatch(typeof(EclipseRun), "OverrideRuleChoices")] [HarmonyPostfix] private static void OverrideRuleChoices(RuleChoiceMask mustInclude, RuleChoiceMask mustExclude) { foreach (RuleChoiceDef choice in RuleBook.startingKarmaRule.choices) { ((SerializableBitArray)mustInclude)[choice.globalIndex] = false; ((SerializableBitArray)mustExclude)[choice.globalIndex] = false; } } [HarmonyPatch(typeof(HUD), "Awake")] [HarmonyPostfix] private static void Awake(HUD __instance) { KarmaIcon componentInChildren = __instance.mainUIPanel.GetComponentInChildren<KarmaIcon>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { GameObject gameObject = ((Component)componentInChildren).gameObject; gameObject.SetActive(false); ((Component)__instance).gameObject.AddComponent<Icon>().parent = gameObject; } } [HarmonyPatch(typeof(HUD), "SetScoreboardState")] [HarmonyPostfix] private static void SetScoreboardState(HUD __instance, bool __0) { Icon icon = default(Icon); if (((Component)__instance).TryGetComponent<Icon>(ref icon) && Object.op_Implicit((Object)(object)icon.parent)) { icon.parent.SetActive(__0); } } } }