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 HitlessMode v0.1.0
plugins/HitlessMode.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; 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 HutongGames.PlayMaker; using Microsoft.CodeAnalysis; using SkongGamemodes; using TeamCherry.Localization; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HitlessMode")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+4ea47612ffad977e464eb5f791d77a36944a72f7")] [assembly: AssemblyProduct("HitlessMode")] [assembly: AssemblyTitle("HitlessMode")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/CarrieForle/HitlessModeSilksong")] [assembly: NeutralResourcesLanguage("en")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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")] [Microsoft.CodeAnalysis.Embedded] 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")] [Microsoft.CodeAnalysis.Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace HitlessMode { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("io.github.carrieforle.hitlessmode", "HitlessMode", "0.1.0")] public class HitlessModePlugin : BaseUnityPlugin { internal static ConfigEntry<bool> ConfigShowHp; internal static ManualLogSource Logger; private bool inFirstBindPrompt; private GameObject eventGo; private Transform? hp; internal const bool ConfigDontDie = false; internal const bool ConfigApplyAllModes = false; public const string Id = "io.github.carrieforle.hitlessmode"; internal static GameModeData FragileMode { get; private set; } internal static GameModeData GlassMode { get; private set; } internal static bool IsCustomMode { get { if (!FragileMode.Enabled) { return GlassMode.Enabled; } return true; } } private Transform? Hp { get { if ((Object)(object)hp == (Object)null) { hp = ((Component)GameCameras.SilentInstance.hudCanvasSlideOut).transform.Find("Health"); PatchBlueHealthFsm(); } return hp; } set { hp = value; } } public static string Name => "HitlessMode"; public static string Version => "0.1.0"; private void Start() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; eventGo = new GameObject("HideHealthEventRegister"); Object.DontDestroyOnLoad((Object)(object)eventGo); EventRegister obj = eventGo.AddComponent<EventRegister>(); obj.SwitchEvent("HUD COMING IN"); ((EventBase)obj).ReceivedEvent += TryHideHealth; EventRegister obj2 = eventGo.AddComponent<EventRegister>(); obj2.SwitchEvent("HERO RESPAWNED"); ((EventBase)obj2).ReceivedEvent += TryHideHealth; EventRegister obj3 = eventGo.AddComponent<EventRegister>(); obj3.SwitchEvent("SPOOL APPEAR"); ((EventBase)obj3).ReceivedEvent += TryHideHealth; new Harmony("io.github.carrieforle.hitlessmode").PatchAll(); ConfigShowHp = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowHp", false, LocalisedString.op_Implicit(Localized("SHOW_HP_OPTION"))); FragileMode = GameModeManagerPlugin.Instance.Manager.Init((MonoBehaviour)(object)this, "Fragile Soul", LocalisedString.op_Implicit(Localized("FRAGILE_MODE_DESCRIPTION")), (Color?)null, false, (Sprite)null); GlassMode = GameModeManagerPlugin.Instance.Manager.Init((MonoBehaviour)(object)this, "Glass Soul", LocalisedString.op_Implicit(Localized("GLASS_MODE_DESCRIPTION")), (Color?)null, true, (Sprite)null); } internal void TryHideBlueHealth() { if (IsCustomMode && !ConfigShowHp.Value && !((Object)(object)Hp == (Object)null)) { ToggleBlueHealthRenderer(enable: false); } } private void TryHideHealth() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!IsCustomMode || ConfigShowHp.Value || (Object)(object)Hp == (Object)null) { return; } ToggleHealthRenderer(enable: false); foreach (Transform item in Hp) { GameObject gameObject = ((Component)item).gameObject; if (((Object)gameObject).name == "Health 1") { Transform val = gameObject.transform.Find("Fractured Mask"); if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(false); Logger.LogDebug((object)"Disabled Fractured Mask"); } } } } private Sprite? LoadSpriteFromFile(string filePath) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), filePath); Sprite val = null; try { byte[] array = File.ReadAllBytes(text); Texture2D val2 = new Texture2D(0, 0); if (ImageConversion.LoadImage(val2, array)) { Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); val = Sprite.Create(val2, val3, val4); } } catch { } if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Failed to load sprite frorm \"" + text + "\"")); } return val; } private void ToggleBlueHealthRenderer(bool enable) { ToggleRenderer("Blue Health", enable); } private void ToggleHealthRenderer(bool enable) { ToggleRenderer("Health", enable); } private void ToggleRenderer(string name, bool enable) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Hp == (Object)null) { return; } int num = 0; foreach (Transform item in Hp) { GameObject gameObject = ((Component)item).gameObject; if (((Object)gameObject).name.StartsWith(name)) { MeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<MeshRenderer>(true); MeshRenderer[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { ((Renderer)array[i]).enabled = enable; } num += componentsInChildren.Length; } } Logger.LogDebug((object)$"Toggle({enable}) {num} \"{name}\" renderer"); } private void PatchBlueHealthFsm() { if ((Object)(object)Hp == (Object)null) { return; } PlayMakerFSM val = ((IEnumerable<PlayMakerFSM>)((Component)Hp).GetComponents<PlayMakerFSM>()).FirstOrDefault((Func<PlayMakerFSM, bool>)((PlayMakerFSM fsm) => fsm.FsmName == "Blue Health Control")); if (!((Object)(object)val == (Object)null)) { FsmState val2 = ((IEnumerable<FsmState>)val.fsm.States).FirstOrDefault((Func<FsmState, bool>)((FsmState s) => s.name == "REALLY Approaching Max?")); if (val2 != null) { HideBlueHealthAction hideBlueHealthAction = new HideBlueHealthAction(this); FsmStateAction val3 = (FsmStateAction)(object)hideBlueHealthAction; FsmStateAction[] actions = val2.actions; int num = 0; FsmStateAction[] array = (FsmStateAction[])(object)new FsmStateAction[1 + actions.Length]; array[num] = val3; num++; ReadOnlySpan<FsmStateAction> readOnlySpan = new ReadOnlySpan<FsmStateAction>(actions); readOnlySpan.CopyTo(new Span<FsmStateAction>(array).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; val2.actions = array; ((FsmStateAction)hideBlueHealthAction).Init(val2); Logger.LogDebug((object)"Patched Blue Health FSM"); } } } internal static LocalisedString Localized(string key) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return new LocalisedString("Mods.io.github.carrieforle.hitlessmode", key); } internal static bool IsSlotCustomMode(int saveSlotIndex) { if (PlayerPrefs.GetInt($"{GlassMode.Name}_{saveSlotIndex}") != 1) { return PlayerPrefs.GetInt($"{FragileMode.Name}_{saveSlotIndex}") == 1; } return true; } } internal class HideBlueHealthAction : FsmStateAction { [CompilerGenerated] private HitlessModePlugin <plugin>P; public HideBlueHealthAction(HitlessModePlugin plugin) { <plugin>P = plugin; ((FsmStateAction)this)..ctor(); } public override void OnEnter() { <plugin>P.TryHideBlueHealth(); ((FsmStateAction)this).Finish(); } } [HarmonyPatch(typeof(PlayerData), "TakeHealth")] internal class Patch_DieInOneHit { private static void Postfix(PlayerData __instance, ref int amount, ref bool hasBlueHealth, ref bool allowFracturedMaskBreak) { if (HitlessModePlugin.IsCustomMode) { __instance.health = 0; } } } [HarmonyPatch(typeof(SaveSlotButton), "PresentSaveSlot")] internal class Patch_ZeroProfileHealthBar { private static void Postfix(SaveSlotButton __instance) { if (HitlessModePlugin.ConfigShowHp.Value || !HitlessModePlugin.IsSlotCustomMode(__instance.SaveSlotIndex)) { return; } foreach (Image healthImage in __instance.healthSlots.healthImages) { ((Component)healthImage).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(EventRegister), "SendEvent", new Type[] { typeof(string), typeof(GameObject) })] internal class Patch_EventRegister { private static void Postfix(EventRegister __instance, string eventName, GameObject excludeGameObject) { string text = (((Object)(object)excludeGameObject != (Object)null) ? ((object)excludeGameObject).ToString() : "null"); HitlessModePlugin.Logger.LogDebug((object)("EventRegister.SendEvent(\"" + eventName + "\", " + text + ")")); } } }