Decompiled source of Giant Overhaul v0.0.1

GiantOverhaul.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GiantOverhaul")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod which changes the giant AI to work with the Candyland map")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GiantOverhaul")]
[assembly: AssemblyTitle("GiantOverhaul")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 GiantOverhaul
{
	[BepInPlugin("GiantOverhaul", "GiantOverhaul", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(EnemyAI), "GetAllPlayersInLineOfSight")]
		private class GiantSightPatch
		{
			private static void Postfix(ref EnemyAI __instance, ref PlayerControllerB[] __result)
			{
				if (!(__instance.enemyType.enemyName == "ForestGiant") || __result == null)
				{
					return;
				}
				List<PlayerControllerB> list = new List<PlayerControllerB>();
				if (StartOfRound.Instance.timeSinceRoundStarted <= 330f)
				{
					for (int i = 0; i < __result.Length; i++)
					{
						if (__result[i].twoHanded)
						{
							list.Add(__result[i]);
						}
					}
				}
				else
				{
					list = __result.ToList();
					bool flag = false;
					for (int j = 0; j < __result.Length; j++)
					{
						if (__result[j].twoHanded)
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						int num = 0;
						while (num < __result.Length)
						{
							if (!__result[num].twoHanded)
							{
								list.RemoveAt(num);
							}
							else
							{
								num++;
							}
						}
					}
				}
				if (__result.Length > list.Count && (Object)(object)__instance.targetPlayer != (Object)null && (list.Count == 0 || !list.Contains(__instance.targetPlayer)))
				{
					__instance.SwitchToBehaviourState(0);
				}
				if (list.Count == 0)
				{
					__result = null;
				}
				else
				{
					__result = list.ToArray();
				}
			}
		}

		[HarmonyPatch(typeof(ForestGiantAI), "GiantSeePlayerEffect")]
		private class GiantFearPatch
		{
			private static bool Prefix(ref ForestGiantAI __instance)
			{
				if (StartOfRound.Instance.timeSinceRoundStarted <= 330f)
				{
					bool result = false;
					PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)__instance).GetAllPlayersInLineOfSight(50f, 70, ((EnemyAI)__instance).eye, 3f, StartOfRound.Instance.collidersRoomDefaultAndFoliage);
					for (int i = 0; i < allPlayersInLineOfSight.Length; i++)
					{
						if (allPlayersInLineOfSight[i].twoHanded)
						{
							result = true;
						}
					}
					return result;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ForestGiantAI), "BeginEatPlayer")]
		private class GiantNoEatInDayPatch
		{
			private static bool Prefix(ref ForestGiantAI __instance)
			{
				if (StartOfRound.Instance.timeSinceRoundStarted <= 330f)
				{
					bool result = false;
					PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)__instance).GetAllPlayersInLineOfSight(50f, 70, ((EnemyAI)__instance).eye, 3f, StartOfRound.Instance.collidersRoomDefaultAndFoliage);
					for (int i = 0; i < allPlayersInLineOfSight.Length; i++)
					{
						if (allPlayersInLineOfSight[i].twoHanded)
						{
							result = true;
						}
					}
					return result;
				}
				return true;
			}
		}

		private const int secondsUntilMad = 330;

		private Harmony harmony = new Harmony("GiantOverhaul");

		public static Plugin Instance;

		private void Awake()
		{
			Instance = this;
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Giant Overhaul Active!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "GiantOverhaul";

		public const string PLUGIN_NAME = "GiantOverhaul";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}