mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-16 09:19:37 -06:00
28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
using HarmonyLib;
|
|
using Model.AI;
|
|
using Railloader;
|
|
using RMROC451.TweaksAndThings.Extensions;
|
|
using Serilog;
|
|
using System.Collections;
|
|
|
|
namespace RMROC451.TweaksAndThings.Patches;
|
|
|
|
[HarmonyPatch(typeof(AutoOiler))]
|
|
[HarmonyPatch(nameof(AutoOiler.Loop))]
|
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
|
internal class AutoOiler_Loop_Patch
|
|
{
|
|
private static ILogger _log => Log.ForContext<AutoOiler_Loop_Patch>();
|
|
|
|
public static bool Prefix(AutoOiler __instance, ref IEnumerator __result)
|
|
{
|
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
|
if (!tweaksAndThings.IsEnabled()) return true;
|
|
bool buttonsHaveCost = tweaksAndThings.EndGearHelpersRequirePayment();
|
|
bool cabooseRequired = tweaksAndThings.RequireConsistCabooseForOilerAndHotboxSpotter() && !__instance._cars.ConsistNoFreight();
|
|
|
|
if (buttonsHaveCost) __result = __instance.MrocAutoOilerLoop(_log, cabooseRequired);
|
|
return !buttonsHaveCost; //only hit this if !buttonsHaveCost, since Loop is a coroutine
|
|
}
|
|
}
|