Decompiled source of SimpleRebalanceMod v1.0.3

SimpleRebalanceMod.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ATS_API.Helpers;
using ATS_API.Recipes.Builders;
using BepInEx;
using Eremite;
using Eremite.Buildings;
using Eremite.Controller;
using Eremite.Model;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("SimpleRebalanceMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My Second Mod for Against The Storm - by Shush")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("SimpleRebalanceMod")]
[assembly: AssemblyTitle("SimpleRebalanceMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 SimpleRebalanceMod
{
	[BepInPlugin("SimpleRebalanceMod", "SimpleRebalanceMod", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		private Harmony harmony;

		private void Awake()
		{
			Instance = this;
			harmony = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SimpleRebalanceMod is loaded!");
		}

		[HarmonyPatch(typeof(MainController), "InitReferences")]
		[HarmonyPostfix]
		private static void PostSetupMainController()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			bool flag = false;
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Initializing post Init References in MainController");
			WorkshopModel val = (WorkshopModel)MB.Settings.GetBuilding(BuildingTypesExtensions.ToName((BuildingTypes)86));
			if (flag)
			{
				GoodModel good = GoodsTypesExtensions.ToGoodModel(GoodsTypesExtensions.ToName((GoodsTypes)38));
				GoodRef val2 = new GoodRef
				{
					good = good,
					amount = 1
				};
				((BuildingModel)val).requiredGoods = (GoodRef[])(object)new GoodRef[1] { val2 };
				((BuildingModel)val).allowedTerrains = (FieldType[])(object)new FieldType[2]
				{
					(FieldType)20,
					(FieldType)40
				};
			}
			WorkshopRecipeBuilder val3 = new WorkshopRecipeBuilder("SimpleRebalanceMod", "Clay Pit Copper", (GoodsTypes)40, 4, 80, (Grade)3);
			val3.AddRequiredIngredients((NameToAmount[])(object)new NameToAmount[1] { NameToAmount.op_Implicit((10, (GoodsTypes)62)) });
			((RecipeBuilder<WorkshopRecipeModel>)(object)val3).AddTags((TagTypes[])(object)new TagTypes[1] { (TagTypes)40 });
			WorkshopRecipeModel[] recipes = val.recipes;
			foreach (WorkshopRecipeModel val4 in recipes)
			{
				val4.producedGood.amount = 6;
				val4.productionTime = 45f;
			}
			WorkshopRecipeModel val5 = ((RecipeBuilder<WorkshopRecipeModel>)(object)val3).Build();
			Array.Resize(ref SO.Settings.recipes, SO.Settings.recipes.Length + 1);
			SO.Settings.recipes[SO.Settings.recipes.Length - 1] = (RecipeModel)(object)val5;
			SO.Settings.recipesCache.cache = null;
			WorkshopRecipeModel[] recipes2 = (WorkshopRecipeModel[])(object)new WorkshopRecipeModel[3]
			{
				val.recipes[0],
				val.recipes[1],
				val5
			};
			val.recipes = recipes2;
			((BuildingModel)val).tags = (BuildingTagModel[])(object)new BuildingTagModel[1] { BuildingTagTypesExtensions.ToBuildingTagModel((BuildingTagTypes)1) };
		}

		[HarmonyPatch(typeof(MainController), "OnServicesReady")]
		[HarmonyPostfix]
		private static void HookMainControllerSetup()
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Performing game initialization on behalf of SimpleRebalanceMod.");
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"The game has loaded {MainController.Instance.Settings.effects.Length} effects.");
		}

		[HarmonyPatch(typeof(MetaController), "OnServicesReady")]
		[HarmonyPrefix]
		private static void HookMetaControllerSetup()
		{
			string item = "Clay Pit Workshop";
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)"adding clay pit to meta state services list");
			MB.MetaStateService.Content.buildings.Add(item);
			MB.MetaStateService.Content.essentialBuildings.Add(item);
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)"clay pit added");
		}

		[HarmonyPatch(typeof(GameController), "StartGame")]
		[HarmonyPostfix]
		private static void HookEveryGameStart()
		{
			bool flag = MB.GameSaveService.IsNewGame();
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"Entered a game. Is this a new game: {flag}.");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SimpleRebalanceMod";

		public const string PLUGIN_NAME = "SimpleRebalanceMod";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}