Decompiled source of DSPReplicatorPlus v0.0.2

DSPReplicatorPLus.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DspFontPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DspFontPatcher")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81DF3045-8007-4F6A-AAF6-903139D85B6C")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace DSPReplicatorPlus;

[BepInPlugin("Appun.DSP.plugin.DSPReplicatorPlus", "DSPReplicatorPlus", "0.0.2")]
[HarmonyPatch]
public class Main : BaseUnityPlugin
{
	public class LogManager
	{
		public static ManualLogSource Logger;
	}

	public static ConfigEntry<float> speedMultiplier;

	public static ConfigEntry<float> maximumSpeed;

	public static ConfigEntry<KeyCode> KeyConfig;

	public void Start()
	{
		LogManager.Logger = ((BaseUnityPlugin)this).Logger;
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		UI.Create();
	}
}
[HarmonyPatch]
internal class Patch
{
	public static int SelectedRecipeIndexBk = -1;

	public static int currentTypeBk = 1;

	public static RecipeProto resipeBk;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIReplicatorWindow), "_OnUpdate")]
	public static void UIReplicatorWindow_OnUpdate_Postfix(UIReplicatorWindow __instance)
	{
		if (__instance.selectedRecipe != null)
		{
			if (GameMain.sandboxToolsEnabled && __instance.isInstantItem)
			{
				((Selectable)UI.headMax.GetComponent<Button>()).interactable = true;
				((Selectable)UI.head500.GetComponent<Button>()).interactable = true;
				((Selectable)UI.head100.GetComponent<Button>()).interactable = true;
				((Selectable)UI.head50.GetComponent<Button>()).interactable = true;
				((Selectable)UI.head10.GetComponent<Button>()).interactable = true;
				((Selectable)UI.head5.GetComponent<Button>()).interactable = true;
				((Selectable)UI.head1.GetComponent<Button>()).interactable = true;
				((Selectable)UI.endMax.GetComponent<Button>()).interactable = true;
				((Selectable)UI.end500.GetComponent<Button>()).interactable = true;
				((Selectable)UI.end100.GetComponent<Button>()).interactable = true;
				((Selectable)UI.end50.GetComponent<Button>()).interactable = true;
				((Selectable)UI.end10.GetComponent<Button>()).interactable = true;
				((Selectable)UI.end5.GetComponent<Button>()).interactable = true;
				((Selectable)UI.end1.GetComponent<Button>()).interactable = true;
			}
			else if (!__instance.selectedRecipe.Handcraft)
			{
				((Selectable)UI.headMax.GetComponent<Button>()).interactable = false;
				((Selectable)UI.head500.GetComponent<Button>()).interactable = false;
				((Selectable)UI.head100.GetComponent<Button>()).interactable = false;
				((Selectable)UI.head50.GetComponent<Button>()).interactable = false;
				((Selectable)UI.head10.GetComponent<Button>()).interactable = false;
				((Selectable)UI.head5.GetComponent<Button>()).interactable = false;
				((Selectable)UI.head1.GetComponent<Button>()).interactable = false;
				((Selectable)UI.endMax.GetComponent<Button>()).interactable = false;
				((Selectable)UI.end500.GetComponent<Button>()).interactable = false;
				((Selectable)UI.end100.GetComponent<Button>()).interactable = false;
				((Selectable)UI.end50.GetComponent<Button>()).interactable = false;
				((Selectable)UI.end10.GetComponent<Button>()).interactable = false;
				((Selectable)UI.end5.GetComponent<Button>()).interactable = false;
				((Selectable)UI.end1.GetComponent<Button>()).interactable = false;
			}
			else if (__instance.selectedRecipe != null)
			{
				int num = __instance.mechaForge.PredictTaskCount(((Proto)__instance.selectedRecipe).ID, 999);
				int stackSize = ((ProtoSet<ItemProto>)(object)LDB.items).Select(((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(((Proto)__instance.selectedRecipe).ID).Results[0]).StackSize;
				((Selectable)UI.headMax.GetComponent<Button>()).interactable = num > 0;
				((Selectable)UI.head500.GetComponent<Button>()).interactable = num >= 500;
				((Selectable)UI.head100.GetComponent<Button>()).interactable = num >= 100;
				((Selectable)UI.head50.GetComponent<Button>()).interactable = num >= 50;
				((Selectable)UI.head10.GetComponent<Button>()).interactable = num >= 10;
				((Selectable)UI.head5.GetComponent<Button>()).interactable = num >= 5;
				((Selectable)UI.head1.GetComponent<Button>()).interactable = num >= 1;
				((Selectable)UI.endMax.GetComponent<Button>()).interactable = num > 0;
				((Selectable)UI.end500.GetComponent<Button>()).interactable = num >= 500;
				((Selectable)UI.end100.GetComponent<Button>()).interactable = num >= 100;
				((Selectable)UI.end50.GetComponent<Button>()).interactable = num >= 50;
				((Selectable)UI.end10.GetComponent<Button>()).interactable = num >= 10;
				((Selectable)UI.end5.GetComponent<Button>()).interactable = num >= 5;
				((Selectable)UI.end1.GetComponent<Button>()).interactable = num >= 1;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIReplicatorWindow), "OnRecipeMouseDown")]
	public static void UIReplicatorWindow_SetSelectedRecipeIndex_Postfix(UIReplicatorWindow __instance)
	{
		SelectedRecipeIndexBk = __instance.mouseRecipeIndex;
		currentTypeBk = __instance.currentType;
		resipeBk = __instance.selectedRecipe;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIReplicatorWindow), "_OnOpen")]
	public static void UIReplicatorWindow_OnOpen_Postfix(UIReplicatorWindow __instance)
	{
		__instance.selectedRecipe = resipeBk;
		__instance.currentType = currentTypeBk;
		__instance.RefreshRecipeIcons();
		__instance.typeButton1.highlighted = currentTypeBk == 1;
		__instance.typeButton2.highlighted = currentTypeBk == 2;
		((Selectable)__instance.typeButton1.button).interactable = currentTypeBk != 1;
		((Selectable)__instance.typeButton2.button).interactable = currentTypeBk != 2;
		__instance.SetSelectedRecipeIndex(SelectedRecipeIndexBk, true);
		__instance.OnSelectedRecipeChange(true);
	}
}
internal class UI : MonoBehaviour
{
	public static GameObject headTitle = new GameObject();

