Decompiled source of Siabudabu v6.3.0

siabudabu.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using LethalLevelLoader;
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("siabudabu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("siabudabu")]
[assembly: AssemblyTitle("siabudabu")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 siabudabu
{
	[BepInPlugin("com.fiufki.siabudabu", "Siabudabu", "6.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.fiufki.siabudabu";

		public const string PluginName = "Siabudabu";

		public const string PluginVersion = "6.3.0";

		internal static ManualLogSource Logger;

		public static siabudabuconfig ModConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			ModConfig = new siabudabuconfig(((BaseUnityPlugin)this).Config);
			AssetBundleLoader.AddOnExtendedModLoadedListener((Action<ExtendedMod>)OnExtendedModRegistered, "fiufki", "Siabudabu");
			AssetBundleLoader.AddOnLethalBundleLoadedListener((Action<AssetBundle>)OnLethalBundleLoaded, "siabudabu.lethalbundle");
			Logger.LogInfo((object)"Siabudabu is loaded.");
		}

		internal static void OnExtendedModRegistered(ExtendedMod extendedMod)
		{
			if ((Object)(object)extendedMod == (Object)null)
			{
				return;
			}
			foreach (ExtendedItem extendedItem in extendedMod.ExtendedItems)
			{
				int configValueForItem = GetConfigValueForItem(extendedItem.Item.itemName);
				if (configValueForItem == 0)
				{
					extendedItem.LevelMatchingProperties = null;
				}
				else if ((Object)(object)extendedItem.LevelMatchingProperties != (Object)null)
				{
					StringWithRarity val = extendedItem.LevelMatchingProperties.planetNames.Find((StringWithRarity p) => p.Name == "597 Siabudabu");
					if (val != null)
					{
						val.Rarity = configValueForItem;
					}
				}
			}
		}

		internal static void OnLethalBundleLoaded(AssetBundle assetBundle)
		{
			if (!((Object)(object)assetBundle == (Object)null))
			{
			}
		}

		private static int GetConfigValueForItem(string itemName)
		{
			if (!(itemName == "Turret Mount"))
			{
				if (itemName == "Do Not Enter Sign")
				{
					return siabudabuconfig.DoNotEnterSignConfig.Value;
				}
				return 0;
			}
			return siabudabuconfig.TurretMountConfig.Value;
		}

		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 class siabudabuconfig
	{
		public static ConfigEntry<int> TurretMountConfig { get; private set; }

		public static ConfigEntry<int> DoNotEnterSignConfig { get; private set; }

		public siabudabuconfig(ConfigFile configFile)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			TurretMountConfig = configFile.Bind<int>("Scraps", "Turret Mount Spawn Weights", 82, new ConfigDescription("Change the spawn weights of the Turret Mount scrap.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 300), Array.Empty<object>()));
			DoNotEnterSignConfig = configFile.Bind<int>("Scraps", "Do Not Enter Sign Spawn Weights", 46, new ConfigDescription("Change the spawn weights of the Do Not Enter Sign scrap.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 300), Array.Empty<object>()));
			ClearUnusedEntries(configFile);
			plugin.Logger.LogInfo((object)"Siabudabu config is loading.");
		}

		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();
		}
	}
}