Patch inspector button recalc based on consist brake || air system changes

This commit is contained in:
2024-06-16 22:13:03 -05:00
parent ced72acf7c
commit b3546f433d
2 changed files with 20 additions and 6 deletions

View File

@@ -12,7 +12,7 @@
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''"> <PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion> <MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion> <MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
<PatchVersion Condition="'$(PatchVersion)' == ''">0</PatchVersion> <PatchVersion Condition="'$(PatchVersion)' == ''">1</PatchVersion>
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion> <AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion> <FileVersion>$(AssemblyVersion)</FileVersion>
<ProductVersion>$(AssemblyVersion)</ProductVersion> <ProductVersion>$(AssemblyVersion)</ProductVersion>

View File

@@ -46,17 +46,24 @@ public class CarInspector_PopulateCarPanel_Patch
builder.HStack(delegate (UIPanelBuilder hstack) builder.HStack(delegate (UIPanelBuilder hstack)
{ {
hstack.AddButtonCompact("Handbrakes", delegate var consist = __instance._car.EnumerateCoupled(LogicalEnd.A);
var buttonName = $"{(consist.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} {TextSprites.HandbrakeWheel}";
hstack.AddButtonCompact(buttonName, delegate
{ {
MrocConsistHelper(__instance._car, MrocHelperType.Handbrake); MrocConsistHelper(__instance._car, MrocHelperType.Handbrake);
}).Tooltip("Release Consist Handbrakes", "Iterates over each car in this consist and releases handbrakes."); hstack.Rebuild();
if (StateManager.IsHost || true) }).Tooltip(buttonName, $"Iterates over cars in this consist and {(consist.Any(c => c.HandbrakeApplied()) ? "releases" : "sets")} {TextSprites.HandbrakeWheel}.");
if (consist.Any(c => c.EndAirSystemIssue()))
{ {
hstack.AddButtonCompact("Air Lines", delegate hstack.AddButtonCompact("Connect Air Lines", delegate
{ {
MrocConsistHelper(__instance._car, MrocHelperType.GladhandAndAnglecock); MrocConsistHelper(__instance._car, MrocHelperType.GladhandAndAnglecock);
hstack.Rebuild();
}).Tooltip("Connect Consist Air Lines", "Iterates over each car in this consist and connects gladhands and opens anglecocks."); }).Tooltip("Connect Consist Air Lines", "Iterates over each car in this consist and connects gladhands and opens anglecocks.");
} }
hstack.RebuildOnInterval(1f);
}); });
return true; return true;
@@ -70,7 +77,14 @@ public class CarInspector_PopulateCarPanel_Patch
switch (mrocHelperType) switch (mrocHelperType)
{ {
case MrocHelperType.Handbrake: case MrocHelperType.Handbrake:
consist.Do(c => c.SetHandbrake(false)); if (consist.Any(c => c.HandbrakeApplied()))
{
consist.Do(c => c.SetHandbrake(false));
} else
{
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
tc.ApplyHandbrakesAsNeeded(consist.ToList(), PlaceTrainHandbrakes.Automatic);
}
break; break;
case MrocHelperType.GladhandAndAnglecock: case MrocHelperType.GladhandAndAnglecock: