Decompiled source of LessAnnoyingSmolkr v1.0.3

LessAnnoyingSmolkr.dll

Decompiled 2 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 BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SSSGame;
using SSSGame.AI;
using SSSGame.AI.FSM;
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("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LessAnnoyingSmolkr")]
[assembly: AssemblyTitle("LessAnnoyingSmolkr")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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.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;
		}
	}
	[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 LessAnnoyingSmolkr
{
	[BepInPlugin("blacks7ar.LessAnnoyingSmolkr", "LessAnnoyingSmolkr", "1.0.3")]
	public class Plugin : BasePlugin
	{
		[HarmonyPatch]
		private static class Patch
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(Creature), "Update")]
			private static void Spawned_Postfix(Creature __instance)
			{
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Expected O, but got Unknown
				try
				{
					if ((Object)(object)__instance == (Object)null || !((Object)__instance).name.Contains("Smolkr"))
					{
						return;
					}
					IFSMBehaviourController behaviourController = __instance._behaviourController;
					if (behaviourController == null)
					{
						return;
					}
					vFSMState currentState = behaviourController.CurrentState;
					if ((Object)(object)currentState == (Object)null)
					{
						return;
					}
					string name = ((Object)currentState).name;
					List<vFSMState> states = behaviourController.Behaviour.states;
					if (states?._items != null && ((IEnumerable<vFSMState>)states._items).ToDictionary((vFSMState state) => ((Object)state).name, (vFSMState state) => state).TryGetValue("Go Home", out var value) && name.Equals("GoToStorage"))
					{
						IControlAI aiController = behaviourController.AiController;
						if (aiController != null && (aiController.IsNearDestination || aiController.RemainingDistance <= 2f))
						{
							behaviourController.ChangeState(value);
						}
					}
				}
				catch (Exception ex)
				{
					ManualLogSource lLogger = LLogger;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Exception thrown while trying to change state: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					lLogger.LogError(val);
				}
			}
		}

		private const string modGUID = "blacks7ar.LessAnnoyingSmolkr";

		public const string modName = "LessAnnoyingSmolkr";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.0.3";

		private static ManualLogSource LLogger;

		public override void Load()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			LLogger = ((BasePlugin)this).Log;
			LLogger.LogInfo((object)"Mod loaded!");
			new Harmony("blacks7ar.LessAnnoyingSmolkr").PatchAll();
		}
	}
}