Decompiled source of GiantScrapEaters v1.0.0

plugins/GiantScrapEaters/GiantScrapEaters.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GiantScrapEaters.Configs;
using GiantScrapEaters.NetcodePatcher;
using Microsoft.CodeAnalysis;
using UnityEngine;
using com.github.zehsteam.SellMyScrap;
using com.github.zehsteam.SellMyScrap.MonoBehaviours;
using com.github.zehsteam.SellMyScrap.ScrapEaters;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GiantScrapEaters")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Scrap eaters as the enemies from the giant specimens mod.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GiantScrapEaters")]
[assembly: AssemblyTitle("GiantScrapEaters")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 GiantScrapEaters
{
	[BepInPlugin("GiantScrapEaters", "GiantScrapEaters", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static class Assets
		{
			public static AssetBundle MainAssetBundle;

			public static void PopulateAssets()
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "giantscrapeatersasset"));
				if ((Object)(object)MainAssetBundle == (Object)null)
				{
					Logger.LogError((object)"Failed to load custom assets.");
				}
			}
		}

		internal static ManualLogSource Logger;

		public static GameObject RedwoodPrefab;

		public static GiantScrapEatersConfig ModConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Assets.PopulateAssets();
			ModConfig = new GiantScrapEatersConfig(((BaseUnityPlugin)this).Config);
			RedwoodPrefab = Assets.MainAssetBundle.LoadAsset<GameObject>("RedwoodGiantScrapEater");
			Logger.LogInfo((object)"Plugin GiantScrapEaters is loaded!");
			ScrapEaterManager.AddScrapEater(RedwoodPrefab, (Func<int>)(() => ModConfig.ConfigRedwoodScrapEater.Value));
			ConfigHelper.AddScrapEaterConfigItem("redwoodGiantWeight", (Action<string>)delegate(string value)
			{
				ModConfig.ConfigRedwoodScrapEater.Value = int.Parse(value);
			}, (Func<string>)(() => ModConfig.ConfigRedwoodScrapEater.Value.ToString()));
			InitializeNetworkBehaviours();
		}

		private void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "GiantScrapEaters";

		public const string PLUGIN_NAME = "GiantScrapEaters";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace GiantScrapEaters.Redwood
{
	internal class RedwoodGiantScrapEater : ScrapEaterExtraBehaviour
	{
		protected override IEnumerator StartAnimation()
		{
			yield return ((MonoBehaviour)this).StartCoroutine(((ScrapEaterExtraBehaviour)this).MoveToPosition(base.spawnPosition, base.startPosition, 2f));
			((ScrapEaterExtraBehaviour)this).PlayOneShotSFX(base.landSFX, base.landIndex, 1f);
			HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
			HUDManager.Instance.ShakeCamera((ScreenShakeType)2);
			yield return (object)new WaitForSeconds(1f);
			((ScrapEaterExtraBehaviour)this).PlayAudioSource(base.movementAudio);
			yield return ((MonoBehaviour)this).StartCoroutine(((ScrapEaterExtraBehaviour)this).MoveToPosition(base.startPosition, base.endPosition, base.movementDuration));
			((ScrapEaterExtraBehaviour)this).StopAudioSource(base.movementAudio);
			yield return (object)new WaitForSeconds(base.pauseDuration);
			((ScrapEaterExtraBehaviour)this).MoveTargetScrapToTargetTransform(base.mouthTransform, base.suckDuration - 0.1f);
			yield return (object)new WaitForSeconds(base.suckDuration);
			yield return (object)new WaitForSeconds(((ScrapEaterExtraBehaviour)this).PlayOneShotSFX(base.eatSFX, 1f));
			yield return (object)new WaitForSeconds(base.pauseDuration);
			((ScrapEaterExtraBehaviour)this).PlayAudioSource(base.movementAudio);
			yield return ((MonoBehaviour)this).StartCoroutine(((ScrapEaterExtraBehaviour)this).MoveToPosition(base.endPosition, base.startPosition, base.movementDuration));
			((ScrapEaterExtraBehaviour)this).StopAudioSource(base.movementAudio);
			yield return (object)new WaitForSeconds(1f);
			((ScrapEaterExtraBehaviour)this).PlayOneShotSFX(base.takeOffSFX, 1f);
			yield return ((MonoBehaviour)this).StartCoroutine(((ScrapEaterExtraBehaviour)this).MoveToPosition(base.startPosition, base.spawnPosition, base.takeOffSFX.length));
		}

		protected override void __initializeVariables()
		{
			((ScrapEaterExtraBehaviour)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "RedwoodGiantScrapEater";
		}
	}
}
namespace GiantScrapEaters.Configs
{
	public class GiantScrapEatersConfig
	{
		public ConfigEntry<int> ConfigRedwoodScrapEater { get; private set; }

		public GiantScrapEatersConfig(ConfigFile configFile)
		{
			ConfigRedwoodScrapEater = configFile.Bind<int>("ScrapEater Options", "Redwood | Spawn Weight", 1, "Spawn weight of the redwood giant scrap eater.");
			ClearUnusedEntries(configFile);
			Plugin.Logger.LogInfo((object)"Setting up config for GiantScrapEaters plugin...");
		}

		private void ClearUnusedEntries(ConfigFile configFile)
		{
			PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
			dictionary.Clear();
			configFile.Save();
		}
	}
}
namespace GiantScrapEaters.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}