mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-18 02:09:37 -06:00
@@ -20,7 +20,7 @@ This mod requires Railloader by Zamu.
|
|||||||
3. Run the game and enjoy all of the tweaks and things!
|
3. Run the game and enjoy all of the tweaks and things!
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
1. This mod currently supports Railroader verison 2024.4.4. This mod may break in future updates. I will do my best to continue to update this mod.
|
1. This mod currently supports Railroader version 2024.4.4. This mod may break in future updates. I will do my best to continue to update this mod.
|
||||||
2. It is possible that the developers of Railroader will implement their own fix for this issue. At such time this mod will be deprecated and no longer maintained.
|
2. It is possible that the developers of Railroader will implement their own fix for this issue. At such time this mod will be deprecated and no longer maintained.
|
||||||
3. As the saying goes, use mods at your own risk.
|
3. As the saying goes, use mods at your own risk.
|
||||||
|
|
||||||
@@ -29,13 +29,13 @@ This mod requires Railloader by Zamu.
|
|||||||
**PLEASE READ AS THE WAY THIS MOD FUNCTIONS HAS CHANGED FROM PRIOR VERSIONS**
|
**PLEASE READ AS THE WAY THIS MOD FUNCTIONS HAS CHANGED FROM PRIOR VERSIONS**
|
||||||
|
|
||||||
1. Car Inspector : Handbrake & Air Line Helper
|
1. Car Inspector : Handbrake & Air Line Helper
|
||||||
* Gives two buttons that will scan the current car's connections, including the whole consist, and automatically release handbrakes, set anglecocks and connect glad hands.
|
* Gives two buttons that will scan the current car's connections, including the whole consist, and automatically release hand brakes, set anglecocks and connect glad hands.
|
||||||
2. Car Tag Updates
|
2. Car Tag Updates
|
||||||
* Shows an indication of which cars in the FOV have Air System or Handbrake issues.
|
* Shows an indication of which cars in the FOV have Air System or Handbrake issues.
|
||||||
* **hold SHIFT** to only show the tags in the FOV for cars with an issue!
|
* **hold SHIFT** to only show the tags in the FOV for cars with an issue!
|
||||||
3. Discord Webhooks
|
3. Discord Webhooks
|
||||||
* Allows the console messages to post to a discord webhook. useful for those wanting to keep an eye on 24/7 hosted saves.
|
* Allows the console messages to post to a discord webhook. useful for those wanting to keep an eye on 24/7 hosted saves.
|
||||||
* Locomotive messages grab the locomotive `Ident.RoadNumber` and check the `CTC Panel Markers` if they exist. If found, they will use the red/green color and embed the locmotive as an image in the message. If no marker is found, it defaults to blue.
|
* Locomotive messages grab the locomotive `Ident.RoadNumber` and check the `CTC Panel Markers` if they exist. If found, they will use the red/green color and embed the locomotive as an image in the message. If no marker is found, it defaults to blue.
|
||||||
* Currently, One person per server should have this per discord webhook, otherwise you will get duplicate messages to the webhook.
|
* Currently, One person per server should have this per discord webhook, otherwise you will get duplicate messages to the webhook.
|
||||||
* **Multiple hooks**: Allows for many different webhooks per client to be setup, and filtered to the `Ident.ReportingMark` so you can get messages to different hooks based on what save/server you are playing on.
|
* **Multiple hooks**: Allows for many different webhooks per client to be setup, and filtered to the `Ident.ReportingMark` so you can get messages to different hooks based on what save/server you are playing on.
|
||||||
* **Customizable** from the in-game Railloader settings, find `RMROC451.TweaksAndThings`
|
* **Customizable** from the in-game Railloader settings, find `RMROC451.TweaksAndThings`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace TweaksAndThings.Enums;
|
namespace RMROC451.TweaksAndThings.Enums;
|
||||||
|
|
||||||
public enum EngineRosterFuelDisplayColumn
|
public enum EngineRosterFuelDisplayColumn
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace TweaksAndThings.Enums;
|
namespace RMROC451.TweaksAndThings.Enums;
|
||||||
|
|
||||||
public enum MrocHelperType
|
public enum MrocHelperType
|
||||||
{
|
{
|
||||||
|
|||||||
40
TweaksAndThings/Extensions/Car_Extensions.cs
Normal file
40
TweaksAndThings/Extensions/Car_Extensions.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using Model;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Extensions
|
||||||
|
{
|
||||||
|
public static class Car_Extensions
|
||||||
|
{
|
||||||
|
public static bool EndAirSystemIssue(this Car car)
|
||||||
|
{
|
||||||
|
bool AEndAirSystemIssue = car[Car.LogicalEnd.A].IsCoupled && !car[Car.LogicalEnd.A].IsAirConnectedAndOpen;
|
||||||
|
bool BEndAirSystemIssue = car[Car.LogicalEnd.B].IsCoupled && !car[Car.LogicalEnd.B].IsAirConnectedAndOpen;
|
||||||
|
bool EndAirSystemIssue = AEndAirSystemIssue || BEndAirSystemIssue;
|
||||||
|
return EndAirSystemIssue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HandbrakeApplied(this Model.Car car) =>
|
||||||
|
car.air.handbrakeApplied;
|
||||||
|
|
||||||
|
public static bool CarOrEndGearIssue(this Model.Car car) =>
|
||||||
|
car.EndAirSystemIssue() || car.HandbrakeApplied();
|
||||||
|
|
||||||
|
public static bool CarAndEndGearIssue(this Model.Car car) =>
|
||||||
|
car.EndAirSystemIssue() && car.HandbrakeApplied();
|
||||||
|
|
||||||
|
public static Car? DetermineFuelCar(this Car engine, bool returnEngineIfNull = false)
|
||||||
|
{
|
||||||
|
Car? car;
|
||||||
|
if (engine is SteamLocomotive steamLocomotive && new Func<Car>(steamLocomotive.FuelCar) != null)
|
||||||
|
{
|
||||||
|
car = steamLocomotive.FuelCar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
car = engine is DieselLocomotive ? engine : null;
|
||||||
|
if (returnEngineIfNull && car == null) car = engine;
|
||||||
|
}
|
||||||
|
return car;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,16 +3,17 @@ using Game.State;
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using KeyValue.Runtime;
|
using KeyValue.Runtime;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TweaksAndThings.Enums;
|
|
||||||
using UI.Builder;
|
using UI.Builder;
|
||||||
using UI.CarInspector;
|
using UI.CarInspector;
|
||||||
using static Model.Car;
|
using static Model.Car;
|
||||||
|
|
||||||
namespace TweaksAndThings.Patches;
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
[HarmonyPatch(typeof(CarInspector))]
|
[HarmonyPatch(typeof(CarInspector))]
|
||||||
[HarmonyPatch(nameof(CarInspector.PopulateCarPanel), typeof(UIPanelBuilder))]
|
[HarmonyPatch(nameof(CarInspector.PopulateCarPanel), typeof(UIPanelBuilder))]
|
||||||
@@ -22,7 +23,7 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
private static IEnumerable<LogicalEnd> ends = Enum.GetValues(typeof(LogicalEnd)).Cast<LogicalEnd>();
|
private static IEnumerable<LogicalEnd> ends = Enum.GetValues(typeof(LogicalEnd)).Cast<LogicalEnd>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If a caboose inspector is opened, it will auto set Anglecocks, gladhands and handbrakes
|
/// If a caboose inspector is opened, it will auto set Anglecocks, gladhands and hand brakes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="__instance"></param>
|
/// <param name="__instance"></param>
|
||||||
/// <param name="builder"></param>
|
/// <param name="builder"></param>
|
||||||
@@ -90,6 +91,16 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//var dh = new DownloadHandlerAudioClip($"file://{cacheFileName}", AudioType.MPEG);
|
||||||
|
//dh.compressed = true; // This
|
||||||
|
|
||||||
|
//using (UnityWebRequest wr = new UnityWebRequest($"file://{cacheFileName}", "GET", dh, null)) {
|
||||||
|
// yield return wr.SendWebRequest();
|
||||||
|
// if (wr.responseCode == 200) {
|
||||||
|
// audioSource.clip = dh.audioClip;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType)
|
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType)
|
||||||
{
|
{
|
||||||
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
||||||
@@ -104,7 +115,9 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
|
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
|
||||||
tc.ApplyHandbrakesAsNeeded(consist.ToList(), PlaceTrainHandbrakes.Automatic);
|
|
||||||
|
//when ApplyHandbrakesAsNeeded is called, and the consist contains an engine, it stops applying brakes.
|
||||||
|
tc.ApplyHandbrakesAsNeeded(consist.Where(c => c.DetermineFuelCar(true) != null).ToList(), PlaceTrainHandbrakes.Automatic);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,22 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Model;
|
using Model;
|
||||||
using Model.Definition;
|
|
||||||
using Model.Definition.Data;
|
using Model.Definition.Data;
|
||||||
using Model.OpsNew;
|
using Model.OpsNew;
|
||||||
using Model.Physics;
|
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Settings;
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
using UI;
|
using UI;
|
||||||
using UI.Builder;
|
|
||||||
using UI.EngineRoster;
|
using UI.EngineRoster;
|
||||||
using UI.Tooltips;
|
using UI.Tooltips;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static Model.Car;
|
|
||||||
|
|
||||||
|
|
||||||
namespace TweaksAndThings.Patches;
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
[HarmonyPatch(typeof(EngineRosterRow))]
|
[HarmonyPatch(typeof(EngineRosterRow))]
|
||||||
[HarmonyPatch(nameof(EngineRosterRow.Refresh))]
|
[HarmonyPatch(nameof(EngineRosterRow.Refresh))]
|
||||||
@@ -48,7 +44,7 @@ public class EngineRosterRow_Refresh_Patch
|
|||||||
List<LoadSlot> loadSlots = __instance._engine.Definition.LoadSlots;
|
List<LoadSlot> loadSlots = __instance._engine.Definition.LoadSlots;
|
||||||
if (!loadSlots.Any())
|
if (!loadSlots.Any())
|
||||||
{
|
{
|
||||||
engineOrTender = DetermineFuelCar(__instance._engine);
|
engineOrTender = __instance._engine.DetermineFuelCar()!;
|
||||||
loadSlots = engineOrTender != null ? engineOrTender.Definition.LoadSlots : Enumerable.Empty<LoadSlot>().ToList();
|
loadSlots = engineOrTender != null ? engineOrTender.Definition.LoadSlots : Enumerable.Empty<LoadSlot>().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,22 +97,4 @@ public class EngineRosterRow_Refresh_Patch
|
|||||||
|
|
||||||
return $"{Mathf.FloorToInt(num):D2}%";
|
return $"{Mathf.FloorToInt(num):D2}%";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Car DetermineFuelCar(BaseLocomotive engine)
|
|
||||||
{
|
|
||||||
Car car;
|
|
||||||
if (engine is SteamLocomotive steamLocomotive && new Func<Car>(steamLocomotive.FuelCar) != null)
|
|
||||||
{
|
|
||||||
car = steamLocomotive.FuelCar();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!(engine is DieselLocomotive))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Unable to detect locomotive fuel source for {engine}");
|
|
||||||
}
|
|
||||||
car = engine;
|
|
||||||
}
|
|
||||||
return car;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@ using HarmonyLib;
|
|||||||
using Helpers;
|
using Helpers;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Settings;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -15,7 +14,7 @@ using System.Text.RegularExpressions;
|
|||||||
using Track.Signals.Panel;
|
using Track.Signals.Panel;
|
||||||
using UI.Console;
|
using UI.Console;
|
||||||
|
|
||||||
namespace TweaksAndThings.Patches;
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
[HarmonyPatch(typeof(ExpandedConsole))]
|
[HarmonyPatch(typeof(ExpandedConsole))]
|
||||||
[HarmonyPatch(nameof(ExpandedConsole.Add))]
|
[HarmonyPatch(nameof(ExpandedConsole.Add))]
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
using Model;
|
using Model;
|
||||||
using Model.OpsNew;
|
using Model.OpsNew;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
using UI;
|
using UI;
|
||||||
using UI.Tags;
|
using UI.Tags;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace TweaksAndThings.Patches;
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
[HarmonyPatch(typeof(TagController))]
|
[HarmonyPatch(typeof(TagController))]
|
||||||
[HarmonyPatch(nameof(TagController.UpdateTag), typeof(Car), typeof(TagCallout), typeof(OpsController))]
|
[HarmonyPatch(nameof(TagController.UpdateTag), typeof(Car), typeof(TagCallout), typeof(OpsController))]
|
||||||
@@ -55,23 +56,3 @@ public class TagController_UpdateTag_Patch
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ModelCarExtensions
|
|
||||||
{
|
|
||||||
public static bool EndAirSystemIssue(this Model.Car car)
|
|
||||||
{
|
|
||||||
bool AEndAirSystemIssue = car[Car.LogicalEnd.A].IsCoupled && !car[Car.LogicalEnd.A].IsAirConnectedAndOpen;
|
|
||||||
bool BEndAirSystemIssue = car[Car.LogicalEnd.B].IsCoupled && !car[Car.LogicalEnd.B].IsAirConnectedAndOpen;
|
|
||||||
bool EndAirSystemIssue = AEndAirSystemIssue || BEndAirSystemIssue;
|
|
||||||
return EndAirSystemIssue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool HandbrakeApplied(this Model.Car car) =>
|
|
||||||
car.air.handbrakeApplied;
|
|
||||||
|
|
||||||
public static bool CarOrEndGearIssue(this Model.Car car) =>
|
|
||||||
car.EndAirSystemIssue() || car.HandbrakeApplied();
|
|
||||||
|
|
||||||
public static bool CarAndEndGearIssue(this Model.Car car) =>
|
|
||||||
car.EndAirSystemIssue() && car.HandbrakeApplied();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
|
|
||||||
namespace RMROC451.TweaksAndThings.Settings;
|
namespace RMROC451.TweaksAndThings;
|
||||||
|
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
using GalaSoft.MvvmLight.Messaging;
|
// Ignore Spelling: RMROC
|
||||||
|
|
||||||
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
using Game.State;
|
using Game.State;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Settings;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using TweaksAndThings.Enums;
|
|
||||||
using UI.Builder;
|
using UI.Builder;
|
||||||
using static Model.Car;
|
|
||||||
|
|
||||||
namespace TweaksAndThings
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings;
|
||||||
|
|
||||||
|
public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHandler, IModTabHandler
|
||||||
{
|
{
|
||||||
public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHandler, IModTabHandler
|
|
||||||
{
|
|
||||||
private HttpClient client;
|
private HttpClient client;
|
||||||
internal HttpClient Client
|
internal HttpClient Client
|
||||||
{
|
{
|
||||||
@@ -100,7 +101,7 @@ namespace TweaksAndThings
|
|||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
).Tooltip("Enable Fuel Display in Engine Roster", $"Will add remaing fuel indication to Engine Roster (with details in roster row tooltip), Examples : {string.Join(" ", Enumerable.Range(0,4).Select(i => TextSprites.PiePercent(i, 4)))}");
|
).Tooltip("Enable Fuel Display in Engine Roster", $"Will add reaming fuel indication to Engine Roster (with details in roster row tool tip), Examples : {string.Join(" ", Enumerable.Range(0,4).Select(i => TextSprites.PiePercent(i, 4)))}");
|
||||||
|
|
||||||
builder.AddField(
|
builder.AddField(
|
||||||
"Always Visible?",
|
"Always Visible?",
|
||||||
@@ -200,5 +201,4 @@ namespace TweaksAndThings
|
|||||||
logger.Information("Nighttime...");
|
logger.Information("Nighttime...");
|
||||||
this.moddingContext.SaveSettingsData(this.modDefinition.Id, settings ?? new());
|
this.moddingContext.SaveSettingsData(this.modDefinition.Id, settings ?? new());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user