mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-17 17:59:39 -06:00
Patch inspector button recalc based on consist brake || air system changes
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user