Decompiled source of Goose v1.1.0

Goose.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Goose;
using HBMF.AudioImporter;
using HBMF.GameResources;
using HBMF.SpawnGun;
using HBMF.Utilities;
using Il2Cpp;
using Il2CppFirearmSystem;
using Il2CppInteractionSystem;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "Goose", "1.1.0", "korbykob", null)]
[assembly: MelonGame("GexagonVR", "Hard Bullet")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Goose")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Goose")]
[assembly: AssemblyTitle("Goose")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Goose;

public class Mod : MelonMod
{
	private bool loaded = false;

	public override void OnInitializeMelon()
	{
		Goose.honkClip = Audio.Import(Utils.GetResource(Assembly.GetExecutingAssembly(), "Goose.Honk.wav"));
		Goose.biteClip = Audio.Import(Utils.GetResource(Assembly.GetExecutingAssembly(), "Goose.Bite.wav"));
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (!loaded)
		{
			loaded = true;
			GameObject val = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(Utils.GetResource(Assembly.GetExecutingAssembly(), "Goose.goose.assets"))).LoadAsset<GameObject>("Goose.prefab");
			val.AddComponent<Goose>();
			Spawnables.AddSpawnable("Goose", val);
		}
	}
}
[RegisterTypeInIl2Cpp]
public class Goose : MonoBehaviour
{
	private NavMeshAgent goose;

	private float lastAction = Time.unscaledTime;

	private float newActionTime = Random.Range(100f, 500f);

	private bool wander = true;

	internal static AudioClip honkClip;

	private AudioSource honk;

	internal static AudioClip biteClip;

	private AudioSource bite;

	public Goose(IntPtr ptr)
		: base(ptr)
	{
	}

	internal void Start()
	{
		goose = ((Component)this).GetComponent<NavMeshAgent>();
		GameObject gameObject = ((Component)((Component)goose).transform.Find("Beak")).gameObject;
		honk = gameObject.AddComponent<AudioSource>();
		honk.clip = honkClip;
		bite = gameObject.AddComponent<AudioSource>();
		bite.clip = biteClip;
	}

	internal void Update()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if (!wander)
		{
			return;
		}
		if (goose.remainingDistance <= goose.stoppingDistance)
		{
			NavMeshHit val = default(NavMeshHit);
			NavMesh.SamplePosition(Random.insideUnitSphere * 10f, ref val, 20f, 1);
			goose.SetDestination(((Component)this).transform.position + ((NavMeshHit)(ref val)).position);
		}
		if (Time.time - lastAction >= newActionTime)
		{
			wander = false;
			lastAction = Time.time;
			switch (Random.Range(0, 6))
			{
			case 0:
				MelonCoroutines.Start(GrabHand());
				break;
			case 1:
				MelonCoroutines.Start(Headbutt());
				break;
			case 2:
				MelonCoroutines.Start(BringEnemy());
				break;
			case 3:
				MelonCoroutines.Start(Honk());
				break;
			case 4:
				MelonCoroutines.Start(BringGun());
				break;
			case 5:
				MelonCoroutines.Start(StealGun());
				break;
			}
		}
	}

	[HideFromIl2Cpp]
	private IEnumerator GrabHand()
	{
		goose.speed = 4f;
		yield return new Goto(goose, ((Component)GameResources.RightGrabber).transform);
		bite.Play((PlaySettings)null);
		yield return new Drag(goose, ((Component)GameResources.RightGrabber).transform);
		newActionTime = Random.Range(100f, 500f);
		goose.speed = 2f;
		wander = true;
	}

	[HideFromIl2Cpp]
	private IEnumerator Headbutt()
	{
		goose.speed = 4f;
		yield return new Goto(goose, GameResources.Head);
		Vector3 velocity = GameResources.Locoball.position - ((Component)goose).transform.position;
		((Component)GameResources.Locoball).GetComponent<Rigidbody>().AddForce(new Vector3(((Vector3)(ref velocity)).normalized.x * 1000f, 100f, ((Vector3)(ref velocity)).normalized.z * 1000f), (ForceMode)1);
		newActionTime = Random.Range(100f, 500f);
		goose.speed = 2f;
		wander = true;
	}

	[HideFromIl2Cpp]
	private IEnumerator BringEnemy()
	{
		goose.speed = 4f;
		List<EnemyRoot> dead = new List<EnemyRoot>();
		for (int i = 0; i < GameResources.Enemies.childCount; i++)
		{
			EnemyRoot root = ((Component)GameResources.Enemies.GetChild(i)).GetComponent<EnemyRoot>();
			if (root.HealthContainer.IsHealthContainerEmpty)
			{
				dead.Add(root);
			}
		}
		if (dead.Count > 0)
		{
			Transform foot = ((Component)dead[Random.Range(0, dead.Count)]).transform.Find("[BODY]/PhysicalBones/foot_r");
			yield return new Goto(goose, foot);
			bite.Play((PlaySettings)null);
			yield return new Bring(goose, foot, GameResources.Head);
			newActionTime = Random.Range(100f, 500f);
		}
		goose.speed = 2f;
		wander = true;
	}

	[HideFromIl2Cpp]
	private IEnumerator Honk()
	{
		goose.speed = 4f;
		yield return new Goto(goose, GameResources.Head);
		yield return new Honk(goose, GameResources.Head, honk);
		newActionTime = Random.Range(100f, 500f);
		goose.speed = 2f;
		wander = true;
	}

	[HideFromIl2Cpp]
	private IEnumerator BringGun()
	{
		goose.speed = 4f;
		FirearmEntity[] guns = Il2CppArrayBase<FirearmEntity>.op_Implicit(Object.FindObjectsOfType<FirearmEntity>());
		Socketable gun = null;
		while ((Object)(object)gun == (Object)null || (Object)(object)((AbstractSocketable)gun).CurrentSocket == (Object)null)
		{
			gun = ((Component)guns[Random.Range(0, guns.Length)]).GetComponent<Socketable>();
		}
		yield return new Goto(goose, ((Component)gun).transform);
		if (((AbstractSocketable)gun).IsAlreadyInSocket)
		{
			((AbstractSocketable)gun).ForceUnsnapFromSocket();
		}
		bite.Play((PlaySettings)null);
		yield return new Bring(goose, ((Component)gun).transform, GameResources.Head);
		newActionTime = Random.Range(100f, 500f);
		goose.speed = 2f;
		wander = true;
	}

	[HideFromIl2Cpp]
	private IEnumerator StealGun()
	{
		goose.speed = 4f;
		Socket[] sockets = Il2CppArrayBase<Socket>.op_Implicit(((Component)GameResources.HexaBody.Find("Knee/LowerPoint/IKStabilizer/root/pelvis")).GetComponentsInChildren<Socket>());
		bool found = false;
		Socket[] array = sockets;
		foreach (Socket socket in array)
		{
			if ((Object)(object)((AbstractSocket)socket).ObjectInSocket != (Object)null)
			{
				found = true;
			}
		}
		if (found)
		{
			yield return new Goto(goose, GameResources.Head);
			Socket socket2 = null;
			while ((Object)(object)socket2 == (Object)null || (Object)(object)((AbstractSocket)socket2).ObjectInSocket == (Object)null)
			{
				socket2 = sockets[Random.Range(0, sockets.Length)];
			}
			Transform gun = ((Component)((AbstractSocket)socket2).ObjectInSocket).transform;
			((AbstractSocketable)((Component)gun).GetComponent<Socketable>()).ForceUnsnapFromSocket();
			bite.Play((PlaySettings)null);
			yield return new Drag(goose, gun);
			newActionTime = Random.Range(100f, 500f);
		}
		goose.speed = 2f;
		wander = true;
	}
}
[RegisterTypeInIl2Cpp]
public class Goto : CustomYieldInstruction
{
	private readonly NavMeshAgent goose;