	public static GameObject headMax = new GameObject();

	public static GameObject headStack = new GameObject();

	public static GameObject head500 = new GameObject();

	public static GameObject head100 = new GameObject();

	public static GameObject head50 = new GameObject();

	public static GameObject head10 = new GameObject();

	public static GameObject head5 = new GameObject();

	public static GameObject head1 = new GameObject();

	public static GameObject endTitle = new GameObject();

	public static GameObject endMax = new GameObject();

	public static GameObject endStack = new GameObject();

	public static GameObject end500 = new GameObject();

	public static GameObject end100 = new GameObject();

	public static GameObject end50 = new GameObject();

	public static GameObject end10 = new GameObject();

	public static GameObject end5 = new GameObject();

	public static GameObject end1 = new GameObject();

	public static float headX = -60f;

	public static float headY = 160f;

	public static float diffX = 120f;

	public static float diffY = 22f;

	public static void Create()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04da: Unknown result type (might be due to invalid IL or missing references)
		//IL_050d: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_060c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0684: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_072f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0762: Unknown result type (might be due to invalid IL or missing references)
		//IL_07da: Unknown result type (might be due to invalid IL or missing references)
		//IL_080d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0885: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0930: Unknown result type (might be due to invalid IL or missing references)
		//IL_0963: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a65: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a86: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a90: Expected O, but got Unknown
		//IL_0aa7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab1: Expected O, but got Unknown
		//IL_0ac8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad2: Expected O, but got Unknown
		//IL_0ae9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0af3: Expected O, but got Unknown
		//IL_0b0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b14: Expected O, but got Unknown
		//IL_0b2b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b35: Expected O, but got Unknown
		//IL_0b4c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b56: Expected O, but got Unknown
		//IL_0b6d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b77: Expected O, but got Unknown
		//IL_0b8e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b98: Expected O, but got Unknown
		//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bb9: Expected O, but got Unknown
		//IL_0bd0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bda: Expected O, but got Unknown
		//IL_0bf1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bfb: Expected O, but got Unknown
		//IL_0c12: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c1c: Expected O, but got Unknown
		//IL_0c33: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c3d: Expected O, but got Unknown
		GameObject gameObject = ((Component)UIRoot.instance.uiGame.replicator.multiValueText).gameObject;
		headTitle = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
		headTitle.transform.localPosition = new Vector3(headX, headY + diffY, 0f);
		headTitle.GetComponent<Text>().text = Localization.Translate("to head");
		GameObject gameObject2 = ((Component)UIRoot.instance.uiGame.replicator.minusButton).gameObject;
		headMax = Object.Instantiate<GameObject>(gameObject2, gameObject2.transform.parent);
		headMax.GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 24f);
		headMax.transform.localPosition = new Vector3(headX, headY, 0f);
		((Component)headMax.transform.Find("text")).GetComponent<Text>().text = Localization.Translate("MAX");
		((Component)headMax.transform.Find("text")).GetComponent<Text>().font = headTitle.GetComponent<Text>().font;
		((Component)headMax.transform.Find("text")).GetComponent<Text>().fontSize = 16;
		head500 = Object.Instantiate<GameObject>(headMax, headMax.transform.parent);
		head500.transform.localPosition = new Vector3(headX, headY - diffY * 1f, 0f);
		((Component)head500.transform.Find("text")).GetComponent<Text>().text = "500";
		head100 = Object.Instantiate<GameObject>(headMax, headMax.transform.parent);
		head100.transform.localPosition = new Vector3(headX, headY - diffY * 2f, 0f);
		((Component)head100.transform.Find("text")).GetComponent<Text>().text = "100";
		head50 = Object.Instantiate<GameObject>(headMax, headMax.transform.parent);
		head50.transform.localPosition = new Vector3(headX, headY - diffY * 3f, 0f);
		((Component)head50.transform.Find("text")).GetComponent<Text>().text = "50";
		head10 = Object.Instantiate<GameObject>(headMax, headMax.transform.parent);
		head10.transform.localPosition = new Vector3(headX, headY - diffY * 4f, 0f);
		((Component)head10.transform.Find("text")).GetComponent<Text>().text = "10";
		head5 = Object.Instantiate<GameObject>(headMax, headMax.transform.parent);
		head5.transform.localPosition = new Vector3(headX, headY - diffY * 5f, 0f);
		((Component)head5.transform.Find("text")).GetComponent<Text>().text = "5";
		head1 = Object.Instantiate<GameObject>(headMax, headMax.transform.parent);
		head1.transform.localPosition = new Vector3(headX, headY - diffY * 6f, 0f);
		((Component)head1.transform.Find("text")).GetComponent<Text>().text = "1";
		GameObject gameObject3 = ((Component)UIRoot.instance.uiGame.replicator.plusButton).gameObject;
		endTitle = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
		endTitle.transform.localPosition = new Vector3(headX + diffX, headY + diffY, 0f);
		endTitle.GetComponent<Text>().text = Localization.Translate("to end");
		endMax = Object.Instantiate<GameObject>(gameObject3, gameObject3.transform.parent);
		endMax.GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 24f);
		endMax.transform.localPosition = new Vector3(headX + diffX, headY, 0f);
		((Component)endMax.transform.Find("text")).transform.localPosition = new Vector3(-1f, 1f, 0f);
		((Component)endMax.transform.Find("text")).GetComponent<Text>().text = Localization.Translate("MAX");
		((Component)endMax.transform.Find("text")).GetComponent<Text>().font = headTitle.GetComponent<Text>().font;
		((Component)endMax.transform.Find("text")).GetComponent<Text>().fontSize = 16;
		end500 = Object.Instantiate<GameObject>(endMax, endMax.transform.parent);
		end500.transform.localPosition = new Vector3(headX + diffX, headY - diffY * 1f, 0f);
		((Component)end500.transform.Find("text")).transform.localPosition = new Vector3(-1f, 1f, 0f);
		((Component)end500.transform.Find("text")).GetComponent<Text>().text = "500";
		end100 = Object.Instantiate<GameObject>(endMax, endMax.transform.parent);
		end100.transform.localPosition = new Vector3(headX + diffX, headY - diffY * 2f, 0f);
		((Component)end100.transform.Find("text")).transform.localPosition = new Vector3(-1f, 1f, 0f);
		((Component)end100.transform.Find("text")).GetComponent<Text>().text = "100";
		end50 = Object.Instantiate<GameObject>(endMax, endMax.transform.parent);
		end50.transform.localPosition = new Vector3(headX + diffX, headY - diffY * 3f, 0f);
		((Component)end50.transform.Find("text")).transform.localPosition = new Vector3(-1f, 1f, 0f);
		((Component)end50.transform.Find("text")).GetComponent<Text>().text = "50";
		end10 = Object.Instantiate<GameObject>(endMax, endMax.transform.parent);
		end10.transform.localPosition = new Vector3(headX + diffX, headY - diffY * 4f, 0f);
		((Component)end10.transform.Find("text")).transform.localPosition = new Vector3(-1f, 1f, 0f);
		((Component)end10.transform.Find("text")).GetComponent<Text>().text = "10";
		end5 = Object.Instantiate<GameObject>(endMax, endMax.transform.parent);
		end5.transform.localPosition = new Vector3(headX + diffX, headY - diffY * 5f, 0f);
		((Component)end5.transform.Find("text")).transform.localPosition = new Vector3(-1f, 1f, 0f);
		((Component)end5.transform.Find("text")).GetComponent<Text>().text = "5";
		end1 = Object.Instantiate<GameObject>(endMax, endMax.transform.parent);
		end1.transform.localPosition = new Vector3(headX + diffX, headY - diffY * 6f, 0f);
		((Component)end1.transform.Find("text")).transform.localPosition = new Vector3(-1f, 1f, 0f);
		((Component)end1.transform.Find("text")).GetComponent<Text>().text = "1";
		GameObject gameObject4 = ((Component)((Component)UIRoot.instance.uiGame.replicator).transform.Find("recipe-tree/ok-btn")).gameObject;
		gameObject4.transform.localPosition = new Vector3(349f, 120f, 0f);
		((Behaviour)((Component)gameObject4.transform.Find("img")).GetComponent<Image>()).enabled = false;
		GameObject gameObject5 = ((Component)gameObject4.transform.Find("pred-count")).gameObject;
		gameObject5.transform.localPosition = new Vector3(0f, 71f, 0f);
		GameObject gameObject6 = ((Component)((Component)UIRoot.instance.uiGame.replicator).transform.Find("recipe-tree/count")).gameObject;
		gameObject6.transform.localPosition = new Vector3(349f, 30f, 0f);
		((UnityEvent)headMax.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickHeadMax));
		((UnityEvent)head500.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickHead500));
		((UnityEvent)head100.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickHead100));
		((UnityEvent)head50.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickHead50));
		((UnityEvent)head10.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickHead10));
		((UnityEvent)head5.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickHead5));
		((UnityEvent)head1.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickHead1));
		((UnityEvent)endMax.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickEndMax));
		((UnityEvent)end500.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickEnd500));
		((UnityEvent)end100.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickEnd100));
		((UnityEvent)end50.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickEnd50));
		((UnityEvent)end10.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickEnd10));
		((UnityEvent)end5.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickEnd5));
		((UnityEvent)end1.GetComponent<Button>().onClick).AddListener(new UnityAction(onClickEnd1));
	}

	public static void onClickEndMax()
	{
		UIReplicatorWindow replicator = UIRoot.instance.uiGame.replicator;
		if (replicator.isInstantItem)
		{
			mechaForgeAddTask(1000);
		}
		else
		{
			mechaForgeAddTask(replicator.mechaForge.PredictTaskCount(((Proto)replicator.selectedRecipe).ID, 999));
		}
	}

	public static void onClickEnd500()
	{
		mechaForgeAddTask(500);
	}

	public static void onClickEnd100()
	{
		mechaForgeAddTask(100);
	}

	public static void onClickEnd50()
	{
		mechaForgeAddTask(50);
	}

	public static void onClickEnd10()
	{
		mechaForgeAddTask(10);
	}

	public static void onClickEnd5()
	{
		mechaForgeAddTask(5);
	}

	public static void onClickEnd1()
	{
		mechaForgeAddTask(1);
	}

	public static void onClickHeadMax()
	{
		UIReplicatorWindow replicator = UIRoot.instance.uiGame.replicator;
		if (replicator.isInstantItem)
		{
			mechaForgeAddTaskHead(1000);
		}
		else
		{
			mechaForgeAddTaskHead(replicator.mechaForge.PredictTaskCount(((Proto)replicator.selectedRecipe).ID, 999));
		}
	}

	public static void onClickHead500()
	{
		mechaForgeAddTaskHead(500);
	}

	public static void onClickHead100()
	{
		mechaForgeAddTaskHead(100);
	}

	public static void onClickHead50()
	{
		mechaForgeAddTaskHead(50);
	}

	public static void onClickHead10()
	{
		mechaForgeAddTaskHead(10);
	}

	public static void onClickHead5()
	{
		mechaForgeAddTaskHead(5);
	}

	public static void onClickHead1()
	{
		mechaForgeAddTaskHead(1);
	}

	public static void mechaForgeAddTask(int count)
	{
		UIReplicatorWindow replicator = UIRoot.instance.uiGame.replicator;
		int iD = ((Proto)replicator.selectedRecipe).ID;
		replicator.mechaForge.AddTask(iD, count);
	}

	public static void mechaForgeAddTaskHead(int count)
	{
		UIReplicatorWindow replicator = UIRoot.instance.uiGame.replicator;
		int iD = ((Proto)replicator.selectedRecipe).ID;
		if (replicator.mechaForge.tasks.Count == 0)
		{
			replicator.mechaForge.AddTask(iD, count);
			return;
		}
		List<ForgeTask> list = new List<ForgeTask>(replicator.mechaForge.tasks);
		replicator.mechaForge.tasks.Clear();
		replicator.mechaForge.AddTask(iD, count);
		int count2 = replicator.mechaForge.tasks.Count;
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].parentTaskIndex >= 0)
			{
				ForgeTask obj = list[i];
				obj.parentTaskIndex += count2;
			}
			replicator.mechaForge.tasks.Add(list[i]);
		}
	}
}