mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2026-02-20 19:28:35 -06:00
added Bleed Consist button
This commit is contained in:
@@ -3,5 +3,6 @@
|
|||||||
public enum MrocHelperType
|
public enum MrocHelperType
|
||||||
{
|
{
|
||||||
Handbrake,
|
Handbrake,
|
||||||
GladhandAndAnglecock
|
GladhandAndAnglecock,
|
||||||
|
BleedAirSystem
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,5 +36,7 @@ namespace RMROC451.TweaksAndThings.Extensions
|
|||||||
}
|
}
|
||||||
return car;
|
return car;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool NotMotivePower(this Car car) => car is not BaseLocomotive && car.Archetype != Model.Definition.CarArchetype.Tender;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
using Game.State;
|
using Game.State;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using KeyValue.Runtime;
|
using KeyValue.Runtime;
|
||||||
|
using Model;
|
||||||
using Model.OpsNew;
|
using Model.OpsNew;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings;
|
|
||||||
using RMROC451.TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
using RMROC451.TweaksAndThings.Extensions;
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
@@ -51,12 +51,18 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
|
|
||||||
if (consist.Any(c => c.EndAirSystemIssue()))
|
if (consist.Any(c => c.EndAirSystemIssue()))
|
||||||
{
|
{
|
||||||
hstack.AddButtonCompact("Connect Air Lines", delegate
|
hstack.AddButtonCompact("Connect Air", delegate
|
||||||
{
|
{
|
||||||
MrocConsistHelper(__instance._car, MrocHelperType.GladhandAndAnglecock);
|
MrocConsistHelper(__instance._car, MrocHelperType.GladhandAndAnglecock);
|
||||||
hstack.Rebuild();
|
hstack.Rebuild();
|
||||||
}).Tooltip("Connect Consist Air Lines", "Iterates over each car in this consist and connects gladhands and opens anglecocks.");
|
}).Tooltip("Connect Consist Air", "Iterates over each car in this consist and connects gladhands and opens anglecocks.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hstack.AddButtonCompact("Bleed Consist", delegate
|
||||||
|
{
|
||||||
|
MrocConsistHelper(__instance._car, MrocHelperType.BleedAirSystem);
|
||||||
|
hstack.Rebuild();
|
||||||
|
}).Tooltip("Bleed Air Lines", "Iterates over each car in this consist and bleeds the air out of the lines.");
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -111,16 +117,17 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
||||||
|
|
||||||
Log.Information($"{car} => {mrocHelperType} => {string.Join("/", consist.Select(c => c.ToString()))}");
|
Log.Information($"{car} => {mrocHelperType} => {string.Join("/", consist.Select(c => c.ToString()))}");
|
||||||
|
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
|
||||||
switch (mrocHelperType)
|
switch (mrocHelperType)
|
||||||
{
|
{
|
||||||
case MrocHelperType.Handbrake:
|
case MrocHelperType.Handbrake:
|
||||||
if (consist.Any(c => c.HandbrakeApplied()))
|
if (consist.Any(c => c.HandbrakeApplied()))
|
||||||
{
|
{
|
||||||
consist.Do(c => c.SetHandbrake(false));
|
consist.Do(c => c.SetHandbrake(false));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
|
consist = consist.Where(c => c is not BaseLocomotive && c.Archetype != Model.Definition.CarArchetype.Tender);
|
||||||
consist = consist.Where(c => c.DetermineFuelCar(true) != null);
|
|
||||||
Log.Information($"{car} => {mrocHelperType} => {string.Join("/", consist.Select(c => c.ToString()))}");
|
Log.Information($"{car} => {mrocHelperType} => {string.Join("/", consist.Select(c => c.ToString()))}");
|
||||||
//when ApplyHandbrakesAsNeeded is called, and the consist contains an engine, it stops applying brakes.
|
//when ApplyHandbrakesAsNeeded is called, and the consist contains an engine, it stops applying brakes.
|
||||||
tc.ApplyHandbrakesAsNeeded(consist.ToList(), PlaceTrainHandbrakes.Automatic);
|
tc.ApplyHandbrakesAsNeeded(consist.ToList(), PlaceTrainHandbrakes.Automatic);
|
||||||
@@ -149,6 +156,15 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MrocHelperType.BleedAirSystem:
|
||||||
|
consist = consist.Where(c => c.NotMotivePower());
|
||||||
|
Log.Information($"{car} => {mrocHelperType} => {string.Join("/", consist.Select(c => c.ToString()))}");
|
||||||
|
foreach (Model.Car bleed in consist)
|
||||||
|
{
|
||||||
|
StateManager.ApplyLocal(new PropertyChange(bleed.id, PropertyChange.Control.Bleed, 1));
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user