Decompiled source of Follower2 v0.0.3

Follower2.dll

Decompiled 21 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ThundergunRevised")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThundergunRevised")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5711e2a0-d5a7-4ddf-b8d4-00f355fe9397")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-FI")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Follower20;

public class FollowerFlayer : MonoBehaviour
{
	public Follow follow;

	public NewMovement player;

	public Mindflayer mindflayYergh;

	public AlwaysLookAtCamera ALAC;

	public bool dead = false;

	private void Start()
	{
		follow = ((Component)this).gameObject.GetComponent<Follow>();
		mindflayYergh = ((Component)this).gameObject.GetComponent<Mindflayer>();
		ALAC = ((Component)this).gameObject.GetComponent<AlwaysLookAtCamera>();
		player = MonoSingleton<NewMovement>.Instance;
	}

	private void Update()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position);
		((Behaviour)follow).enabled = (num > 10f) & (mindflayYergh.target == null);
		((Behaviour)ALAC).enabled = mindflayYergh.target == null;
		follow.speed = (num - 10f) * 5f;
		follow.target = ((Component)player).transform;
		if (mindflayYergh.dying & !dead)
		{
			MainCode.RespawnDelay = 15f;
			MainCode.SendHudMessage("Follower has died.\nIt will respawn in 15 seconds.");
			dead = true;
		}
		if (!mindflayYergh.beaming & (mindflayYergh.rightHand.childCount > 0))
		{
			Object.Destroy((Object)(object)((Component)mindflayYergh.rightHand.GetChild(0)).gameObject);
		}
	}
}
[BepInPlugin("plonk.follower2", "FOLLOWER", "1.0.0")]
public class MainCode : BaseUnityPlugin
{
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Mindflayer), "Awake")]
		public static bool NOMENALLOWED(Mindflayer __instance)
		{
			FollowerFlayer followerFlayer = default(FollowerFlayer);
			if (((Component)__instance).TryGetComponent<FollowerFlayer>(ref followerFlayer))
			{
				__instance.mach = ((Component)__instance).GetComponent<Machine>();
				__instance.rb = ((Component)__instance).GetComponent<Rigidbody>();
				__instance.anim = ((Component)__instance).GetComponent<Animator>();
				__instance.eid = ((Component)__instance).GetComponent<EnemyIdentifier>();
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
		public static bool DONTHITWOMENYOUFUCKINGBITCHASS(EnemyIdentifier __instance, GameObject target, Vector3 force, Vector3 hitPoint, float multiplier, bool tryForExplode, float critMultiplier = 0f, GameObject sourceWeapon = null, bool ignoreTotalDamageTakenMultiplier = false, bool fromExplosion = false)
		{
			FollowerFlayer followerFlayer = default(FollowerFlayer);
			if (((Component)__instance).TryGetComponent<FollowerFlayer>(ref followerFlayer) && (Object)(object)sourceWeapon != (Object)null)
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(NewMovement), "Respawn")]
		public static void Woman_Remover()
		{
			if ((Object)(object)flayer != (Object)null)
			{
				Object.Destroy((Object)(object)flayer);
			}
		}
	}

	private static AssetBundle tcbundle;

	public static float RespawnDelay;

	private static bool candoshit;

	public static GameObject flayer;

	public static Type Fetch<Type>(string name)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return Addressables.LoadAssetAsync<Type>((object)name).WaitForCompletion();
	}

	public static void Log(string log, int type)
	{
		switch (type)
		{
		case 1:
			Debug.Log((object)log);
			break;
		case 2:
			Debug.LogWarning((object)log);
			break;
		case 3:
			Debug.LogError((object)log);
			break;
		}
	}

	public static void SendHudMessage(string msg, int delay = 0, bool silent = false)
	{
		MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(msg, "", "", delay, silent, false, true);
	}

	public void Awake()
	{
	}

	public static Type FetchFromBundle<Type>(string name, bool autofill = false) where Type : Object
	{
		if ((Object)(object)tcbundle == (Object)null)
		{
			Log("Straymode bundle is null!", 3);
			return default(Type);
		}
		if (!autofill)
		{
			return tcbundle.LoadAsset<Type>(name);
		}
		return tcbundle.LoadAsset<Type>("assets/formods/follower20_/" + name);
	}

	public void Start()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("plonk.follower2");
		val.PatchAll();
	}

	public static void SpawnFlayer()
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Fetch<GameObject>("Assets/Prefabs/Enemies/Mindflayer.prefab");
		GameObject val2 = Object.Instantiate<GameObject>(val);
		val2.SetActive(false);
		val2.GetComponent<EnemyIdentifier>().ignorePlayer = true;
		val2.GetComponent<EnemyIdentifier>().attackEnemies = true;
		val2.GetComponent<EnemyIdentifier>().ignoredByEnemies = true;
		val2.GetComponent<EnemyIdentifier>().prioritizePlayerOverFallback = true;
		Transform transform = val2.transform;
		transform.localScale *= 0.5f;
		AlwaysLookAtCamera val3 = val2.AddComponent<AlwaysLookAtCamera>();
		val3.useXAxis = true;
		val3.useYAxis = true;
		val3.useZAxis = true;
		val3.preferCameraOverHead = true;
		val3.speed = 100f;
		val3.easeIn = true;
		Follow val4 = val2.AddComponent<Follow>();
		val4.followX = true;
		val4.followY = true;
		val4.followZ = true;
		val4.mimicPosition = true;
		val4.speed = 10f;
		val2.AddComponent<FollowerFlayer>();
		Mindflayer component = val2.GetComponent<Mindflayer>();
		val2.GetComponent<EnemyIdentifier>().difficultyOverride = 4;
		val2.tag = "Untagged";
		val2.SetActive(true);
		flayer = val2;
	}

	public void Update()
	{
		if (!candoshit && SceneHelper.CurrentScene == "Main Menu")
		{
			candoshit = true;
		}
		if (candoshit && SceneHelper.CurrentScene != "Main Menu")
		{
			if (RespawnDelay > 0f)
			{
				RespawnDelay -= Time.deltaTime;
			}
			if (((Object)(object)flayer == (Object)null) & (RespawnDelay <= 0f))
			{
				SpawnFlayer();
			}
		}
	}
}