Compare commits

..

1 Commits

Author SHA1 Message Date
5affe27323 Merge pull request #41 from rmroc451/car-click-actions-and-other-misc-updates
Car click actions and other misc updates
2025-08-16 11:31:10 -05:00
2 changed files with 1 additions and 46 deletions

View File

@@ -2,6 +2,6 @@
<PropertyGroup> <PropertyGroup>
<MajorVersion>2</MajorVersion> <MajorVersion>2</MajorVersion>
<MinorVersion>0</MinorVersion> <MinorVersion>0</MinorVersion>
<PatchVersion>1</PatchVersion> <PatchVersion>0</PatchVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -1,45 +0,0 @@
using HarmonyLib;
using Model;
using Model.Definition;
using Model.Physics;
using Railloader;
using System;
using static Model.Car;
namespace RMROC451.TweaksAndThings.Patches;
[HarmonyPatch(typeof(BaseLocomotive))]
[HarmonyPatch(nameof(BaseLocomotive.FindSourceLocomotive), typeof(LogicalEnd))]
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
internal class BaseLocomotive_FindSourceLocomotive_Patch
{
private static bool Prefix(BaseLocomotive __instance, LogicalEnd searchDirection, ref BaseLocomotive __result)
{
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
if (!tweaksAndThings.IsEnabled()) return true;
__result = FindSourceLocomotive(__instance, searchDirection);
return false;
}
public static BaseLocomotive FindSourceLocomotive(BaseLocomotive __instance, LogicalEnd searchDirection)
{
bool stop = false;
int? num = __instance.set.IndexOfCar(__instance);
if (!num.HasValue)
{
throw new Exception("Couldn't find car in set");
}
int carIndex = num.Value;
LogicalEnd fromEnd = ((searchDirection == LogicalEnd.A) ? LogicalEnd.B : LogicalEnd.A);
Car car;
while (!stop && (car = __instance.set.NextCarConnected(ref carIndex, fromEnd, IntegrationSet.EnumerationCondition.AirAndCoupled, out stop)) != null)
{
if (!(car == __instance) && car is BaseLocomotive baseLocomotive && car.Archetype != CarArchetype.Tender && !baseLocomotive.locomotiveControl.air.IsCutOut)
{
return baseLocomotive;
}
}
return null;
}
}