Decompiled source of Free Single Ship Decorations v1.0.0

BepInEx/plugins/LCModFreeSingleShipDecorations.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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LCModFreeSingleShipDecorations.Patches;
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("LCModFreeSingleShipDecorations")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCModFreeSingleShipDecorations")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("18427af3-fa21-4b40-8a7a-3ca47884441a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCModFreeSingleShipDecorations
{
	[BepInPlugin("7ph.dev.lcmodfreesingleshipdecorations", "LC Mod - Free Single Ship Decorations", "1.0.0")]
	public class ModeBase : BaseUnityPlugin
	{
		private const string modGUID = "7ph.dev.lcmodfreesingleshipdecorations";

		private const string modName = "LC Mod - Free Single Ship Decorations";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("7ph.dev.lcmodfreesingleshipdecorations");

		public static ModeBase Instance;

		internal ManualLogSource mls;

		public ManualLogSource Mls => mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("7ph.dev.lcmodfreesingleshipdecorations");
			mls.LogInfo((object)"LC Mod - Free Single Ship Decorations initialized");
			harmony.PatchAll(typeof(ModeBase));
			harmony.PatchAll(typeof(TerminalPatch));
		}
	}
}
namespace LCModFreeSingleShipDecorations.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("RotateShipDecorSelection")]
		[HarmonyPostfix]
		private static void changeShownDecorationPrices(ref List<TerminalNode> ___ShipDecorSelection)
		{
			if (___ShipDecorSelection.Count > 1)
			{
				___ShipDecorSelection.RemoveRange(1, ___ShipDecorSelection.Count - 1);
			}
			foreach (TerminalNode item in ___ShipDecorSelection)
			{
				ModeBase.Instance.mls.LogInfo((object)("Overriding the price of ship decoration (" + ((object)item).ToString() + ")"));
				item.itemCost = 0;
			}
		}

		[HarmonyPatch("LoadNewNodeIfAffordable")]
		[HarmonyPrefix]
		private static void changeDecorationPrices(TerminalNode node, ref List<TerminalNode> ___ShipDecorSelection)
		{
			UnlockableItem val = ((node.shipUnlockableID == -1) ? null : StartOfRound.Instance.unlockablesList.unlockables[node.shipUnlockableID]);
			if (val != null && ___ShipDecorSelection.Contains(val.shopSelectionNode))
			{
				ModeBase.Instance.mls.LogInfo((object)("Overriding the price of ship decoration (" + ((object)node).ToString() + ")"));
				node.itemCost = 0;
			}
		}
	}
}