using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FairyMode")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FairyMode")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a59b435c-4381-43ed-b572-6d201d67ef2d")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace FairyMode; [BepInPlugin("yazirushi.FairyMode", "FairyMode", "1.1.0")] public class FairyMode : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("yazirushi.FairyMode"); internal static ManualLogSource mls; public static ConfigEntry EnableMod; public static ConfigEntry StrengthBalance; public static ConfigEntry EnableLogging; private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown EnableMod = ((BaseUnityPlugin)this).Config.Bind("General", "Mod Enable", true, ""); StrengthBalance = ((BaseUnityPlugin)this).Config.Bind("General", "Strength Balance", 0.65f, new ConfigDescription("0 == Vanilla, 1 == Square Root. The higher the value, the more easily the upgrade power decays.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); EnableLogging = ((BaseUnityPlugin)this).Config.Bind("DebugLog", "Enable Logging", false, "Display debug logs"); mls = ((BaseUnityPlugin)this).Logger; mls.LogInfo((object)"Starting FairyMode..."); harmony.PatchAll(); } } [HarmonyPatch(typeof(PlayerController), "Update")] public class MainPatch { private static readonly FieldInfo fieldDeadSet = AccessTools.Field(typeof(PlayerAvatar), "deadSet"); private static readonly FieldInfo fieldTumble = AccessTools.Field(typeof(PlayerAvatar), "tumble"); private static readonly FieldInfo fieldPhysGrabObject = AccessTools.Field(typeof(PlayerTumble), "physGrabObject"); private static readonly FieldInfo fieldSemiAffect = AccessTools.Field(typeof(SemiAffectZeroGravity), "semiAffect"); private static readonly FieldInfo fieldTimer = AccessTools.Field(typeof(SemiAffect), "timer"); private static readonly FieldInfo fieldGrabbedPhysGrabObject = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject"); private static readonly FieldInfo fieldLevelAnimationCompleted = AccessTools.Field(typeof(LoadingUI), "levelAnimationCompleted"); private static float updateTimer = 0f; private static GameObject zeroGravityAffectPrefab; private static void Postfix() { //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown if (!FairyMode.EnableMod.Value || !SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel() || !CompleteLoading()) { return; } updateTimer -= Time.deltaTime; if (!(updateTimer <= 0f)) { return; } updateTimer = 0.5f; if (!TryGetPrefab()) { return; } foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { if ((Object)(object)item == (Object)null || PlayerIsDead(item)) { continue; } if ((Object)(object)item.activeZeroGravityAffect == (Object)null) { Vector3 position = ((Component)item).transform.position; PlayerTumble obj = (PlayerTumble)fieldTumble.GetValue(item); PhysGrabObject val = (PhysGrabObject)fieldPhysGrabObject.GetValue(obj); SemiAffect component = Object.Instantiate(zeroGravityAffectPrefab, position, Quaternion.identity).GetComponent(); component.direction = Vector3.up; component.positionOfOriginalAreaOfEffect = position; component.SetupSingleplayer(((Component)item).transform, val, 1f, item); item.activeZeroGravityAffect = ((Component)component).GetComponentInChildren(); if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)("add affect for " + SemiFunc.PlayerGetName(item))); } } else { SemiAffect obj2 = (SemiAffect)fieldSemiAffect.GetValue(item.activeZeroGravityAffect); fieldTimer.SetValue(obj2, 1f); } PhysGrabObject val2 = (PhysGrabObject)fieldGrabbedPhysGrabObject.GetValue(item.physGrabber); if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponent() == (Object)null) { val2.OverrideGrabStrength(Mathf.Lerp(item.physGrabber.grabStrength, Mathf.Sqrt(item.physGrabber.grabStrength), FairyMode.StrengthBalance.Value), 1f); } } } private static bool TryGetPrefab() { if ((Object)(object)zeroGravityAffectPrefab != (Object)null) { return true; } StatsManager.instance.itemDictionary.TryGetValue("Item Staff Zero Gravity", out var value); if ((Object)(object)value == (Object)null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"Failed TryGetPrefab() item == null"); } return false; } GameObject prefab = ((PrefabRef)(object)value.prefab).Prefab; if ((Object)(object)prefab == (Object)null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"Failed TryGetPrefab() gameObject == null"); } return false; } ItemStaffZeroGravity componentInChildren = prefab.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"Failed TryGetPrefab() staffZeroGravity == null"); } return false; } PrefabRef projectilePrefab = componentInChildren.projectilePrefab; if (projectilePrefab == null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"Failed TryGetPrefab() zeroGravityProjectile == null"); } return false; } SemiAreaOfEffect componentInChildren2 = ((PrefabRef)(object)projectilePrefab).Prefab.GetComponentInChildren(); if ((Object)(object)componentInChildren2 == (Object)null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"Failed TryGetPrefab() projectileSemiAreaOfEffect == null"); } return false; } SemiAffectZeroGravity componentInChildren3 = ((PrefabRef)(object)componentInChildren2.semiAffectPrefab).Prefab.GetComponentInChildren(); if ((Object)(object)componentInChildren3 == (Object)null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"Failed TryGetPrefab() affectZeroGravity == null"); } return false; } zeroGravityAffectPrefab = ((PrefabRef)(object)componentInChildren2.semiAffectPrefab).Prefab; return true; } private static bool PlayerIsDead(PlayerAvatar __player) { if ((Object)(object)__player == (Object)null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"player == null"); } return true; } return (bool)fieldDeadSet.GetValue(__player); } private static bool CompleteLoading() { if ((Object)(object)LoadingUI.instance == (Object)null) { if (FairyMode.EnableLogging.Value) { FairyMode.mls.LogInfo((object)"LoadingUI.instance == null"); } return false; } return (bool)fieldLevelAnimationCompleted.GetValue(LoadingUI.instance); } }