Decompiled source of FatMaker v1.0.0

FatMaker.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 DM;
using FatMaker;
using HarmonyLib;
using Landfall.TABS;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SuperUnits")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("SuperUnits")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace FatMaker;

[BepInPlugin("GeeztJeez.FatMaker", "FatMaker", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
	private static ConfigEntry<float> configFatSize;

	private static ConfigEntry<bool> configEnableMod;

	public static bool Enabled => configEnableMod.Value;

	public static float FatSize => configFatSize.Value;

	private void Awake()
	{
		((MonoBehaviour)this).StartCoroutine("Call");
	}

	private IEnumerator Call()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
		yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
		Debug.Log((object)"Loading FatMaker...");
		SLMALoader.GetInstance();
		_ = ContentDatabase.Instance().LandfallContentDatabase;
		new Harmony("FatMaker").PatchAll();
		GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
		for (int i = 0; i < array.Length; i++)
		{
			if (Object.op_Implicit((Object)(object)array[i].GetComponentInChildren<Unit>()))
			{
				array[i].gameObject.AddComponent<FatMaking>();
			}
		}
		DoConfig();
		((MonoBehaviour)this).StartCoroutine(GenerateSettings());
		Debug.Log((object)"Loaded FatMaker Successfully!");
	}

	private IEnumerator GenerateSettings()
	{
		GlobalSettingsHandler service = null;
		yield return (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)(service = ServiceLocator.GetService<GlobalSettingsHandler>()))));
		List<SettingsInstance> list = service.GameplaySettings.ToList();
		SettingsInstance val2 = new SettingsInstance();
		val2.settingsType = (SettingsType)0;
		val2.options = new string[2] { "On", "Off" };
		val2.currentValue = ((!configEnableMod.Value) ? 1 : 0);
		val2.m_settingsKey = "Use Fat Maker";
		val2.toolTip = "Enables Fat Maker mod.";
		SettingsInstance val3 = val2;
		val3.OnValueChanged += delegate(int val)
		{
			configEnableMod.Value = val == 0;
		};
		list.Add(val3);
		SettingsInstance val4 = new SettingsInstance
		{
			currentSliderValue = configFatSize.Value,
			defaultSliderValue = 1.5f,
			max = 5f,
			min = 0.2f,
			m_settingsKey = "Fat Size",
			settingsType = (SettingsType)1,
			toolTip = "Determines the size of fat. (default: 1.5)"
		};
		val4.OnSliderValueChanged += delegate(float val)
		{
			configFatSize.Value = val;
		};
		list.Add(val4);
		((object)service).GetType().GetField("m_gameplaySettings", (BindingFlags)(-1)).SetValue(service, list.ToArray());
	}

	private void DoConfig()
	{
		configFatSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FatSize", 1.5f, "Determines the size of hip");
		configEnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Fat Maker Mod");
	}
}
public class FatMaking : MonoBehaviour
{
	private Unit unit;

	public float size = 1.5f;

	public void Update()
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		if (Loader.Enabled)
		{
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			if (Object.op_Implicit((Object)(object)unit) && Object.op_Implicit((Object)(object)((Component)((Component)((Component)unit).GetComponentInChildren<Hip>()).gameObject.GetComponentInChildren<SetParent>()).gameObject))
			{
				size = Loader.FatSize;
				Transform transform = ((Component)((Component)((Component)unit).GetComponentInChildren<Hip>()).gameObject.GetComponentInChildren<SetParent>()).gameObject.transform;
				transform.localScale *= size;
				Object.Destroy((Object)(object)this);
			}
		}
	}

	public void Start()
	{
		((Behaviour)this).enabled = Loader.Enabled;
	}
}