diff --git a/TweaksAndThings/Patches/CarInspector_PopulateCarPanel_Patch.cs b/TweaksAndThings/Patches/CarInspector_PopulateCarPanel_Patch.cs index 1d86828..b367792 100644 --- a/TweaksAndThings/Patches/CarInspector_PopulateCarPanel_Patch.cs +++ b/TweaksAndThings/Patches/CarInspector_PopulateCarPanel_Patch.cs @@ -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(); - IEnumerable consist = car._set.Cars; + IEnumerable 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 consist = car._set.Cars; + IEnumerable 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)); diff --git a/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs b/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs index 6e8b31c..69eee66 100644 --- a/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs +++ b/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs @@ -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 {