Decompiled source of ScoutScreamFix v0.0.1

ScoutScreamFix.dll

Decompiled 4 months ago
using System;
using System.CodeDom.Compiler;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Agents;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using Enemies;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ScoutScreamFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScoutScreamFix")]
[assembly: AssemblyTitle("ScoutScreamFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ScoutScreamFix
{
	[BepInPlugin("ScoutScreamFix", "ScoutScreamFix", "0.0.1")]
	public class Plugin : BasePlugin
	{
		public class ScoutWatch : MonoBehaviour
		{
			private EnemyAgent enemy;

			private EnemyAI ai;

			private ES_ScoutScream scream;

			private bool init;

			private float screamtime;

			private bool hasbeenreset;

			private float debugtime;

			public void Attach(ES_ScoutScream scream)
			{
				this.scream = scream;
				enemy = ((ES_Base)this.scream).m_enemyAgent;
				ai = enemy.AI;
				Debug.Log(Object.op_Implicit($"ScoutScreamFix - fixer attached. {((Agent)enemy).GlobalID}"));
				init = true;
			}

			private void Update()
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Invalid comparison between Unknown and I4
				if (init && !hasbeenreset && !((Object)(object)enemy == (Object)null) && ((Agent)enemy).Alive)
				{
					if (screamtime == 0f && (int)scream.m_state == 2)
					{
						screamtime = Clock.Time;
					}
					if (screamtime != 0f && Clock.Time - screamtime > 5f && enemy.Damage.IsImortal)
					{
						Debug.Log(Object.op_Implicit($"ScoutScreamFix - scout {((Agent)enemy).GlobalID} has been screaming for over 5 seconds, reset state.."));
						enemy.Damage.IsImortal = false;
						scream.m_stateDoneTimer = Clock.Time;
						scream.m_state = (ScoutScreamState)3;
						hasbeenreset = true;
					}
				}
			}
		}

		[HarmonyPatch]
		private class Scout1
		{
			[HarmonyPatch(typeof(ES_ScoutScream), "CommonUpdate")]
			[HarmonyPrefix]
			[HarmonyWrapSafe]
			public static bool Prefix(ES_ScoutScream __instance)
			{
				if (((Object)((Component)((ES_Base)__instance).m_enemyAgent).gameObject).name == "fixrun")
				{
					return true;
				}
				((Component)((ES_Base)__instance).m_enemyAgent).gameObject.AddComponent<ScoutWatch>().Attach(__instance);
				Debug.Log(Object.op_Implicit($"ScoutScreamFix - scream detected, attaching fixer to enemy {((Agent)((ES_Base)__instance).m_enemyAgent).GlobalID}"));
				((Object)((Component)((ES_Base)__instance).m_enemyAgent).gameObject).name = "fixrun";
				return true;
			}
		}

		public override void Load()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			ClassInjector.RegisterTypeInIl2Cpp<ScoutWatch>();
			new Harmony("gaa").PatchAll();
			Debug.Log(Object.op_Implicit("ScoutScreamFix - scouts better behave or we will send her to Croatia"));
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "ScoutScreamFix";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const bool GitIsDirty = false;
	}
}