Decompiled source of More Gates PlusPlus v1.0.0

moregates++.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using Shared;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HayzeWoodPack")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HayzeWoodPack")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("09bd6439-b47b-403b-8afa-f86d58a6b86f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[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.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 Shared
{
	internal class AssetBundleHelper
	{
		public static AssetBundle GetAssetBundleFromResources(string fileName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(fileName));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}
	}
}
namespace MoreGates
{
	public record Item
	{
		public string asset;

		public string table;

		public string catergory;

		public requirement[] requirements;
	}
	public record requirement
	{
		public string item;

		public int amount;

		public bool recover;
	}
	[BepInPlugin("com.drakemods.Moregates", "MoreGates++", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Mod : BaseUnityPlugin
	{
		private const string Hammer = "Hammer";

		private const string Moregates = "Gates";

		private const string Building = "Building";

		private const string Furniture = "Furniture";

		private const string Misc = "Misc";

		private readonly Harmony harmony = new Harmony("hayze.Moregates");

		private ConfigEntry<bool> enableLift;

		private AssetBundle _bundleFromResources;

		private void Awake()
		{
			LoadConfigs();
			LoadAssets();
			RegisterPrefabs();
			harmony.PatchAll();
		}

		private void LoadConfigs()
		{
			enableLift = ((BaseUnityPlugin)this).Config.Bind<bool>("Items.Toggles", "LiftEnabled", false, "Whether or experimental lift is enabled");
		}

		private void LoadAssets()
		{
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}

		private void RegisterPrefabs()
		{
			_bundleFromResources = AssetBundleHelper.GetAssetBundleFromResources("moregates");
			MakePiece("h_drawbridge01", "Gates", MakeReqs(new string[3] { "Wood", "Iron", "Chain" }, new int[3] { 60, 10, 4 }));
			MakePiece("h_drawbridge02", "Gates", MakeReqs(new string[3] { "Wood", "Bronze", "Chain" }, new int[3] { 55, 8, 4 }));
			MakePiece("lift_gate", "Gates", MakeReqs(new string[3] { "Iron", "Stone", "Chain" }, new int[3] { 20, 8, 4 }));
			MakePiece("lift_gate2", "Gates", MakeReqs(new string[3] { "Wood", "Bronze", "Chain" }, new int[3] { 75, 8, 4 }));
			MakePiece("Hayze_gate_01", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 18 }));
			MakePiece("Hayze_gate_02", "Gates", MakeReqs(new string[3] { "Wood", "RoundLog", "Bronze" }, new int[3] { 20, 20, 20 }));
			MakePiece("Hayze_gate_03", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 15 }));
			MakePiece("Hayze_gate_04", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 18 }));
			MakePiece("Hayze_gate_05", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 15 }));
			MakePiece("Hayze_gate_06", "Gates", MakeReqs(new string[2] { "Wood", "IronNails" }, new int[2] { 18, 3 }));
			MakePiece("h_door_01", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 5 }));
			MakePiece("h_door_02", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 6 }));
			MakePiece("h_door_03", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 6 }));
			MakePiece("h_shutter_01", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 7 }));
			MakePiece("h_trapdoor", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 5 }));
			MakePiece("h_trapdoorbig", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 10 }));
			MakePiece("h_trapdoor2", "Gates", MakeReqs(new string[2] { "Wood", "Iron" }, new int[2] { 5, 1 }));
			MakePiece("h_trapdoorbig2", "Gates", MakeReqs(new string[2] { "Wood", "Iron" }, new int[2] { 10, 2 }));
			MakePiece("Hayze_halfgate_01", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 6 }));
			MakePiece("Hayze_halfgate_02", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 8 }));
			MakePiece("hayzestake_01", "Misc", MakeReqs(new string[2] { "Wood", "RoundLog" }, new int[2] { 4, 7 }));
			MakePiece("h_loglong26", "Building", MakeReqs(new string[1] { "RoundLog" }, new int[1] { 2 }));
			MakePiece("h_loglong45", "Building", MakeReqs(new string[1] { "RoundLog" }, new int[1] { 2 }));
			MakePiece("h_logshort26", "Building", MakeReqs(new string[1] { "RoundLog" }, new int[1] { 1 }));
			MakePiece("h_logshort45", "Building", MakeReqs(new string[1] { "RoundLog" }, new int[1] { 1 }));
			MakePiece("h_window_01", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 10 }));
			MakePiece("h_window_02", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 12 }));
			MakePiece("h_window_03", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 14 }));
			MakePiece("h_window_04", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 14 }));
			MakePiece("h_window_05", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 14 }));
			MakePiece("h_window_06", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 18 }));
			MakePiece("h_window_07", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_window_08", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_window_09", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_window_10", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_window_11", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_window_12", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_window_13", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_window_14", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 21 }));
			MakePiece("h_chain", "Furniture", MakeReqs(new string[1] { "Chain" }, new int[1] { 1 }));
			if (enableLift.Value)
			{
				MakePiece("h_4x4_lift", "Gates", MakeReqs(new string[1] { "Wood" }, new int[1] { 5 }));
			}
		}

		private void MakePiece(string asset, string category, RequirementConfig[] requirementConfigs)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			GameObject val = _bundleFromResources.LoadAsset<GameObject>(asset);
			PieceConfig val2 = new PieceConfig
			{
				PieceTable = "Hammer",
				Category = category,
				Requirements = requirementConfigs
			};
			PieceManager.Instance.AddPiece(new CustomPiece(val, true, val2));
		}

		private RequirementConfig MakeReq(string material, int amount, bool recover = true)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			return new RequirementConfig
			{
				Item = material,
				Amount = amount,
				Recover = recover
			};
		}

		private RequirementConfig[] MakeReqs(string[] materials, int[] amounts, bool recover = true)
		{
			RequirementConfig[] array = (RequirementConfig[])(object)new RequirementConfig[materials.Length];
			for (int i = 0; i < materials.Length; i++)
			{
				array[i] = MakeReq(materials[i], amounts[i], recover);
			}
			return array;
		}
	}
}