Decompiled source of LethalGiantless v0.0.3

RemoveGiants.dll

Decompiled 5 months ago
using System;
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.Configuration;
using HarmonyLib;
using KillGiants;
using LC_RemoveGiants;
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("RemoveGiants")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Basic Lethal Company mod which removes giants at spawn-time. Must be installed by each player. This has had\r\n        some amount of testing, but could be subject to issues with future patches.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+88d9926e20b7aa8acaf62d63d9ac25308cd271b4")]
[assembly: AssemblyProduct("RemoveGiants")]
[assembly: AssemblyTitle("RemoveGiants")]
[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 KillGiants
{
	[HarmonyPatch(typeof(ForestGiantAI))]
	internal class ForestGiantRemoval
	{
		[HarmonyPatch(typeof(ForestGiantAI), "Start")]
		[HarmonyPostfix]
		public static void RemoveGiant(ForestGiantAI __instance)
		{
			if (Plugin.NumGiants < Plugin.cfgMaxGiants.Value)
			{
				Debug.Log((object)"[RemoveGiant]: Spawned a single giant");
				EnemyAI component = ((Component)__instance).gameObject.GetComponent<EnemyAI>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					Debug.Log((object)"[LethalGiantless]: Failed to find associated AI behaviour!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Bad bad bad");
					return;
				}
				component.syncMovementSpeed *= Plugin.cfgGiantSpeed.Value;
				Plugin.NumGiants++;
			}
			else
			{
				((EnemyAI)__instance).KillEnemyOnOwnerClient(false);
				Object.Destroy((Object)(object)((Component)__instance).gameObject);
				Debug.Log((object)"[RemoveGiant]: Giant Removed (Hopefully)");
			}
		}
	}
}
namespace LC_RemoveGiants
{
	[BepInPlugin("RemoveGiants", "RemoveGiants", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("RemoveGiants");

		public static Plugin _instance;

		public static ConfigEntry<int> cfgMaxGiants;

		public static ConfigEntry<float> cfgGiantSpeed;

		public static int NumGiants;

		private void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			cfgMaxGiants = ((BaseUnityPlugin)this).Config.Bind<int>("Main", "MaxGiants", 0, "");
			cfgGiantSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Main", "GiantMovementSpeed", 1f, "");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RemoveGiants is loaded!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RemoveGiants changed!!!!!!!!!!!!!!!!!!!!!!!!!!!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[RemoveGiants]: Attempting to patch...");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Config] Max Giants: {cfgMaxGiants.Value}");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Config] Giant Move Scalar: {cfgGiantSpeed.Value}");
			_harmony.PatchAll(typeof(ForestGiantRemoval));
			if (_harmony.GetPatchedMethods().Any())
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"[RemoveGiants]: [Awake] - Patch successful!");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RemoveGiants";

		public const string PLUGIN_NAME = "RemoveGiants";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}