	private readonly Transform target;

	public override bool keepWaiting
	{
		get
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			goose.SetDestination(target.position);
			return goose.remainingDistance > goose.stoppingDistance;
		}
	}

	public Goto(IntPtr ptr)
		: base(ptr)
	{
	}

	public Goto(NavMeshAgent newGoose, Transform newTarget)
		: base(ClassInjector.DerivedConstructorPointer<Goto>())
	{
		ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		goose = newGoose;
		target = newTarget;
	}
}
[RegisterTypeInIl2Cpp]
public class Drag : CustomYieldInstruction
{
	private readonly NavMeshAgent goose;

	private readonly Transform hand;

	private readonly Transform beak;

	private readonly float start;

	public override bool keepWaiting
	{
		get
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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)
			hand.position = beak.position;
			if (goose.remainingDistance <= goose.stoppingDistance)
			{
				NavMeshHit val = default(NavMeshHit);
				NavMesh.SamplePosition(Random.insideUnitSphere * 100f, ref val, 100f, 1);
				goose.SetDestination(((NavMeshHit)(ref val)).position);
			}
			return Time.unscaledTime - start < 5f;
		}
	}

	public Drag(IntPtr ptr)
		: base(ptr)
	{
	}

	public Drag(NavMeshAgent newGoose, Transform newHand)
		: base(ClassInjector.DerivedConstructorPointer<Drag>())
	{
		ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		goose = newGoose;
		hand = newHand;
		beak = ((Component)goose).transform.Find("Beak");
		start = Time.unscaledTime;
	}
}
[RegisterTypeInIl2Cpp]
public class Bring : CustomYieldInstruction
{
	private readonly NavMeshAgent goose;

	private readonly Transform bring;

	private readonly Transform beak;

	private readonly Transform target;

	public override bool keepWaiting
	{
		get
		{
			//IL_000d: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			bring.position = beak.position;
			goose.SetDestination(target.position);
			Vector3 val = ((Component)goose).transform.position - target.position;
			return ((Vector3)(ref val)).magnitude > goose.stoppingDistance + 1f;
		}
	}

	public Bring(IntPtr ptr)
		: base(ptr)
	{
	}

	public Bring(NavMeshAgent newGoose, Transform newBring, Transform newTarget)
		: base(ClassInjector.DerivedConstructorPointer<Bring>())
	{
		ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		goose = newGoose;
		bring = newBring;
		beak = ((Component)goose).transform.Find("Beak");
		target = newTarget;
	}
}
[RegisterTypeInIl2Cpp]
public class Honk : CustomYieldInstruction
{
	private readonly NavMeshAgent goose;

	private readonly Transform target;

	private readonly AudioSource honk;

	private float lastHonk;

	private readonly float start;

	public override bool keepWaiting
	{
		get
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			goose.SetDestination(target.position);
			if (Time.time - lastHonk >= 0.5f)
			{
				honk.Play((PlaySettings)null);
				lastHonk = Time.time;
			}
			return Time.time - start < 5f;
		}
	}

	public Honk(IntPtr ptr)
		: base(ptr)
	{
	}

	public Honk(NavMeshAgent newGoose, Transform newTarget, AudioSource newHonk)
		: base(ClassInjector.DerivedConstructorPointer<Honk>())
	{
		ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		goose = newGoose;
		target = newTarget;
		honk = newHonk;
		start = Time.time;
	}
}