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 MurphysFanControl v1.4.2
plugins/MurphysFanControl.dll
Decompiled an hour agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; 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: AssemblyCompany("MurphysFanControl")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.1.0")] [assembly: AssemblyInformationalVersion("1.4.1")] [assembly: AssemblyProduct("MurphysFanControl")] [assembly: AssemblyTitle("MurphysFanControl")] [assembly: AssemblyVersion("1.4.1.0")] namespace MurphysFanControl; [BepInPlugin("Murphy.Dev.MurphysFanControl", "Murphy's Fan Control", "1.4.1")] public sealed class FanControl : BaseUnityPlugin { [HarmonyPatch(typeof(FanTrap), "Start")] private static class RegisterFan { private static void Postfix(FanTrap __instance, HurtCollider ___hurtCollider) { if (Object.op_Implicit((Object)(object)___hurtCollider)) { FanColliders.Remove(___hurtCollider); FanColliders.Add(___hurtCollider, __instance); } } } [HarmonyPatch] private static class BladeSpeed { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(FanTrap), "Update", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(FanTrap), "FixedUpdate", (Type[])null, (Type[])null); } private static void Prefix(ref float ___fanBladeMaxSpeed, out float? __state) { __state = null; if (ControlsActive && plugin.EffectiveBladeSpeed != 1f) { __state = ___fanBladeMaxSpeed; ___fanBladeMaxSpeed *= plugin.EffectiveBladeSpeed; } } private static void Finalizer(ref float ___fanBladeMaxSpeed, float? __state) { if (__state.HasValue) { ___fanBladeMaxSpeed = __state.Value; } } } [HarmonyPatch(typeof(HurtCollider), "PlayerHurt")] private static class PlayerWind { private static bool Prefix(HurtCollider __instance, ref float ___playerHitForce, ref float ___playerTumbleForce, out (float Hit, float Tumble)? __state) { __state = null; if (!ControlsActive || !IsFanWind(__instance)) { return true; } float effectivePushPower = plugin.EffectivePushPower; if (!plugin.pushPlayers.Value || effectivePushPower == 0f) { return false; } if (effectivePushPower == 1f) { return true; } __state = (___playerHitForce, ___playerTumbleForce); ___playerHitForce *= effectivePushPower; ___playerTumbleForce *= effectivePushPower; return true; } private static void Finalizer(ref float ___playerHitForce, ref float ___playerTumbleForce, (float Hit, float Tumble)? __state) { if (__state.HasValue) { ___playerHitForce = __state.Value.Hit; ___playerTumbleForce = __state.Value.Tumble; } } } [HarmonyPatch(typeof(HurtCollider), "PhysObjectHurt")] private static class ItemWind { private static bool Prefix(HurtCollider __instance, PhysGrabObject __0, ref float __2, ref bool __result) { if (!ControlsActive || !IsFanWind(__instance)) { return true; } bool num = ((Object.op_Implicit((Object)(object)__0) && Object.op_Implicit((Object)(object)((Component)__0).GetComponentInParent<PlayerTumble>())) ? plugin.pushPlayers.Value : plugin.pushItems.Value); float effectivePushPower = plugin.EffectivePushPower; if (!num || effectivePushPower == 0f) { __result = false; return false; } __2 *= effectivePushPower; return true; } } [HarmonyPatch(typeof(FanTrap), "Start")] private static class RegisterFanBody { private static void Postfix(FanTrap __instance, PhysGrabObject ___physgrabobject) { PhysGrabObject val = (Object.op_Implicit((Object)(object)___physgrabobject) ? ___physgrabobject : ((Component)__instance).GetComponentInParent<PhysGrabObject>()); if (Object.op_Implicit((Object)(object)val)) { FanBodies.Remove(val); FanBodies.Add(val, __instance); } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnCollisionStay", new Type[] { typeof(Collision) })] private static class SuperFanCollision { private static void Postfix(Collision __0, PhysGrabObject ___physGrabObject) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011b: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if (!ContactActive || !Object.op_Implicit((Object)(object)___physGrabObject) || !FanBodies.TryGetValue(___physGrabObject, out var value) || !Object.op_Implicit((Object)(object)value)) { return; } Collider collider = __0.collider; PlayerAvatar val = (Object.op_Implicit((Object)(object)collider) ? FindPlayer(collider) : null); if (!Object.op_Implicit((Object)(object)val) || isPlayerDisabled.Invoke(val)) { return; } PlayerTumble val2 = getTumble.Invoke(val); if (!Object.op_Implicit((Object)(object)val2)) { return; } ContactCooldown orCreateValue = ContactCooldowns.GetOrCreateValue(val); if (!(Time.time < orCreateValue.Until)) { orCreateValue.Until = Time.time + 4f; Vector3 val3 = Vector3.ProjectOnPlane(((Component)val).transform.position - ((Component)value).transform.position, Vector3.up); if (((Vector3)(ref val3)).sqrMagnitude < 0.001f) { val3 = Vector3.ProjectOnPlane(((Component)value).transform.forward, Vector3.up); } if (((Vector3)(ref val3)).sqrMagnitude < 0.001f) { val3 = Vector3.forward; } Vector3 val4 = ((Vector3)(ref val3)).normalized + Vector3.up * 0.45f; Vector3 force = ((Vector3)(ref val4)).normalized * 250f; requestTumble(val2, arg2: true, arg3: false); ((MonoBehaviour)plugin).StartCoroutine(LaunchWhenTumbling(val, val2, force)); } } } private sealed class ContactCooldown { public float Until; } private const string PluginId = "Murphy.Dev.MurphysFanControl"; private const float DefaultMultiplier = 1f; private const float MaxMultiplier = 20f; private const float MinBladeSpeed = 0.25f; private const float MinPushPower = 0f; private const float SuperBladeSpeed = 8f; private const float SuperPushPower = 100f; private static FanControl plugin; private Harmony harmony; private bool hooksReady; private bool menuOpen; private bool controlsCursor; private CursorLockMode previousCursorLock; private bool previousCursorVisible; private ConfigEntry<KeyCode> menuKey; private ConfigEntry<KeyCode> cursorKey; private ConfigEntry<bool> enabledOverride; private ConfigEntry<bool> superFan; private ConfigEntry<float> bladeSpeed; private ConfigEntry<float> pushPower; private ConfigEntry<bool> pushItems; private ConfigEntry<bool> pushPlayers; private static readonly ConditionalWeakTable<HurtCollider, FanTrap> FanColliders = new ConditionalWeakTable<HurtCollider, FanTrap>(); private static FieldRef<FanTrap, HurtCollider> getFanCollider; private const int WindowId = 1840225531; private const float PanelWidth = 416f; private static readonly Color Panel = Color32.op_Implicit(new Color32((byte)16, (byte)20, (byte)33, byte.MaxValue)); private static readonly Color Surface = Color32.op_Implicit(new Color32((byte)26, (byte)33, (byte)52, byte.MaxValue)); private static readonly Color Text = Color32.op_Implicit(new Color32((byte)243, (byte)246, byte.MaxValue, byte.MaxValue)); private static readonly Color Muted = Color32.op_Implicit(new Color32((byte)164, (byte)177, (byte)205, byte.MaxValue)); private static readonly Color Pink = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)87, (byte)181, byte.MaxValue)); private static readonly Color Blue = Color32.op_Implicit(new Color32((byte)116, (byte)199, byte.MaxValue, byte.MaxValue)); private Rect window = new Rect(32f, 84f, 416f, 350f); private GUIStyle titleStyle; private GUIStyle labelStyle; private GUIStyle secondaryStyle; private GUIStyle valueStyle; private bool waitingForMenuKey; private string menuKeyPrompt; private const float ContactLaunchForce = 250f; private const float ContactTumbleSeconds = 3f; private const int ContactImpactDamage = 60; private const float ContactCooldownSeconds = 4f; private static readonly ConditionalWeakTable<PhysGrabObject, FanTrap> FanBodies = new ConditionalWeakTable<PhysGrabObject, FanTrap>(); private static readonly ConditionalWeakTable<PlayerAvatar, ContactCooldown> ContactCooldowns = new ConditionalWeakTable<PlayerAvatar, ContactCooldown>(); private static FieldRef<PlayerAvatar, PlayerTumble> getTumble; private static FieldRef<PlayerAvatar, bool> isPlayerDisabled; private static FieldRef<PlayerTumble, bool> isTumbling; private static FieldRef<PlayerTumble, PlayerAvatar> getTumbleOwner; private static FieldRef<PlayerAvatarCollision, PlayerAvatar> getCollisionOwner; private static Action<PlayerTumble, bool, bool> requestTumble; private static Action<PlayerTumble, float> holdTumble; private static Action<PlayerTumble, float, int> armImpactDamage; private static Action<PlayerTumble, Vector3> applyTumbleForce; private bool contactHooksReady; private float EffectiveBladeSpeed { get { if (!superFan.Value) { return bladeSpeed.Value; } return 8f; } } private float EffectivePushPower { get { if (!superFan.Value) { return pushPower.Value; } return 100f; } } private static bool ControlsActive { get { if ((Object)(object)plugin != (Object)null && plugin.hooksReady && ((Behaviour)plugin).isActiveAndEnabled && plugin.enabledOverride.Value) { return SemiFunc.IsMasterClientOrSingleplayer(); } return false; } } private static bool ContactActive { get { if (ControlsActive && plugin.contactHooksReady && plugin.superFan.Value) { return plugin.pushPlayers.Value; } return false; } } private void Awake() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) menuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MenuKey", (KeyCode)289, "Open or close Fan Control."); cursorKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "CursorKey", (KeyCode)308, "Hold to free the cursor for the Open tab."); enabledOverride = ((BaseUnityPlugin)this).Config.Bind<bool>("Fan", "Enabled", true, "Apply the fan controls."); superFan = ((BaseUnityPlugin)this).Config.Bind<bool>("Fan", "SuperFan", false, "Use the Super Fan speed and force preset."); bladeSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fan", "BladeSpeed", 1f, new ConfigDescription("Fan blade speed multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 20f), Array.Empty<object>())); pushPower = ((BaseUnityPlugin)this).Config.Bind<float>("Fan", "PushPower", 1f, new ConfigDescription("Wind force multiplier for enabled targets.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); pushItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Fan", "PushItems", true, "Wind pushes physics items."); pushPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Fan", "PushPlayers", true, "Wind pushes players, including tumbling players."); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; plugin = this; harmony = new Harmony("Murphy.Dev.MurphysFanControl"); try { getFanCollider = AccessTools.FieldRefAccess<FanTrap, HurtCollider>("hurtCollider"); harmony.CreateClassProcessor(typeof(RegisterFan)).Patch(); harmony.CreateClassProcessor(typeof(BladeSpeed)).Patch(); harmony.CreateClassProcessor(typeof(PlayerWind)).Patch(); harmony.CreateClassProcessor(typeof(ItemWind)).Patch(); hooksReady = true; InstallSuperFanContact(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Fan Control ready. Menu key: " + ((object)menuKey.Value/*cast due to .constrained prefix*/).ToString())); } catch (Exception ex) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)("Fan Control could not attach to this R.E.P.O. build: " + ex)); } } private void Update() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!waitingForMenuKey && (int)menuKey.Value != 0 && Input.GetKeyDown(menuKey.Value)) { SetMenuOpen(!menuOpen); } } private void LateUpdate() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) bool flag = (int)cursorKey.Value != 0 && Input.GetKey(cursorKey.Value); SetCursorReleased(Application.isFocused && (menuOpen || flag)); } private void SetCursorReleased(bool released) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (controlsCursor != released) { if (released) { previousCursorLock = Cursor.lockState; previousCursorVisible = Cursor.visible; } else { Cursor.lockState = previousCursorLock; Cursor.visible = previousCursorVisible; } controlsCursor = released; } if (controlsCursor) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void SetMenuOpen(bool open) { if (menuOpen != open) { menuOpen = open; if (!open) { waitingForMenuKey = false; menuKeyPrompt = null; ((BaseUnityPlugin)this).Config.Save(); } } } private void OnDisable() { SetCursorReleased(released: false); SetMenuOpen(open: false); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if ((Object)(object)plugin == (Object)(object)this) { plugin = null; } } private static bool IsFanWind(HurtCollider collider) { if (FanColliders.TryGetValue(collider, out var value) && Object.op_Implicit((Object)(object)value)) { return true; } value = ((Component)collider).GetComponentInParent<FanTrap>(); if (Object.op_Implicit((Object)(object)value)) { return (Object)(object)getFanCollider.Invoke(value) == (Object)(object)collider; } return false; } private void OnGUI() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0047: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (titleStyle == null) { titleStyle = TextStyle(24, Text, (TextAnchor)3, (FontStyle)1); labelStyle = TextStyle(14, Text, (TextAnchor)3, (FontStyle)1); secondaryStyle = TextStyle(12, Muted, (TextAnchor)3, (FontStyle)0); valueStyle = TextStyle(15, Blue, (TextAnchor)5, (FontStyle)1); } if (!menuOpen) { DrawOpenTab(); return; } CaptureMenuKey(Event.current); ((Rect)(ref window)).height = ((hooksReady && SemiFunc.IsMasterClientOrSingleplayer()) ? 350f : 185f); ((Rect)(ref window)).x = Mathf.Clamp(((Rect)(ref window)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref window)).width)); ((Rect)(ref window)).y = Mathf.Clamp(((Rect)(ref window)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref window)).height)); window = GUI.Window(1840225531, window, new WindowFunction(DrawMenu), string.Empty, GUIStyle.none); } private void DrawOpenTab() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) float num = (float)Screen.width - 88f - 12f; float num2 = ((float)Screen.height - 34f) / 2f; if (GUI.Button(new Rect(num, num2, 88f, 34f), "Open")) { SetMenuOpen(open: true); } if (((int)Cursor.lockState != 0 || !Cursor.visible) && (int)cursorKey.Value != 0) { string text = (((int)cursorKey.Value == 308) ? "Left Alt" : ((object)cursorKey.Value/*cast due to .constrained prefix*/).ToString()); GUI.Label(new Rect(num, num2 + 34f + 2f, 88f, 18f), "Hold " + text, secondaryStyle); } } private void DrawMenu(int id) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) Fill(new Rect(0f, 0f, 416f, ((Rect)(ref window)).height), Panel); for (int i = 0; i < 26; i++) { Fill(new Rect((float)(i * 16), 0f, 16f, 3f), Color.Lerp(Pink, Blue, (float)i / 25f)); } GUI.Label(new Rect(18f, 12f, 250f, 32f), "Fan Control", titleStyle); GUI.Label(new Rect(19f, 45f, 240f, 20f), "MurphysLavv Menu", secondaryStyle); GUI.Label(new Rect(253f, 45f, 150f, 20f), "created by Murphy.Dev", secondaryStyle); if (GUI.Button(new Rect(374f, 14f, 25f, 25f), "×")) { SetMenuOpen(open: false); } DrawToggleKey(); if (!hooksReady) { DrawNotice("Fan controls unavailable", "Check the BepInEx log for the startup error."); } else if (!SemiFunc.IsMasterClientOrSingleplayer()) { DrawNotice("Lobby guest", "The host controls the fans. You can adjust them in solo play."); } else { DrawControls(); } GUI.DragWindow(new Rect(0f, 3f, 366f, 64f)); } private void DrawToggleKey() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) string text = (waitingForMenuKey ? menuKeyPrompt : ("Toggle key: " + ((object)menuKey.Value/*cast due to .constrained prefix*/).ToString())); if (GUI.Button(new Rect(18f, 73f, 242f, 24f), text)) { waitingForMenuKey = !waitingForMenuKey; menuKeyPrompt = (waitingForMenuKey ? "Press a key (Esc cancels)" : null); } } private void CaptureMenuKey(Event current) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_002c: 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_005f: Unknown result type (might be due to invalid IL or missing references) if (!waitingForMenuKey || (int)current.type != 4 || (int)current.keyCode == 0) { return; } KeyCode keyCode = current.keyCode; current.Use(); if ((int)keyCode != 27 && keyCode == cursorKey.Value) { menuKeyPrompt = "Cursor key in use. Choose another."; return; } waitingForMenuKey = false; menuKeyPrompt = null; if ((int)keyCode != 27) { menuKey.Value = keyCode; ((BaseUnityPlugin)this).Config.Save(); } } private void DrawControls() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) enabledOverride.Value = GUI.Toggle(new Rect(277f, 72f, 122f, 25f), enabledOverride.Value, "Controls enabled"); Fill(new Rect(18f, 105f, 380f, 52f), Surface); Fill(new Rect(18f, 105f, 3f, 52f), (superFan.Value && enabledOverride.Value) ? Pink : Blue); GUI.Label(new Rect(30f, 119f, 210f, 24f), "Super Fan", labelStyle); bool enabled = GUI.enabled; GUI.enabled = enabled && enabledOverride.Value; if (GUI.Button(new Rect(313f, 117f, 68f, 27f), superFan.Value ? "On" : "Off")) { superFan.Value = !superFan.Value; } GUI.enabled = GUI.enabled && !superFan.Value; float value = DrawSlider(168f, "Blade speed", EffectiveBladeSpeed, 0.25f); float value2 = DrawSlider(222f, "Push power", EffectivePushPower, 0f); if (GUI.enabled) { bladeSpeed.Value = value; pushPower.Value = value2; } GUI.enabled = enabled && enabledOverride.Value; pushItems.Value = GUI.Toggle(new Rect(20f, 280f, 150f, 24f), pushItems.Value, "Push items"); pushPlayers.Value = GUI.Toggle(new Rect(184f, 280f, 150f, 24f), pushPlayers.Value, "Push players"); GUI.enabled = enabled; if ((int)menuKey.Value != 0) { GUI.Label(new Rect(20f, 315f, 230f, 20f), ((object)menuKey.Value/*cast due to .constrained prefix*/).ToString() + " to close", secondaryStyle); } if (GUI.Button(new Rect(280f, 312f, 118f, 26f), "Reset settings")) { enabledOverride.Value = true; superFan.Value = false; bladeSpeed.Value = 1f; pushPower.Value = 1f; pushItems.Value = true; pushPlayers.Value = true; } } private float DrawSlider(float top, string title, float value, float min) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(20f, top, 233f, 22f), title, labelStyle); string text = (superFan.Value ? $"{value:0.##}×" : $"{value:0.##}× / {20f:0}×"); GUI.Label(new Rect(296f, top, 100f, 22f), text, valueStyle); if (superFan.Value) { Fill(new Rect(20f, top + 31f, 376f, 3f), Blue); return value; } return GUI.HorizontalSlider(new Rect(20f, top + 27f, 376f, 19f), value, min, 20f); } private void DrawNotice(string title, string detail) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Fill(new Rect(18f, 105f, 380f, 68f), Surface); GUI.Label(new Rect(30f, 114f, 350f, 24f), title, labelStyle); GUI.Label(new Rect(30f, 138f, 350f, 25f), detail, secondaryStyle); } private static GUIStyle TextStyle(int size, Color color, TextAnchor alignment, FontStyle weight = (FontStyle)0) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = size, fontStyle = weight, alignment = alignment }; val.normal.textColor = color; return val; } private static void Fill(Rect rect, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 7) { Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = color2; } } private void InstallSuperFanContact() { try { getTumble = AccessTools.FieldRefAccess<PlayerAvatar, PlayerTumble>("tumble"); isPlayerDisabled = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled"); isTumbling = AccessTools.FieldRefAccess<PlayerTumble, bool>("isTumbling"); getTumbleOwner = AccessTools.FieldRefAccess<PlayerTumble, PlayerAvatar>("playerAvatar"); getCollisionOwner = AccessTools.FieldRefAccess<PlayerAvatarCollision, PlayerAvatar>("PlayerAvatar"); requestTumble = BindTumble<Action<PlayerTumble, bool, bool>>("TumbleRequest"); holdTumble = BindTumble<Action<PlayerTumble, float>>("TumbleOverrideTime"); armImpactDamage = BindTumble<Action<PlayerTumble, float, int>>("ImpactHurtSet"); applyTumbleForce = BindTumble<Action<PlayerTumble, Vector3>>("TumbleForce"); harmony.CreateClassProcessor(typeof(RegisterFanBody)).Patch(); harmony.CreateClassProcessor(typeof(SuperFanCollision)).Patch(); contactHooksReady = true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Super Fan contact launches are unavailable: " + ex)); } } private static T BindTumble<T>(string name) where T : Delegate { return AccessTools.MethodDelegate<T>(AccessTools.DeclaredMethod(typeof(PlayerTumble), name, (Type[])null, (Type[])null), (object)null, true); } private static PlayerAvatar FindPlayer(Collider collider) { PlayerAvatar componentInParent = ((Component)collider).GetComponentInParent<PlayerAvatar>(); if (Object.op_Implicit((Object)(object)componentInParent)) { return componentInParent; } PlayerAvatarCollision componentInParent2 = ((Component)collider).GetComponentInParent<PlayerAvatarCollision>(); if (Object.op_Implicit((Object)(object)componentInParent2)) { return getCollisionOwner.Invoke(componentInParent2); } PlayerTumble componentInParent3 = ((Component)collider).GetComponentInParent<PlayerTumble>(); if (!Object.op_Implicit((Object)(object)componentInParent3)) { return null; } return getTumbleOwner.Invoke(componentInParent3); } private static IEnumerator LaunchWhenTumbling(PlayerAvatar player, PlayerTumble tumble, Vector3 force) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) float deadline = Time.time + 1f; while (ContactActive && Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)tumble) && !isPlayerDisabled.Invoke(player)) { if (isTumbling.Invoke(tumble)) { holdTumble(tumble, 3f); armImpactDamage(tumble, 3f, 60); applyTumbleForce(tumble, force); break; } if (Time.time >= deadline) { break; } yield return null; } } }