Decompiled source of Cheaper Fuel Company v1.0.1

Cheaper_Fuel_Company.dll

Decompiled a year ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("Cheaper_Fuel_Company")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cheaper_Fuel_Company")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fb631837-abf8-432d-9854-a054c752c77f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Cheaper_Fuel_CompanyBase;

[BepInPlugin("LCMOD.Cheaper_Fuel_Company", "Cheaper_Fuel_Company", "1.0.0")]
public class Cheaper_Fuel_CompanyBase : BaseUnityPlugin
{
	public const string MODGUID = "LCMOD.Cheaper_Fuel_Company";

	public const string MODNAME = "Cheaper_Fuel_Company";

	public const string MODVERSION = "1.0.0";

	private readonly Harmony harmony = new Harmony("LCMOD.Cheaper_Fuel_Company");

	public static Cheaper_Fuel_CompanyBase Instance;

	public static ManualLogSource logger;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		logger = ((BaseUnityPlugin)this).Logger;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod LCMOD.Cheaper_Fuel_Company is loaded!");
		harmony.PatchAll(Assembly.GetExecutingAssembly());
	}
}
[HarmonyPatch(typeof(Terminal), "LoadNewNodeIfAffordable")]
internal class LoadNewNodeIfAffordablePatch
{
	public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codes)
	{
		List<CodeInstruction> list = codes.ToList();
		for (int i = 0; i < list.Count - 7; i++)
		{
			if (list[i].opcode == OpCodes.Ldarg_1 && list[i + 1].opcode == OpCodes.Ldfld && list[i + 1].operand.ToString().Contains("buyRerouteToMoon") && list[i + 2].opcode == OpCodes.Ldc_I4_M1 && list[i + 4].opcode == OpCodes.Ldarg_0 && list[i + 5].opcode == OpCodes.Ldarg_1 && list[i + 6].opcode == OpCodes.Ldfld && list[i + 6].operand.ToString().Contains("itemCost") && list[i + 7].opcode == OpCodes.Stfld && list[i + 7].operand.ToString().Contains("totalCostOfItems"))
			{
				list[i + 5].opcode = OpCodes.Nop;
				list[i + 6].opcode = OpCodes.Ldc_I4_0;
				list[i + 6].operand = null;
			}
		}
		Cheaper_Fuel_CompanyBase.logger.LogWarning((object)"Terminal::LoadNewNodeIfAffordable: Changing totalCostOfItems to 0 for moons!");
		return list.AsEnumerable();
	}
}