Decompiled source of FriendlyDuck v2.1.0

plugins/FriendlyDuck.dll

Decompiled 3 days ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("FriendlyDuck")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FriendlyDuck")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("972d3e57-0fd5-4035-afcb-4660f275e95a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(EnemyDuck), "OnGrabbed")]
public class Patch_EnemyDuck_OnGrabbed
{
	private static bool Prefix(object __instance)
	{
		if (__instance == null)
		{
			FriendlyDuckPlugin.Logger.LogWarning((object)"OnGrabbed: __instance is null.");
			return true;
		}
		MethodInfo method = __instance.GetType().GetMethod("AnnoyingJump", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			FriendlyDuckPlugin.Logger.LogError((object)"AnnoyingJump method not found.");
			return true;
		}
		method.Invoke(__instance, null);
		return false;
	}
}
[HarmonyPatch(typeof(EnemyDuck), "OnSpawn")]
public class Patch_EnemyDuck_OnSpawn
{
	private static void Postfix(EnemyDuck __instance)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance != (Object)null)
		{
			FriendlyDuckPlugin.Logger.LogInfo((object)$">>> Our little guy spawned at position: {((Component)__instance).transform.position}");
		}
	}
}
[HarmonyPatch(typeof(EnemyDuck), "Update")]
public class Patch_EnemyDuck_Update
{
	private static void Postfix(EnemyDuck __instance)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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)
		object obj = typeof(EnemyDuck).GetField("playerTarget", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance);
		if (obj != null && Input.GetKeyDown((KeyCode)101))
		{
			GameObject val = Object.Instantiate<GameObject>(ModAssets.HeartParticlesPrefab, ((Component)__instance).transform.position + Vector3.up * 1.5f, Quaternion.identity);
			val.transform.SetParent(((Component)__instance).transform);
		}
	}
}
[HarmonyPatch(typeof(EnemyDuck), "StateAttackStart")]
public class Patch_EnemyDuck_StateAttackStart
{
	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(EnemyDuck), "OnHurt")]
public class Patch_EnemyDuck_OnHurt
{
	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(EnemyDuck), "OnObjectHurt")]
public class Patch_EnemyDuck_OnObjectHurt
{
	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(EnemyDuck), "StateDespawn")]
public class Patch_EnemyDuck_StateDespawn
{
	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(EnemyDuck), "StateStun")]
public class Patch_EnemyDuck_StateStun
{
	private static bool Prefix()
	{
		return false;
	}
}
[BepInPlugin("com.purplehaxttv.friendlyduck", "Friendly Duck", "2.1.0")]
public class FriendlyDuckPlugin : BaseUnityPlugin
{
	public static ManualLogSource Logger;

	private void Awake()
	{
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		Logger = Logger.CreateLogSource("Friendly Duck");
		Logger.LogInfo((object)"Friendly Duck plugin loaded.");
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string text = Path.Combine(directoryName, "friendlyduckassets");
		if (File.Exists(text))
		{
			AssetBundle bundle = AssetBundle.LoadFromFile(text);
			ModAssets.LoadAssets(bundle);
			Logger.LogInfo((object)("Asset bundle loaded from: " + text));
		}
		else
		{
			Logger.LogWarning((object)("Asset bundle NOT found at: " + text));
		}
		new Harmony("com.purplehaxttv.friendlyduck").PatchAll();
	}
}
public static class ModAssets
{
	public static GameObject HeartParticlesPrefab;

	public static void LoadAssets(AssetBundle bundle)
	{
		if ((Object)(object)bundle == (Object)null)
		{
			Debug.LogError((object)"[FriendlyDuck] AssetBundle was null when passed to LoadAssets.");
			return;
		}
		HeartParticlesPrefab = bundle.LoadAsset<GameObject>("HeartParticles");
		if ((Object)(object)HeartParticlesPrefab == (Object)null)
		{
			Debug.LogWarning((object)"[FriendlyDuck] HeartParticles prefab not found in asset bundle.");
		}
		else
		{
			Debug.Log((object)"[FriendlyDuck] HeartParticles prefab loaded successfully.");
		}
	}
}