Decompiled source of Free Ship Decorations v1.2.0

BepInEx/plugins/LCModFreeShipDecorations.dll

Decompiled 11 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 LCModFreeShipDecorations;
using LCTutorialMod.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("LCModFreeShipDecorations")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCModFreeShipDecorations")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("68107877-bf89-4c98-b632-65afc2bdff28")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCTutorialMod.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("RotateShipDecorSelection")]
		[HarmonyPostfix]
		private static void changeShownDecorationPrices(ref List<TerminalNode> ___ShipDecorSelection)
		{
			___ShipDecorSelection.Clear();
			for (int i = 0; i < StartOfRound.Instance.unlockablesList.unlockables.Count; i++)
			{
				UnlockableItem val = StartOfRound.Instance.unlockablesList.unlockables[i];
				if ((Object)(object)val.shopSelectionNode != (Object)null && !val.alwaysInStock)
				{
					___ShipDecorSelection.Add(val.shopSelectionNode);
				}
			}
			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;
			}
		}
	}
}
namespace LCModFreeShipDecorations
{
	[BepInPlugin("7ph.dev.lcmodfreeshipdecorations", "LC Mod - Free Ship Decorations", "1.0.0")]
	public class ModeBase : BaseUnityPlugin
	{
		private const string modGUID = "7ph.dev.lcmodfreeshipdecorations";

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

		private const string modVersion = "1.0.0";

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

		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.lcmodfreeshipdecorations");
			mls.LogInfo((object)"LC Mod - Free Ship Decorations initialized");
			harmony.PatchAll(typeof(ModeBase));
			harmony.PatchAll(typeof(TerminalPatch));
		}
	}
}