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 FriendlyHeadGrabber v1.0.0
FriendlyHeadGrabber.dll
Decompiled an hour agousing System; using System.Diagnostics; using System.IO; using System.Reflection; 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 Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FriendlyHeadGrabber")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FriendlyHeadGrabber")] [assembly: AssemblyTitle("FriendlyHeadGrabber")] [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; } } } namespace FriendlyHeadGrabber { [BepInPlugin("com.purplehaxttv.friendlyheadgrabber", "Friendly Head Grabber", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "com.purplehaxttv.friendlyheadgrabber"; internal static ManualLogSource Log; internal static ConfigEntry<bool> LeaveHeadsAlone; internal static ConfigEntry<KeyCode> PetKey; internal static ConfigEntry<float> PetRange; internal static GameObject Hearts; private float nextPet; private void Awake() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; LeaveHeadsAlone = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Leave player heads alone", true, "The head grabber no longer picks up the heads of dead players."); PetKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Petting", "Pet key", (KeyCode)101, "Press this while looking at a head grabber to show it some love."); PetRange = ((BaseUnityPlugin)this).Config.Bind<float>("Petting", "Pet range", 4f, new ConfigDescription("How close you have to be to pet it, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); LoadHearts(); new Harmony("com.purplehaxttv.friendlyheadgrabber").PatchAll(); Log.LogInfo((object)"Friendly Head Grabber loaded."); } private void LoadHearts() { Type type = AccessTools.TypeByName("ModAssets"); if (type != null) { object? obj = AccessTools.Field(type, "HeartParticlesPrefab")?.GetValue(null); Hearts = (GameObject)((obj is GameObject) ? obj : null); if (Object.op_Implicit((Object)(object)Hearts)) { return; } } string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "friendlyheadgrabberassets"); if (!File.Exists(text)) { Log.LogWarning((object)("Heart effect not found at " + text)); return; } AssetBundle val = AssetBundle.LoadFromFile(text); if (Object.op_Implicit((Object)(object)val)) { Hearts = val.LoadAsset<GameObject>("HeartParticles"); } if (!Object.op_Implicit((Object)(object)Hearts)) { Log.LogWarning((object)"Heart effect could not be loaded."); } } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0096: 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) if (!Input.GetKeyDown(PetKey.Value) || Time.unscaledTime < nextPet) { return; } Camera main = Camera.main; if (!Object.op_Implicit((Object)(object)main)) { return; } EnemyHeadGrabber val = null; float num = 30f; EnemyHeadGrabber[] array = Object.FindObjectsByType<EnemyHeadGrabber>((FindObjectsSortMode)0); foreach (EnemyHeadGrabber val2 in array) { if (!((Behaviour)val2).isActiveAndEnabled || !Object.op_Implicit((Object)(object)val2.enemy) || !Object.op_Implicit((Object)(object)val2.enemy.CenterTransform)) { continue; } Vector3 val3 = val2.enemy.CenterTransform.position - ((Component)main).transform.position; if (!(((Vector3)(ref val3)).magnitude > PetRange.Value)) { float num2 = Vector3.Angle(((Component)main).transform.forward, val3); if (num2 < num) { val = val2; num = num2; } } } if (Object.op_Implicit((Object)(object)val)) { nextPet = Time.unscaledTime + 1f; Pet(val); } } public static GameObject Pet(EnemyHeadGrabber grabber) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) //IL_004f: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Hearts)) { return null; } Transform val = (Object.op_Implicit((Object)(object)grabber.enemy.Rigidbody) ? ((Component)grabber.enemy.Rigidbody).transform : ((Component)grabber).transform); Vector3 val2 = Vector3.up * 1.5f; GameObject obj = Object.Instantiate<GameObject>(Hearts, val.position + val2, Quaternion.identity); obj.SetActive(true); HeartFollow heartFollow = obj.AddComponent<HeartFollow>(); heartFollow.Target = val; heartFollow.Offset = val2; ParticleSystem component = obj.GetComponent<ParticleSystem>(); if (Object.op_Implicit((Object)(object)component)) { component.Play(); } Object.Destroy((Object)(object)obj, 6f); return obj; } } public class HeartFollow : MonoBehaviour { public Transform Target; public Vector3 Offset; private void LateUpdate() { //IL_0019: 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_0024: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Target)) { ((Component)this).transform.position = Target.position + Offset; } } } [HarmonyPatch(typeof(EnemyHeadGrabber), "UpdateState")] internal static class Patch_UpdateState { private static void Prefix(ref State _state) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected I4, but got Unknown State val = _state; switch (val - 7) { case 0: case 1: case 2: case 3: case 4: _state = (State)1; break; case 5: case 6: case 8: if (Plugin.LeaveHeadsAlone.Value) { _state = (State)1; } break; case 7: break; } } } [HarmonyPatch(typeof(EnemyHeadGrabber), "OnVision")] internal static class Patch_OnVision { private static bool Prefix() { return false; } } [HarmonyPatch(typeof(EnemyHeadGrabber), "NearbyHeadLogic")] internal static class Patch_NearbyHeadLogic { private static bool Prefix(ref bool __result) { if (!Plugin.LeaveHeadsAlone.Value) { return true; } __result = false; return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }