using System; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BoneLib; using BoneLib.BoneMenu; using HarmonyLib; using Il2CppSLZ.Interaction; using Il2CppSLZ.Marrow; using InteractableSettings; using MelonLoader; using MelonLoader.Preferences; 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: MelonInfo(typeof(InteractableSettingsMod), "Interactable Settings", "1.0.0", "triangle", "https://thunderstore.io/c/bonelab/p/triangle/InteractableSettings")] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("InteractableSettings")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2afb102224b9e4e9942bcc87e27f3078c8f74bc0")] [assembly: AssemblyProduct("InteractableSettings")] [assembly: AssemblyTitle("InteractableSettings")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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; } } } internal static class MenuHelper { internal static IntElement CreateIntPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, int increment, int minValue, int maxValue, Action callback = null, string prefName = null, int prefDefaultValue = 0) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!InteractableSettingsMod.InteractableSettings_Category.HasEntry(prefName)) { value = InteractableSettingsMod.InteractableSettings_Category.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; return page.CreateInt(name, color, val.Value, increment, minValue, maxValue, (Action)delegate(int x) { val.Value = x; InteractableSettingsMod.SavePreferences(); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); } internal static FloatElement CreateFloatPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, float increment, float minValue, float maxValue, Action callback = null, string prefName = null, float prefDefaultValue = 0f) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!InteractableSettingsMod.InteractableSettings_Category.HasEntry(prefName)) { value = InteractableSettingsMod.InteractableSettings_Category.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; return page.CreateFloat(name, color, val.Value, increment, minValue, maxValue, (Action)delegate(float x) { val.Value = x; InteractableSettingsMod.SavePreferences(); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); } internal static BoolElement CreateBoolPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, Action callback = null, string prefName = null, bool prefDefaultValue = false) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!InteractableSettingsMod.InteractableSettings_Category.HasEntry(prefName)) { value = InteractableSettingsMod.InteractableSettings_Category.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; return page.CreateBool(name, color, val.Value, (Action)delegate(bool x) { val.Value = x; InteractableSettingsMod.SavePreferences(); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); } internal static EnumElement CreateEnumPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, Action callback = null, string prefName = null, Enum prefDefaultValue = null) where T : Enum { //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!InteractableSettingsMod.InteractableSettings_Category.HasEntry(prefName)) { value = InteractableSettingsMod.InteractableSettings_Category.CreateEntry(prefName, (T)prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; return page.CreateEnum(name, color, (Enum)val.Value, (Action)delegate(Enum x) { val.Value = (T)x; InteractableSettingsMod.SavePreferences(); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); } internal static StringElement CreateStringPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, Action callback = null, string prefName = null, string prefDefaultValue = null) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!InteractableSettingsMod.InteractableSettings_Category.HasEntry(prefName)) { value = InteractableSettingsMod.InteractableSettings_Category.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; StringElement val2 = page.CreateString(name, color, val.Value, (Action)delegate(string x) { val.Value = x; InteractableSettingsMod.SavePreferences(); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); val2.Value = value.Value; return val2; } } namespace InteractableSettings { public class InteractableSettingsMod : MelonMod { public enum ForcePullMode { OFF, ON, ANYTHING, PER_ENTITY } public const int PullAnythingMask = 2146959103; public const float DefaultMaxForce = 250f; public static FloatElement FPGMaxForce; public static MelonPreferences_Category InteractableSettings_Category; public static MelonPreferences_Entry InteractableIcon_HandHover_Enabled; public static MelonPreferences_Entry InteractableIcon_FarHandHover_Enabled; public static MelonPreferences_Entry ForcePullGrip_ForcePullMode; public static MelonPreferences_Entry ForcePullGrip_Collision_Enabled; public static MelonPreferences_Entry ForcePullGrip_ForcePullThroughObjects_Enabled; public static MelonPreferences_Entry ForcePullGrip_MaxForce; public static MelonPreferences_Entry ForcePullGrip_AprilFooled; public static int PlayerHandLayerMask { get; set; } public static int FarHoverHandLayerMask { get; set; } public override void OnInitializeMelon() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) //IL_00dc: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) InteractableSettings_Category = MelonPreferences.CreateCategory("Interactable Settings"); ForcePullGrip_AprilFooled = InteractableSettings_Category.CreateEntry("April Fools", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); Page val = Page.Root.CreatePage("Interactable Settings", Color.green, 0, true); Page page = val.CreatePage("Interactable Icon", Color.white, 0, true); page.CreateBoolPref("Near Hand Icons", Color.white, ref InteractableIcon_HandHover_Enabled, null, null, prefDefaultValue: true); page.CreateBoolPref("Force Pull Icons", Color.white, ref InteractableIcon_FarHandHover_Enabled, null, null, prefDefaultValue: true); Page val2 = val.CreatePage("Force Pull Grip", Color.cyan, 0, true); val2.CreateEnumPref("Force Pull", Color.cyan, ref ForcePullGrip_ForcePullMode, OnChangeForcePullMode, null, ForcePullMode.ON); val2.CreateBoolPref("Force Pull Collision", Color.cyan, ref ForcePullGrip_Collision_Enabled, null, null, prefDefaultValue: true); val2.CreateBoolPref("Force Pull Through Objects", Color.cyan, ref ForcePullGrip_ForcePullThroughObjects_Enabled, OnEnableForcePullThroughObjects); FPGMaxForce = val2.CreateFloatPref("Force Pull Max Force", Color.cyan, ref ForcePullGrip_MaxForce, 50f, -500000f, 500000f, null, null, 250f); val2.CreateFunction("Reset Max Force", Color.cyan, (Action)ResetMaxForce); if (!ForcePullGrip_AprilFooled.Value && DateTime.Today.Month == 4 && DateTime.Today.Day == 1) { ForcePullGrip_MaxForce.Value = -750f; FPGMaxForce.Value = ForcePullGrip_MaxForce.Value; ForcePullGrip_AprilFooled.Value = true; SavePreferences(); } Hooking.OnLevelLoaded += LevelLoaded; ((MelonBase)this).LoggerInstance.Msg(" Initialized."); } private void LevelLoaded(LevelInfo info) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) PlayerHandLayerMask = LayerMask.op_Implicit(Player.LeftHand.playerLayerMask); if (ForcePullGrip_ForcePullThroughObjects_Enabled.Value) { Player.LeftHand.playerLayerMask = LayerMask.op_Implicit(int.MaxValue); Player.RightHand.playerLayerMask = LayerMask.op_Implicit(int.MaxValue); } FarHoverHandLayerMask = LayerMask.op_Implicit(Player.LeftHand.farHoverLayerMask); if (ForcePullGrip_ForcePullMode.Value == ForcePullMode.ANYTHING || ForcePullGrip_ForcePullMode.Value == ForcePullMode.PER_ENTITY) { Player.LeftHand.farHoverLayerMask = LayerMask.op_Implicit(2146959103); Player.RightHand.farHoverLayerMask = LayerMask.op_Implicit(2146959103); } } public static void SavePreferences() { InteractableSettings_Category.SaveToFile(false); } public static void OnEnableForcePullThroughObjects(bool value) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (value) { Player.LeftHand.playerLayerMask = LayerMask.op_Implicit(int.MaxValue); Player.RightHand.playerLayerMask = LayerMask.op_Implicit(int.MaxValue); } else { Player.LeftHand.playerLayerMask = LayerMask.op_Implicit(PlayerHandLayerMask); Player.RightHand.playerLayerMask = LayerMask.op_Implicit(PlayerHandLayerMask); } } public static void OnChangeForcePullMode(Enum value) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((ForcePullMode)(object)value == ForcePullMode.ANYTHING || (ForcePullMode)(object)value == ForcePullMode.PER_ENTITY) { Player.LeftHand.farHoverLayerMask = LayerMask.op_Implicit(2146959103); Player.RightHand.farHoverLayerMask = LayerMask.op_Implicit(2146959103); } else { Player.LeftHand.farHoverLayerMask = LayerMask.op_Implicit(FarHoverHandLayerMask); Player.RightHand.farHoverLayerMask = LayerMask.op_Implicit(FarHoverHandLayerMask); } } public static void ResetMaxForce() { ForcePullGrip_MaxForce.Value = 250f; FPGMaxForce.Value = 250f; SavePreferences(); } } [HarmonyPatch] public static class Patches { private const float ForcePullGripIdentifier = -57f; private const float ExtraForcePullGripIdentifier = -58f; [HarmonyPatch(typeof(InteractableIcon), "MyHandHoverBegin")] [HarmonyPrefix] public static bool InteractableIcon_HandHoverIconDisable() { return InteractableSettingsMod.InteractableIcon_HandHover_Enabled.Value; } [HarmonyPatch(typeof(InteractableIcon), "MyFarHandHoverBegin")] [HarmonyPrefix] public static bool InteractableIcon_FarHandHoverIconDisable() { return InteractableSettingsMod.InteractableIcon_FarHandHover_Enabled.Value; } [HarmonyPatch(typeof(HandReciever), "get_IsFarHoverEnabled")] [HarmonyPrefix] public static bool ForcePullGrip_Mode(Grip __instance) { if (Object.op_Implicit((Object)(object)__instance)) { switch (InteractableSettingsMod.ForcePullGrip_ForcePullMode.Value) { case InteractableSettingsMod.ForcePullMode.OFF: return false; case InteractableSettingsMod.ForcePullMode.ON: if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent()) && ((Component)__instance).GetComponent().maxSpeed != -57f && ((Component)__instance).GetComponent().maxSpeed != -58f) { return true; } return false; case InteractableSettingsMod.ForcePullMode.ANYTHING: return true; case InteractableSettingsMod.ForcePullMode.PER_ENTITY: if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent()) && ((Component)__instance).GetComponent().maxSpeed == -58f) { return false; } return true; default: return true; } } return true; } [HarmonyPatch(typeof(Grip), "add_forcePullCompleteDelegate")] [HarmonyPostfix] public static void ForcePullGrip_OnPullCollisionDisable(Grip __instance) { if (!InteractableSettingsMod.ForcePullGrip_Collision_Enabled.Value) { __instance._marrowEntity.EnableColliders(false); } ((Component)__instance).GetComponent().maxForce = InteractableSettingsMod.ForcePullGrip_MaxForce.Value; } [HarmonyPatch(typeof(Grip), "remove_forcePullCompleteDelegate")] [HarmonyPostfix] public static void ForcePullGrip_OnAttachCollisionEnable(Grip __instance) { if (!InteractableSettingsMod.ForcePullGrip_Collision_Enabled.Value) { __instance._marrowEntity.EnableColliders(true); } } [HarmonyPatch(typeof(Grip), "Start")] [HarmonyPostfix] public static void ForcePullGrip_AddForcePullGrip(Grip __instance) { if (((object)__instance).GetType() != typeof(GenericGrip) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { if (!Object.op_Implicit((Object)(object)((Component)((Component)__instance).transform.root).gameObject.GetComponentInChildren())) { ((Component)__instance).gameObject.AddComponent().maxSpeed = -57f; } else { ((Component)__instance).gameObject.AddComponent().maxSpeed = -58f; } } } } }