mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-16 01:09:38 -06:00
Merge pull request #34 from rmroc451/32-buttons-dont-adjust-when-decoupling-as-expected
#32 swap from integration set that was giving inconsistent results, a…
This commit is contained in:
@@ -43,7 +43,7 @@ internal class CarInspector_PopulateCarPanel_Patch
|
||||
if (!tweaksAndThings.IsEnabled) return true;
|
||||
bool buttonsHaveCost = tweaksAndThings.EndGearHelpersRequirePayment();
|
||||
|
||||
var consist = __instance._car._set.Cars;
|
||||
var consist = __instance._car.EnumerateCoupled();
|
||||
builder = AddCarConsistRebuildObservers(builder, consist);
|
||||
|
||||
builder.HStack(delegate (UIPanelBuilder hstack)
|
||||
@@ -122,8 +122,8 @@ internal class CarInspector_PopulateCarPanel_Patch
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.Rebuild();
|
||||
if (car.TagCallout != null) tagController.UpdateTags(CameraSelector.shared._currentCamera.GroundPosition, true); //tagController.UpdateTag(car, car.TagCallout, OpsController.Shared);
|
||||
builder.RebuildOnInterval(.01f);
|
||||
if (car.TagCallout != null) tagController.UpdateTags(CameraSelector.shared._currentCamera.GroundPosition, true);
|
||||
if (ContextMenu.IsShown && ContextMenu.Shared.centerLabel.text == car.DisplayName) CarPickable.HandleShowContextMenu(car);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -151,7 +151,7 @@ internal class CarInspector_PopulateCarPanel_Patch
|
||||
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType, bool buttonsHaveCost)
|
||||
{
|
||||
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
|
||||
IEnumerable<Model.Car> consist = car._set.Cars;
|
||||
IEnumerable<Model.Car> consist = car.EnumerateCoupled();
|
||||
_log.ForContext("car", car).Verbose($"{car} => {mrocHelperType} => {string.Join("/", consist.Select(c => c.ToString()))}");
|
||||
|
||||
CalculateCostIfEnabled(car, mrocHelperType, buttonsHaveCost, consist);
|
||||
@@ -232,7 +232,7 @@ internal class CarInspector_PopulateCarPanel_Patch
|
||||
carIdsCheckedAlready.Add(car.id);
|
||||
|
||||
//check consist, for cabeese
|
||||
IEnumerable<Car> consist = car._set.Cars;
|
||||
IEnumerable<Car> consist = car.EnumerateCoupled();
|
||||
output = consist.FirstOrDefault(c => c.CabooseWithSufficientCrewHours(timeNeeded, carIdsCheckedAlready, decrement));
|
||||
if (output != null) return output; //short out if we are good
|
||||
carIdsCheckedAlready.UnionWith(consist.Select(c => c.id));
|
||||
|
||||
@@ -22,12 +22,12 @@ internal class CarPickable_HandleShowContextMenu_Patch
|
||||
|
||||
bool buttonsHaveCost = tweaksAndThings.EndGearHelpersRequirePayment();
|
||||
ContextMenu shared = ContextMenu.Shared;
|
||||
shared.AddButton(ContextMenuQuadrant.Unused2, $"{(car._set.Cars.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} Consist", SpriteName.Handbrake, delegate
|
||||
shared.AddButton(ContextMenuQuadrant.Unused2, $"{(car.EnumerateCoupled().Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} Consist", SpriteName.Handbrake, delegate
|
||||
{
|
||||
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Handbrake, buttonsHaveCost);
|
||||
});
|
||||
|
||||
if (car._set.Cars.Any(c => c.EndAirSystemIssue()))
|
||||
if (car.EnumerateCoupled().Any(c => c.EndAirSystemIssue()))
|
||||
{
|
||||
shared.AddButton(ContextMenuQuadrant.Unused2, $"Air Up Consist", SpriteName.Select, delegate
|
||||
{
|
||||
@@ -35,7 +35,7 @@ internal class CarPickable_HandleShowContextMenu_Patch
|
||||
});
|
||||
}
|
||||
|
||||
if (car._set.Cars.Any(c => c.SupportsBleed()))
|
||||
if (car.EnumerateCoupled().Any(c => c.SupportsBleed()))
|
||||
{
|
||||
shared.AddButton(ContextMenuQuadrant.Unused2, $"Bleed Consist", SpriteName.Bleed, delegate
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user