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 AlternateCrests v0.1.5
AltCrests.dll
Decompiled 8 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GlobalSettings; using HarmonyLib; using HutongGames.PlayMaker; using Microsoft.CodeAnalysis; 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: AssemblyCompany("AltCrests")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("AltCrests")] [assembly: AssemblyTitle("AltCrests")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/vice/AltCrests")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace AltCrests { [BepInPlugin("io.github.altcrests", "AltCrests", "0.1.0")] public class AltCrestsPlugin : BaseUnityPlugin { private enum ActiveCrest { MAIN_CREST, ALT_CREST } [HarmonyPatch(typeof(HealthManager), "TakeDamage")] private static class HealthManager_TakeDamage_Patch { private static bool ReturnTrue(string a, string b) { return true; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Reaper", (string)null) }).Advance(1).SetInstructionAndAdvance(Transpilers.EmitDelegate<Func<string, string, bool>>((Func<string, string, bool>)ReturnTrue)); ManualLogSource? log = Log; if (log != null) { log.LogInfo((object)"Successfully transpiled HealthManager.TakeDamage"); } return val.InstructionEnumeration(); } } [HarmonyPatch(typeof(HeroController), "Awake")] private static class HeroControllerPatch { private static void Postfix(HeroController __instance) { heroController = __instance; } } [HarmonyPatch(typeof(PlayMakerFSM), "Awake")] private static class PatchToolAttacksFSM { private static void Postfix(PlayMakerFSM __instance) { if ((Object)(object)__instance == (Object)null) { return; } FsmState state = __instance.Fsm.GetState("Flea Brew Burst"); if (state != null) { fleaBrewBurstState = state; originalFleaBrewAudio = state.Actions.OfType<PlayAudioEvent>().FirstOrDefault(); FsmState state2 = __instance.Fsm.GetState("Flea Brew Kickup"); if (state2 != null) { fleaBrewKickupState = state2; } } } } private const string HARMONY_ID = "com.vice.altcrests"; private static ActiveCrest activeCrest = ActiveCrest.MAIN_CREST; private static FsmState? fleaBrewBurstState = null; private static FsmState? fleaBrewKickupState = null; private static HeroController? heroController = null; private static PlayAudioEvent? originalFleaBrewAudio = null; private static AudioClip? Silk_HUD_evo_3 = null; private static AudioClip? hornet_flea_brew_effect_trigger = null; private static float crestSwapCooldownTimer = 0f; private static float crestSwapCooldown = 0.75f; private static int crestSwapSilkCost = 1; private ConfigEntry<string>? mainCrest; private ConfigEntry<string>? altCrest; private ConfigEntry<KeyCode>? keybind; private Dictionary<string, string> crestNames = new Dictionary<string, string>(); internal static ManualLogSource? Log; public const string Id = "io.github.altcrests"; public static string Name => "AltCrests"; public static string Version => "0.1.0"; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_004c: Expected O, but got Unknown //IL_004c: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0081: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.vice.altcrests").PatchAll(); keybind = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(new ConfigDefinition("AltCrests", "keybind"), (KeyCode)304, new ConfigDescription("Key for swapping crests. \nIf you're on a controller,I would recommend looking up a diagram of your controller's unity gamepad KeyCodes.\n", (AcceptableValueBase)null, Array.Empty<object>())); mainCrest = ((BaseUnityPlugin)this).Config.Bind<string>(new ConfigDefinition("AltCrests", "main_crest"), "hunter", new ConfigDescription("Crest names go here, lowercase.\n- hunter\n- wanderer\n- reaper\n- beast\n- architect\n- witch\n- shaman\n", (AcceptableValueBase)null, Array.Empty<object>())); altCrest = ((BaseUnityPlugin)this).Config.Bind<string>(new ConfigDefinition("AltCrests", "alt_crest"), "wanderer", (ConfigDescription)null); crestNames.Add("hunter", "Hunter"); crestNames.Add("wanderer", "Wanderer"); crestNames.Add("reaper", "Reaper"); crestNames.Add("beast", "Warrior"); crestNames.Add("architect", "Toolmaster"); crestNames.Add("witch", "Witch"); crestNames.Add("shaman", "Spell"); if (!crestNames.ContainsKey(mainCrest.Value)) { Log.LogError((object)(mainCrest.Value + " is not a valid crest! (Did you type the name correctly?)")); } if (!crestNames.ContainsKey(altCrest.Value)) { Log.LogError((object)(altCrest.Value + " is not a valid crest! (Did you type the name correctly?)")); } Log.LogInfo((object)("Plugin " + Name + " (io.github.altcrests) has loaded!")); } private void Update() { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) if (fleaBrewBurstState == null || fleaBrewKickupState == null || (Object)(object)heroController == (Object)null || originalFleaBrewAudio == null) { return; } PlayAudioEvent val = fleaBrewBurstState.actions.OfType<PlayAudioEvent>().FirstOrDefault(); if (heroController.toolsFSM.ActiveStateName == "Idle") { fleaBrewBurstState.Actions[2].enabled = true; if ((Object)(object)hornet_flea_brew_effect_trigger != (Object)null) { originalFleaBrewAudio.audioClip = FsmObject.op_Implicit((Object)(object)hornet_flea_brew_effect_trigger); ((PlayAudioEventBase)fleaBrewBurstState.Actions.OfType<PlayAudioEvent>().FirstOrDefault()).volume = FsmFloat.op_Implicit(1f); } } crestSwapCooldownTimer -= Time.deltaTime; if (!Input.GetKeyDown(keybind.Value)) { return; } ((BaseUnityPlugin)this).Config.Reload(); if (!crestNames.ContainsKey(mainCrest.Value)) { Log.LogError((object)(mainCrest.Value + " is not a valid crest! (Did you type the name correctly?)")); } else if (!crestNames.ContainsKey(altCrest.Value)) { ManualLogSource? log = Log; if (log != null) { log.LogError((object)(altCrest.Value + " is not a valid crest! (Did you type the name correctly?)")); } } else { if (PlayerData.instance.CurrentCrestID == "Cursed" || PlayerData.instance.CurrentCrestID == "Cloakless" || !heroController.CanAttack() || crestSwapCooldownTimer > 0f) { return; } heroController.toolsFSM.SetState("Take Control"); heroController.toolsFSM.SetState("Flea Brew Kickup"); fleaBrewBurstState.Actions[2].enabled = false; AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>(); for (int i = 0; i < array.Length; i++) { if (((Object)array[i]).name == "Silk_HUD_evo_3") { Silk_HUD_evo_3 = array[i]; } if (((Object)array[i]).name == "hornet_flea_brew_effect_trigger") { hornet_flea_brew_effect_trigger = array[i]; } } ((PlayAudioEventBase)fleaBrewBurstState.Actions.OfType<PlayAudioEvent>().FirstOrDefault()).volume = FsmFloat.op_Implicit(0.8f); if ((Object)(object)Silk_HUD_evo_3 != (Object)null) { val.audioClip = FsmObject.op_Implicit((Object)(object)Silk_HUD_evo_3); } else { ManualLogSource? log2 = Log; if (log2 != null) { log2.LogWarning((object)"Silk_HUD_evo_3 was null"); } } crestSwapCooldownTimer = crestSwapCooldown; heroController.TakeSilk(crestSwapSilkCost); if (Gameplay.HunterCrest2.IsUnlocked) { crestNames.Remove("hunter"); crestNames.Add("hunter", Gameplay.HunterCrest2.name); } if (Gameplay.HunterCrest3.IsUnlocked) { crestNames.Remove("hunter"); crestNames.Add("hunter", Gameplay.HunterCrest3.name); } bool isInRageMode = HeroController.instance.warriorState.IsInRageMode; float rageEffectTimeLeft = HeroController.instance.warriorState.RageEffectTimeLeft; int rageModeHealCount = HeroController.instance.warriorState.RageModeHealCount; float rageHealTimeLeft = HeroController.instance.warriorState.RageHealTimeLeft; int lastHealAttack = HeroController.instance.warriorState.LastHealAttack; bool isInReaperMode = HeroController.instance.reaperState.IsInReaperMode; float reaperModeDurationLeft = HeroController.instance.reaperState.ReaperModeDurationLeft; if (activeCrest == ActiveCrest.MAIN_CREST) { ToolItemManager.AutoEquip(ToolItemManager.GetCrestByName(crestNames[altCrest.Value]), false, false); activeCrest = ActiveCrest.ALT_CREST; } else { ToolItemManager.AutoEquip(ToolItemManager.GetCrestByName(crestNames[mainCrest.Value]), false, false); activeCrest = ActiveCrest.MAIN_CREST; } if (isInRageMode) { HeroController.instance.warriorState.IsInRageMode = isInRageMode; HeroController.instance.warriorState.RageEffectTimeLeft = rageEffectTimeLeft; HeroController.instance.warriorState.RageHealTimeLeft = rageHealTimeLeft; HeroController.instance.warriorState.RageModeHealCount = rageModeHealCount; HeroController.instance.warriorState.LastHealAttack = lastHealAttack; ToolCrest crestByName = ToolItemManager.GetCrestByName((activeCrest == ActiveCrest.MAIN_CREST) ? crestNames[mainCrest.Value] : crestNames[altCrest.Value]); if (crestByName.HeroConfig.GetAnimationClip("Rage Idle") == null) { ManualLogSource? log3 = Log; if (log3 != null) { log3.LogInfo((object)("Rage Idle is not on " + crestByName.name + " crest! Patching...")); } tk2dSpriteAnimationClip animationClip = ToolItemManager.GetCrestByName("Warrior").HeroConfig.GetAnimationClip("Rage Idle"); tk2dSpriteAnimationClip animationClip2 = ToolItemManager.GetCrestByName("Warrior").HeroConfig.GetAnimationClip("Rage Idle End"); int num = crestByName.HeroConfig.heroAnimOverrideLib.clips.Length; int id = num + 1; CollectionExtensions.AddItem<tk2dSpriteAnimationClip>((IEnumerable<tk2dSpriteAnimationClip>)crestByName.HeroConfig.heroAnimOverrideLib.clips, animationClip); CollectionExtensions.AddItem<tk2dSpriteAnimationClip>((IEnumerable<tk2dSpriteAnimationClip>)crestByName.HeroConfig.heroAnimOverrideLib.clips, animationClip2); crestByName.HeroConfig.heroAnimOverrideLib.lookup.Add(animationClip.name, new AnimationInfo { clip = animationClip, id = num }); crestByName.HeroConfig.heroAnimOverrideLib.lookup.Add(animationClip2.name, new AnimationInfo { clip = animationClip2, id = id }); ManualLogSource? log4 = Log; if (log4 != null) { log4.LogInfo((object)("Patched " + crestByName.name + " crest.")); } } StatusVignette.AddStatus((StatusTypes)3); Transform val2 = ((Component)heroController).gameObject.transform.Find("crest_warrior_effects(Clone)"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(true); } else { ManualLogSource? log5 = Log; if (log5 != null) { log5.LogWarning((object)"crest_warrior_effects was not found"); } } } if (isInReaperMode) { HeroController.instance.reaperState.IsInReaperMode = true; HeroController.instance.reaperState.ReaperModeDurationLeft = reaperModeDurationLeft; if (Object.op_Implicit((Object)(object)HeroController.instance.reaperModeEffect)) { ((Component)HeroController.instance.reaperModeEffect).gameObject.SetActive(false); ((Component)HeroController.instance.reaperModeEffect).gameObject.SetActive(true); } } HeroController.instance.UpdateSilkCursed(); } } } }