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 NoSlipOnRoof v0.1.0
NoSlipOnRoof.dll
Decompiled 5 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using NoSlipOnRoof.Roofs; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("NoSlipOnRoof")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Stop sliding off steep roofs.")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+2824d724b48f7e8cc8b1b16e800d9f5f26d208ed")] [assembly: AssemblyProduct("NoSlipOnRoof")] [assembly: AssemblyTitle("NoSlipOnRoof")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.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; } } } namespace NoSlipOnRoof { [BepInPlugin("javidahmed64592.nosliponroof", "No Slip On Roof", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class NoSlipOnRoofPlugin : BaseUnityPlugin { public const string PluginGUID = "javidahmed64592.nosliponroof"; public const string PluginName = "No Slip On Roof"; public const string PluginVersion = "0.1.0"; private Harmony _harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _harmony = new Harmony("javidahmed64592.nosliponroof"); _harmony.PatchAll(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace NoSlipOnRoof.Roofs { internal static class RoofCheck { private const string Roof = "roof"; private static Collider _lastCollider; private static bool _lastResult; public static bool IsRoof(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if ((Object)(object)collider != (Object)(object)_lastCollider) { _lastCollider = collider; _lastResult = Check(collider); } return _lastResult; } private static bool Check(Collider collider) { Piece componentInParent = ((Component)collider).GetComponentInParent<Piece>(); if ((Object)(object)componentInParent != (Object)null) { if (!Mentions(Utils.GetPrefabName(((Component)componentInParent).gameObject))) { return Mentions(componentInParent.m_name); } return true; } return false; } private static bool Mentions(string name) { if (name == null) { return false; } return name.IndexOf("roof", StringComparison.OrdinalIgnoreCase) >= 0; } } } namespace NoSlipOnRoof.Patches { [HarmonyPatch(typeof(Character), "ApplyGroundForce")] internal static class Character_ApplyGroundForce_Patch { private const float IdleTargetSpeed = 0.01f; private const float MaxDrift = 4f; private const float PullStrength = 10f; private static Character _anchored; private static Vector3 _anchor; [HarmonyPostfix] private static void Postfix(Character __instance, ref Vector3 vel, Vector3 targetVel, Rigidbody ___m_body, Collider ___m_lastGroundCollider, Vector3 ___m_pushForce) { //IL_001e: 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_006a: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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) if (!(__instance is Player) || !__instance.IsOnGround() || !(((Vector3)(ref targetVel)).magnitude <= 0.01f) || !(___m_pushForce == Vector3.zero) || !RoofCheck.IsRoof(___m_lastGroundCollider)) { if ((Object)(object)_anchored == (Object)(object)__instance) { _anchored = null; } return; } if ((Object)(object)_anchored != (Object)(object)__instance) { _anchored = __instance; _anchor = ___m_body.position; } Vector3 val = _anchor - ___m_body.position; val.y = 0f; if (((Vector3)(ref val)).magnitude < 4f) { vel += val * 10f; } else { _anchored = null; } } } [HarmonyPatch(typeof(Character), "ApplySlide")] internal static class Character_ApplySlide_Patch { [HarmonyPrefix] private static bool Prefix(Character __instance, Collider ___m_lastGroundCollider, ref float ___m_slippage) { if (!(__instance is Player) || !RoofCheck.IsRoof(___m_lastGroundCollider)) { return true; } ___m_slippage = 0f; return false; } } [HarmonyPatch(typeof(Character), "UpdateBodyFriction")] internal static class Character_UpdateBodyFriction_Patch { private const float HoldFriction = 7f; private const float IdleMoveThreshold = 0.1f; [HarmonyPostfix] private static void Postfix(Character __instance, CapsuleCollider ___m_collider, Collider ___m_lastGroundCollider, Vector3 ___m_moveDir) { if (__instance is Player && !(((Vector3)(ref ___m_moveDir)).magnitude >= 0.1f) && __instance.IsOnGround() && !__instance.IsDead() && !__instance.IsSwimming() && RoofCheck.IsRoof(___m_lastGroundCollider)) { PhysicsMaterial material = ((Collider)___m_collider).material; material.staticFriction = 7f; material.dynamicFriction = 7f; material.frictionCombine = (PhysicsMaterialCombine)3; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }