mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-17 01:39:38 -06:00
Compare commits
36 Commits
v0.1.4
...
v1.2.1_Exp
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ebd14db2a | |||
| ca0e78b971 | |||
| 9f210b0b8a | |||
| 840f35cf62 | |||
| 786db49b68 | |||
| 108900b026 | |||
| 9e8c38e6f4 | |||
| 89f2490f14 | |||
| fbd08b007c | |||
| 27d3432cbf | |||
| cf1d5e32e5 | |||
| 92317b29b2 | |||
| 1f48bf04aa | |||
| 5774c7f04c | |||
| 5eed492b47 | |||
| d4d18d8c92 | |||
| d7e35828b8 | |||
| 0b444d6364 | |||
| d197ff8d8a | |||
| 89894890b4 | |||
| a13701c3d2 | |||
| b5be17703f | |||
| 35afa4520d | |||
| 80d064c950 | |||
| ec21effd30 | |||
| 2242aaacde | |||
| e26713688b | |||
| 8a228be5a8 | |||
| 2ed33465d9 | |||
| 67d39801de | |||
| 8dc87f312d | |||
| 9cb788d86a | |||
| 2e47536028 | |||
| b6edc93636 | |||
| 6693a762c9 | |||
| fc43d54815 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -396,4 +396,3 @@ FodyWeavers.xsd
|
|||||||
|
|
||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
/TweaksAndThings/Commands/EchoCommand.cs
|
|
||||||
|
|||||||
7
Assembly.version
Normal file
7
Assembly.version
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<MajorVersion>1</MajorVersion>
|
||||||
|
<MinorVersion>2</MinorVersion>
|
||||||
|
<PatchVersion>1</PatchVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<Import Project="Paths.user" Condition="Exists('Paths.user')" />
|
<Import Project="Paths.user" Condition="Exists('Paths.user')" />
|
||||||
|
<Import Project="Assembly.version" Condition="Exists('Assembly.version')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net48</TargetFramework>
|
<TargetFramework>net48</TargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
|||||||
@@ -6,13 +6,14 @@
|
|||||||
<!-- Copy the mod to the game directory -->
|
<!-- Copy the mod to the game directory -->
|
||||||
<GameModDir Condition="'$(GameModDir)' == ''">$(GameDir)/Mods/$(AssemblyName)</GameModDir>
|
<GameModDir Condition="'$(GameModDir)' == ''">$(GameDir)/Mods/$(AssemblyName)</GameModDir>
|
||||||
<OutDir Condition="'$(Configuration)' == 'Debug'">$(GameModDir)/</OutDir>
|
<OutDir Condition="'$(Configuration)' == 'Debug'">$(GameModDir)/</OutDir>
|
||||||
|
<VersionTimestamp>$([System.DateTime]::UtcNow.ToString(`o`))</VersionTimestamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Replace the default version if something was set for it -->
|
<!-- Replace the default version if something was set for it -->
|
||||||
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
||||||
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
|
<MajorVersion Condition="'$(MajorVersion)' == ''">1</MajorVersion>
|
||||||
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
||||||
<PatchVersion Condition="'$(PatchVersion)' == ''">5</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>
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
<!-- Publish the mod as a neat zip file -->
|
<!-- Publish the mod as a neat zip file -->
|
||||||
<Target Name="PrepareForPublishing" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Release'">
|
<Target Name="PrepareForPublishing" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Release'">
|
||||||
<!-- Replace $(AssemblyVersion) with the actual version -->
|
<!-- Replace $(AssemblyVersion) with the actual version -->
|
||||||
<Exec Command="powershell -Command "(Get-Content '$(OutputPath)Definition.json') -replace '\$\(AssemblyVersion\)', '$(AssemblyVersion)' | Set-Content '$(OutputPath)Definition.json'"" />
|
<Exec Command="powershell -Command "(Get-Content '$(OutputPath)Definition.json') -replace '\$\(AssemblyVersion\)', '$(AssemblyVersion)_$(VersionTimestamp)' | Set-Content '$(OutputPath)Definition.json'"" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ModsDirectory>$(OutputPath)/Mods</ModsDirectory>
|
<ModsDirectory>$(OutputPath)/Mods</ModsDirectory>
|
||||||
@@ -38,7 +39,7 @@
|
|||||||
|
|
||||||
<!-- Folder we'll put the published zips into -->
|
<!-- Folder we'll put the published zips into -->
|
||||||
<PublishPath>../bin</PublishPath>
|
<PublishPath>../bin</PublishPath>
|
||||||
<ZipName>$(PublishPath)/$(AssemblyName)_$(AssemblyVersion).zip</ZipName>
|
<ZipName>$(PublishPath)/$(AssemblyName)_$(AssemblyVersion)_Experimental.zip</ZipName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Assure the output path exists -->
|
<!-- Assure the output path exists -->
|
||||||
|
|||||||
6
Paths.user.example
Normal file
6
Paths.user.example
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- Directory that the game (Railroader.exe) is in -->
|
||||||
|
<GameDir></GameDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.4.33122.133
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{452A23A6-81C8-49C6-A7EE-95FD9377F896}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{452A23A6-81C8-49C6-A7EE-95FD9377F896}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
.gitignore = .gitignore
|
||||||
|
Assembly.version = Assembly.version
|
||||||
Directory.Build.props = Directory.Build.props
|
Directory.Build.props = Directory.Build.props
|
||||||
Directory.Build.targets = Directory.Build.targets
|
Directory.Build.targets = Directory.Build.targets
|
||||||
Paths.user = Paths.user
|
Paths.user = Paths.user
|
||||||
|
|||||||
44
TweaksAndThings/Commands/CrewUpdateCommand.cs
Normal file
44
TweaksAndThings/Commands/CrewUpdateCommand.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using Game.State;
|
||||||
|
using Helpers;
|
||||||
|
using Model.Ops;
|
||||||
|
using Network;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
using System.Linq;
|
||||||
|
using UI.Console;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Commands;
|
||||||
|
|
||||||
|
[ConsoleCommand("/cu", "generate a formatted message about a locomotive's status.")]
|
||||||
|
public class EchoCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Execute(string[] comps)
|
||||||
|
{
|
||||||
|
if (comps.Length < 4)
|
||||||
|
{
|
||||||
|
return "Usage: /cu <car>|. +|- <message>";
|
||||||
|
}
|
||||||
|
|
||||||
|
string query = comps[1];
|
||||||
|
Model.Car car = query == "." ? TrainController.Shared.SelectedLocomotive : TrainController.Shared.CarForString(query);
|
||||||
|
|
||||||
|
if (car.DetermineFuelCar() == null)
|
||||||
|
{
|
||||||
|
return "Car not found.";
|
||||||
|
}
|
||||||
|
string message = string.Join(" ", comps.Skip(3)).Truncate(512);
|
||||||
|
|
||||||
|
switch (comps[2])
|
||||||
|
{
|
||||||
|
case "+":
|
||||||
|
break;
|
||||||
|
case "-":
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return "+ to include area or - to leave it out";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comps[2] == "+") message += $" {OpsController.Shared.ClosestArea(car)?.name ?? "???"}";
|
||||||
|
Multiplayer.Broadcast($"{StateManager.Shared._playersManager.LocalPlayer} {Hyperlink.To(car)}: \"{message}\"");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,17 @@
|
|||||||
"requires": [
|
"requires": [
|
||||||
{
|
{
|
||||||
"id": "railloader",
|
"id": "railloader",
|
||||||
"notBefore": "1.8.1"
|
"notBefore": "1.9.6.8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Zamu.StrangeCustoms",
|
||||||
|
"notBefore": "1.10.24358.413"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"assemblies": [ "RMROC451.TweaksAndThings" ]
|
"assemblies": [ "RMROC451.TweaksAndThings" ],
|
||||||
|
"mixintos": {
|
||||||
|
"container:ne-caboose01": "file(mroc-cabeese.json)",
|
||||||
|
"container:ne-caboose02": "file(mroc-cabeese.json)",
|
||||||
|
"container:ne-caboose03": "file(mroc-cabeese.json)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,5 +3,6 @@
|
|||||||
public enum MrocHelperType
|
public enum MrocHelperType
|
||||||
{
|
{
|
||||||
Handbrake,
|
Handbrake,
|
||||||
GladhandAndAnglecock
|
GladhandAndAnglecock,
|
||||||
|
BleedAirSystem
|
||||||
}
|
}
|
||||||
|
|||||||
118
TweaksAndThings/Extensions/AutoEngineer_Extensions.cs
Normal file
118
TweaksAndThings/Extensions/AutoEngineer_Extensions.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using Model.AI;
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Extensions
|
||||||
|
{
|
||||||
|
internal static class AutoEngineer_Extensions
|
||||||
|
{
|
||||||
|
private static float CabooseHalvedFloat(this float input, Model.Car? hasCaboose) =>
|
||||||
|
hasCaboose ? input / 2 : input;
|
||||||
|
|
||||||
|
private static float CabooseAutoOilerLimit(this Model.Car? caboose) =>
|
||||||
|
caboose ? 0.99f : AutoOiler.OilIfBelow;
|
||||||
|
|
||||||
|
public static IEnumerator MrocAutoOilerLoop(this AutoOiler oiler, Serilog.ILogger _log, bool cabooseRequired)
|
||||||
|
{
|
||||||
|
int originIndex = oiler.FindOriginIndex();
|
||||||
|
Model.Car? foundCaboose = oiler._cars.CabooseInConsist();
|
||||||
|
if (originIndex < 0)
|
||||||
|
{
|
||||||
|
_log.Error("Couldn't find origin car {car}", oiler._originCar);
|
||||||
|
oiler._coroutine = null;
|
||||||
|
yield break;
|
||||||
|
} else if (CabooseRequirementChecker(string.Format("{0} {1}", oiler.GetType().Name, oiler.name), cabooseRequired, foundCaboose, _log))
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
oiler._reverse = originIndex > oiler._cars.Count - originIndex;
|
||||||
|
_log.Information(
|
||||||
|
"AutoOiler {name} starting, rev = {reverse}, caboose required = {req}, caboose halving adjustment = {hasCaboose}, oil limit = {limit}",
|
||||||
|
oiler.name,
|
||||||
|
oiler._reverse,
|
||||||
|
cabooseRequired,
|
||||||
|
foundCaboose,
|
||||||
|
foundCaboose.CabooseAutoOilerLimit()
|
||||||
|
);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(AutoOiler.StartDelay.CabooseHalvedFloat(foundCaboose));
|
||||||
|
int carIndex = originIndex;
|
||||||
|
float adjustedTimeToWalk = AutoOiler.TimeToWalkCar.CabooseHalvedFloat(foundCaboose);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (oiler.TryGetCar(carIndex, out var car))
|
||||||
|
{
|
||||||
|
float num = 0f;
|
||||||
|
float origOil = car.Oiled;
|
||||||
|
if (car.NeedsOiling && car.Oiled < foundCaboose.CabooseAutoOilerLimit())
|
||||||
|
{
|
||||||
|
float num2 = 1f - car.Oiled;
|
||||||
|
car.OffsetOiled(num2);
|
||||||
|
float num3 = num2 * AutoOiler.TimeToFullyOil.CabooseHalvedFloat(foundCaboose);
|
||||||
|
num += num3;
|
||||||
|
oiler._pendingRunDuration += num3;
|
||||||
|
oiler._oiledCount++;
|
||||||
|
_log.Information("AutoOiler {name}: oiled {car} from {orig} => {new}", oiler.name, car, origOil, car.Oiled);
|
||||||
|
}
|
||||||
|
if (car.HasHotbox && car.Oiled == 1f && cabooseRequired && foundCaboose)
|
||||||
|
{
|
||||||
|
_log.Information("AutoOiler {name}: {foundCaboose} repaired hotbox {car}", oiler.name, foundCaboose, car);
|
||||||
|
car.AdjustHotboxValue(0f);
|
||||||
|
}
|
||||||
|
num += adjustedTimeToWalk;
|
||||||
|
oiler._pendingRunDuration += adjustedTimeToWalk;
|
||||||
|
yield return new WaitForSeconds(num);
|
||||||
|
}
|
||||||
|
carIndex = oiler.NextIndex(carIndex);
|
||||||
|
}
|
||||||
|
while (oiler.InBounds(carIndex));
|
||||||
|
oiler._reverse = !oiler._reverse;
|
||||||
|
oiler.PayWages();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerator MrocAutoHotboxSpotterLoop(this AutoHotboxSpotter spotter, Serilog.ILogger _log, bool cabooseRequired)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Model.Car? foundCaboose = spotter._cars.CabooseInConsist();
|
||||||
|
if (!spotter.HasCars)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(1f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_log.Information("AutoHotboxSpotter {name}: Hotbox Spotter Running, Found Caboose => {hasCaboose}; Has Cars {hasCars}; Requires Caboose {requiresCaboose}",
|
||||||
|
spotter.name, foundCaboose, spotter.HasCars, cabooseRequired);
|
||||||
|
foundCaboose = spotter._cars.CabooseInConsist();
|
||||||
|
if (CabooseRequirementChecker(string.Format("{0} {1}", spotter.GetType().Name, spotter.name), cabooseRequired, foundCaboose, _log))
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
spotter.CheckForHotbox();
|
||||||
|
while (spotter.HasCars)
|
||||||
|
{
|
||||||
|
int num = Random.Range(60, 300);
|
||||||
|
foundCaboose = spotter._cars.CabooseInConsist();
|
||||||
|
if (foundCaboose)
|
||||||
|
{
|
||||||
|
var numOrig = num;
|
||||||
|
num = Random.Range(15, 30);
|
||||||
|
_log.Information("AutoHotboxSpotter {name}: Next check went from num(60,300) => {numOrig}; to num(15,30) => {hasCaboose}; Requires Caboose {requiresCaboose}", spotter.name, numOrig, num, foundCaboose, cabooseRequired);
|
||||||
|
}
|
||||||
|
yield return new WaitForSeconds(num);
|
||||||
|
spotter.CheckForHotbox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool CabooseRequirementChecker(string name, bool cabooseRequired, Model.Car? foundCaboose, Serilog.ILogger _log)
|
||||||
|
{
|
||||||
|
bool error = cabooseRequired && foundCaboose == null;
|
||||||
|
if (error) {
|
||||||
|
_log.Debug("{name}: Couldn't find required caboose!", name);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,27 @@
|
|||||||
using Model;
|
using Game.Messages;
|
||||||
|
using Game.State;
|
||||||
|
using Helpers;
|
||||||
|
using Model;
|
||||||
|
using Model.Definition.Data;
|
||||||
|
using Model.Ops;
|
||||||
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace RMROC451.TweaksAndThings.Extensions
|
namespace RMROC451.TweaksAndThings.Extensions;
|
||||||
|
|
||||||
|
public static class Car_Extensions
|
||||||
{
|
{
|
||||||
public static class Car_Extensions
|
private static bool EndGearIssue(this Car car, Car.LogicalEnd end) =>
|
||||||
{
|
(!car[end].IsCoupled && car[end].IsAnglecockOpen) ||
|
||||||
|
(car[end].IsCoupled && !car[end].IsAirConnectedAndOpen);
|
||||||
|
|
||||||
public static bool EndAirSystemIssue(this Car car)
|
public static bool EndAirSystemIssue(this Car car)
|
||||||
{
|
{
|
||||||
bool AEndAirSystemIssue = car[Car.LogicalEnd.A].IsCoupled && !car[Car.LogicalEnd.A].IsAirConnectedAndOpen;
|
bool AEndAirSystemIssue = car.EndGearIssue(Car.LogicalEnd.A);
|
||||||
bool BEndAirSystemIssue = car[Car.LogicalEnd.B].IsCoupled && !car[Car.LogicalEnd.B].IsAirConnectedAndOpen;
|
bool BEndAirSystemIssue = car.EndGearIssue(Car.LogicalEnd.B);
|
||||||
bool EndAirSystemIssue = AEndAirSystemIssue || BEndAirSystemIssue;
|
bool EndAirSystemIssue = AEndAirSystemIssue || BEndAirSystemIssue;
|
||||||
return EndAirSystemIssue;
|
return EndAirSystemIssue;
|
||||||
}
|
}
|
||||||
@@ -24,6 +37,7 @@ namespace RMROC451.TweaksAndThings.Extensions
|
|||||||
|
|
||||||
public static Car? DetermineFuelCar(this Car engine, bool returnEngineIfNull = false)
|
public static Car? DetermineFuelCar(this Car engine, bool returnEngineIfNull = false)
|
||||||
{
|
{
|
||||||
|
if (engine == null) return null;
|
||||||
Car? car;
|
Car? car;
|
||||||
if (engine is SteamLocomotive steamLocomotive && new Func<Car>(steamLocomotive.FuelCar) != null)
|
if (engine is SteamLocomotive steamLocomotive && new Func<Car>(steamLocomotive.FuelCar) != null)
|
||||||
{
|
{
|
||||||
@@ -36,5 +50,88 @@ 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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For every car in the consist, cost 1 minute of AI Engineer time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="consist"></param>
|
||||||
|
public static int CalculateCostForAutoEngineerEndGearSetting(this IEnumerable<Car> consist) =>
|
||||||
|
consist.Count() * 60;
|
||||||
|
|
||||||
|
public static bool IsCaboose(this Car car) => car.Archetype == Model.Definition.CarArchetype.Caboose;
|
||||||
|
|
||||||
|
public static bool IsCabooseAndStoppedForLoadRefresh(this Car car) => car.IsCaboose() && car.IsStopped(30f);
|
||||||
|
|
||||||
|
public static Car? CabooseInConsist(this IEnumerable<Car> input) => input.FirstOrDefault(c => c.IsCaboose());
|
||||||
|
|
||||||
|
public static Car? CabooseWithSufficientCrewHours(this Car car, float timeNeeded, HashSet<string> carIdsCheckedAlready, bool decrement = false)
|
||||||
|
{
|
||||||
|
Car? output = null;
|
||||||
|
if (carIdsCheckedAlready.Contains(car.id) || !car.IsCaboose()) return null;
|
||||||
|
|
||||||
|
List<LoadSlot> loadSlots = car.Definition.LoadSlots;
|
||||||
|
for (int i = 0; i < loadSlots.Count; i++)
|
||||||
|
{
|
||||||
|
CarLoadInfo? loadInfo = car.GetLoadInfo(i);
|
||||||
|
if (loadInfo.HasValue)
|
||||||
|
{
|
||||||
|
CarLoadInfo valueOrDefault = loadInfo.GetValueOrDefault();
|
||||||
|
output = valueOrDefault.Quantity >= timeNeeded ? car : null;
|
||||||
|
if (decrement && output != null) output.SetLoadInfo(i, valueOrDefault with { Quantity = valueOrDefault.Quantity - timeNeeded });
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Car? HuntingForCabeeseNearCar(this Car car, float timeNeeded, TrainController tc, HashSet<string> carIdsCheckedAlready, bool decrement = false)
|
||||||
|
{
|
||||||
|
List<(string carId, float distance)> source =
|
||||||
|
CarsNearCurrentCar(car, timeNeeded, tc, carIdsCheckedAlready, decrement);
|
||||||
|
|
||||||
|
Car output = FindNearestCabooseFromNearbyCars(tc, source);
|
||||||
|
if (output != null) output.CabooseWithSufficientCrewHours(timeNeeded, carIdsCheckedAlready, decrement);
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Car FindNearestCabooseFromNearbyCars(TrainController tc, List<(string carId, float distance)> source) =>
|
||||||
|
(
|
||||||
|
from t in source
|
||||||
|
where t.distance < 21f //todo: add setting slider for catchment
|
||||||
|
orderby t.distance ascending
|
||||||
|
select tc.CarForId(t.carId)
|
||||||
|
).FirstOrDefault();
|
||||||
|
|
||||||
|
private static List<(string carId, float distance)> CarsNearCurrentCar(Car car, float timeNeeded, TrainController tc, HashSet<string> carIdsCheckedAlready, bool decrement)
|
||||||
|
{
|
||||||
|
Vector3 position = car.GetMotionSnapshot().Position;
|
||||||
|
Vector3 center = WorldTransformer.WorldToGame(position);
|
||||||
|
Rect rect = new Rect(new Vector2(center.x - 30f, center.z - 30f), Vector2.one * 30f * 2f);
|
||||||
|
var cars = tc.CarIdsInRect(rect);
|
||||||
|
Log.Information($"{nameof(HuntingForCabeeseNearCar)} => {cars.Count()}");
|
||||||
|
List<(string carId, float distance)> source =
|
||||||
|
cars
|
||||||
|
.Select(carId =>
|
||||||
|
{
|
||||||
|
Car car = tc.CarForId(carId);
|
||||||
|
if (car == null || !car.CabooseWithSufficientCrewHours(timeNeeded, carIdsCheckedAlready))
|
||||||
|
{
|
||||||
|
return (carId: carId, distance: 1000f);
|
||||||
|
}
|
||||||
|
Vector3 a = WorldTransformer.WorldToGame(car.GetMotionSnapshot().Position);
|
||||||
|
return (carId: carId, distance: Vector3.Distance(a, center));
|
||||||
|
}).ToList();
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AdjustHotboxValue(this Car car, float hotboxValue) =>
|
||||||
|
StateManager.ApplyLocal(
|
||||||
|
new PropertyChange(
|
||||||
|
car.id, PropertyChange.KeyForControl(PropertyChange.Control.Hotbox),
|
||||||
|
new FloatPropertyValue(hotboxValue)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
28
TweaksAndThings/Extensions/Load_Extensions.cs
Normal file
28
TweaksAndThings/Extensions/Load_Extensions.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using Core;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Extensions;
|
||||||
|
|
||||||
|
public static class Load_Extensions
|
||||||
|
{
|
||||||
|
//https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings?redirectedfrom=MSDN#the--section-separator
|
||||||
|
//https://dotnetfiddle.net/iHVevM
|
||||||
|
public static string FormatCrewHours(this float quantity, string description)
|
||||||
|
{
|
||||||
|
var ts = TimeSpan.FromHours(quantity);
|
||||||
|
float minutes = ts.Minutes - (ts.Minutes % 15);
|
||||||
|
|
||||||
|
string output = string.Format("{0:;;No}{1:##}{2:\\.##;\\.##;.} {3} {4}",
|
||||||
|
ts.Hours + minutes,
|
||||||
|
ts.Hours, (minutes / 60.0f) * 100,
|
||||||
|
description,
|
||||||
|
"Hour".Pluralize(quantity == 1 ? 1 : 0)
|
||||||
|
).Trim();
|
||||||
|
|
||||||
|
if (ts.Hours < 1)
|
||||||
|
{
|
||||||
|
output = string.Format("{0} {1} Minutes", ts.Minutes, description).Trim();
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using Model.AI;
|
||||||
|
using Railloader;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
using Serilog;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(AutoHotboxSpotter))]
|
||||||
|
[HarmonyPatch(nameof(AutoHotboxSpotter.SpotterLoop))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class AutoHotboxSpotter_SpotterLoop_Patch
|
||||||
|
{
|
||||||
|
private static ILogger _log => Log.ForContext<AutoHotboxSpotter_SpotterLoop_Patch>();
|
||||||
|
|
||||||
|
public static bool Prefix(AutoHotboxSpotter __instance, ref IEnumerator __result)
|
||||||
|
{
|
||||||
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
|
if (!tweaksAndThings.IsEnabled) return true;
|
||||||
|
bool buttonsHaveCost = tweaksAndThings.EndGearHelpersRequirePayment();
|
||||||
|
bool cabooseRequired = tweaksAndThings.RequireConsistCabooseForOilerAndHotboxSpotter();
|
||||||
|
|
||||||
|
if (buttonsHaveCost) __result = __instance.MrocAutoHotboxSpotterLoop(_log, cabooseRequired);
|
||||||
|
return !buttonsHaveCost; //only hit this if !buttonsHaveCost, since Loop is a coroutine
|
||||||
|
}
|
||||||
|
}
|
||||||
27
TweaksAndThings/Patches/AutoOiler_Loop_Patch.cs
Normal file
27
TweaksAndThings/Patches/AutoOiler_Loop_Patch.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using Model.AI;
|
||||||
|
using Railloader;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
using Serilog;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(AutoOiler))]
|
||||||
|
[HarmonyPatch(nameof(AutoOiler.Loop))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class AutoOiler_Loop_Patch
|
||||||
|
{
|
||||||
|
private static ILogger _log => Log.ForContext<AutoOiler_Loop_Patch>();
|
||||||
|
|
||||||
|
public static bool Prefix(AutoOiler __instance, ref IEnumerator __result)
|
||||||
|
{
|
||||||
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
|
if (!tweaksAndThings.IsEnabled) return true;
|
||||||
|
bool buttonsHaveCost = tweaksAndThings.EndGearHelpersRequirePayment();
|
||||||
|
bool cabooseRequired = tweaksAndThings.RequireConsistCabooseForOilerAndHotboxSpotter();
|
||||||
|
|
||||||
|
if (buttonsHaveCost) __result = __instance.MrocAutoOilerLoop(_log, cabooseRequired);
|
||||||
|
return !buttonsHaveCost; //only hit this if !buttonsHaveCost, since Loop is a coroutine
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,23 @@
|
|||||||
using Game.Messages;
|
using Core;
|
||||||
|
using Game.Messages;
|
||||||
using Game.State;
|
using Game.State;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using KeyValue.Runtime;
|
using KeyValue.Runtime;
|
||||||
|
using Model;
|
||||||
|
using Network;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
using RMROC451.TweaksAndThings.Extensions;
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
using RollingStock;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UI;
|
||||||
using UI.Builder;
|
using UI.Builder;
|
||||||
using UI.CarInspector;
|
using UI.CarInspector;
|
||||||
|
using UI.ContextMenu;
|
||||||
|
using UI.Tags;
|
||||||
using static Model.Car;
|
using static Model.Car;
|
||||||
|
|
||||||
namespace RMROC451.TweaksAndThings.Patches;
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
@@ -18,8 +25,9 @@ namespace RMROC451.TweaksAndThings.Patches;
|
|||||||
[HarmonyPatch(typeof(CarInspector))]
|
[HarmonyPatch(typeof(CarInspector))]
|
||||||
[HarmonyPatch(nameof(CarInspector.PopulateCarPanel), typeof(UIPanelBuilder))]
|
[HarmonyPatch(nameof(CarInspector.PopulateCarPanel), typeof(UIPanelBuilder))]
|
||||||
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
public class CarInspector_PopulateCarPanel_Patch
|
internal class CarInspector_PopulateCarPanel_Patch
|
||||||
{
|
{
|
||||||
|
private static ILogger _log => Log.ForContext<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>
|
||||||
@@ -31,58 +39,97 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
private static bool Prefix(CarInspector __instance, UIPanelBuilder builder)
|
private static bool Prefix(CarInspector __instance, UIPanelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
||||||
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
if (!tweaksAndThings.IsEnabled) return true;
|
if (!tweaksAndThings.IsEnabled) return true;
|
||||||
|
bool buttonsHaveCost = tweaksAndThings.EndGearHelpersRequirePayment();
|
||||||
|
|
||||||
var consist = __instance._car.EnumerateCoupled(LogicalEnd.A);
|
var consist = __instance._car.EnumerateCoupled();
|
||||||
builder = AddCarConsistRebuildObservers(builder, consist);
|
|
||||||
|
|
||||||
builder.HStack(delegate (UIPanelBuilder hstack)
|
builder.HStack(delegate (UIPanelBuilder hstack)
|
||||||
{
|
{
|
||||||
|
hstack = AddCarConsistRebuildObservers(hstack, consist);
|
||||||
var buttonName = $"{(consist.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} {TextSprites.HandbrakeWheel}";
|
var buttonName = $"{(consist.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} {TextSprites.HandbrakeWheel}";
|
||||||
hstack.AddButtonCompact(buttonName, delegate
|
hstack.AddButtonCompact(buttonName, delegate
|
||||||
{
|
{
|
||||||
MrocConsistHelper(__instance._car, MrocHelperType.Handbrake);
|
MrocConsistHelper(__instance._car, MrocHelperType.Handbrake, buttonsHaveCost);
|
||||||
hstack.Rebuild();
|
hstack.Rebuild();
|
||||||
}).Tooltip(buttonName, $"Iterates over cars in this consist and {(consist.Any(c => c.HandbrakeApplied()) ? "releases" : "sets")} {TextSprites.HandbrakeWheel}.");
|
}).Tooltip(buttonName, $"Iterates over cars in this consist and {(consist.Any(c => c.HandbrakeApplied()) ? "releases" : "sets")} {TextSprites.HandbrakeWheel}.");
|
||||||
|
|
||||||
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, buttonsHaveCost);
|
||||||
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, buttonsHaveCost);
|
||||||
|
hstack.Rebuild();
|
||||||
|
}).Tooltip("Bleed Air Lines", "Iterates over each car in this consist and bleeds the air out of the lines.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CabooseUiEnhancer(__instance, builder, consist, tweaksAndThings);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CabooseUiEnhancer(CarInspector __instance, UIPanelBuilder builder, IEnumerable<Car> consist, TweaksAndThingsPlugin plugin)
|
||||||
|
{
|
||||||
|
if (plugin.CabooseNonMotiveAllowedSetting(__instance._car))
|
||||||
|
{
|
||||||
|
builder.HStack(delegate (UIPanelBuilder hstack)
|
||||||
|
{
|
||||||
|
hstack.AddField("Consist Info", hstack.HStack(delegate (UIPanelBuilder field)
|
||||||
|
{
|
||||||
|
int consistLength = consist.Count();
|
||||||
|
int tonnage = LocomotiveControlsHoverArea.CalculateTonnage(consist);
|
||||||
|
int lengthInMeters = UnityEngine.Mathf.CeilToInt(LocomotiveControlsHoverArea.CalculateLengthInMeters(consist.ToList()) * 3.28084f);
|
||||||
|
var newSubTitle = () => string.Format("{0}, {1:N0}T, {2:N0}ft, {3:0.0} mph", consistLength.Pluralize("car"), tonnage, lengthInMeters, __instance._car.VelocityMphAbs);
|
||||||
|
|
||||||
|
field.AddLabel(() => newSubTitle(), UIPanelBuilder.Frequency.Fast)
|
||||||
|
.Tooltip("Consist Info", "Reflects info about consist.").FlexibleWidth();
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static UIPanelBuilder AddCarConsistRebuildObservers(UIPanelBuilder builder, IEnumerable<Model.Car> consist)
|
private static UIPanelBuilder AddCarConsistRebuildObservers(UIPanelBuilder builder, IEnumerable<Model.Car> consist)
|
||||||
{
|
{
|
||||||
foreach (Model.Car car in consist)
|
TagController tagController = UnityEngine.Object.FindFirstObjectByType<TagController>();
|
||||||
|
foreach (Model.Car car in consist.Where(c => c.Archetype != Model.Definition.CarArchetype.Tender))
|
||||||
{
|
{
|
||||||
builder = AddObserver(builder, car, PropertyChange.KeyForControl(PropertyChange.Control.Handbrake));
|
builder = AddObserver(builder, car, PropertyChange.KeyForControl(PropertyChange.Control.Handbrake), tagController);
|
||||||
foreach (LogicalEnd logicalEnd in ends)
|
foreach (LogicalEnd logicalEnd in ends)
|
||||||
{
|
{
|
||||||
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsCoupled, car.LogicalToEnd(logicalEnd)));
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsCoupled, car.LogicalToEnd(logicalEnd)), tagController);
|
||||||
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsAirConnected, car.LogicalToEnd(logicalEnd)));
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsAirConnected, car.LogicalToEnd(logicalEnd)), tagController);
|
||||||
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.Anglecock, car.LogicalToEnd(logicalEnd)));
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.Anglecock, car.LogicalToEnd(logicalEnd)), tagController);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UIPanelBuilder AddObserver(UIPanelBuilder builder, Model.Car car, string key)
|
private static UIPanelBuilder AddObserver(UIPanelBuilder builder, Model.Car car, string key, TagController tagController)
|
||||||
{
|
{
|
||||||
builder.AddObserver(
|
builder.AddObserver(
|
||||||
car.KeyValueObject.Observe(
|
car.KeyValueObject.Observe(
|
||||||
key,
|
key,
|
||||||
delegate (Value value)
|
delegate (Value value)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
_log.ForContext("car", car).Warning(ex, $"{nameof(AddObserver)} {car} Exception logged for {key}");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
@@ -101,22 +148,24 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType)
|
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType, bool buttonsHaveCost)
|
||||||
{
|
{
|
||||||
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
|
||||||
|
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);
|
||||||
|
|
||||||
Log.Information($"{car} => {mrocHelperType} => {string.Join("/", consist.Select(c => c.ToString()))}");
|
|
||||||
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()))}");
|
|
||||||
//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);
|
||||||
}
|
}
|
||||||
@@ -136,14 +185,66 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (c.TryGetAdjacentCar(end, out Model.Car c2))
|
if (c.TryGetAdjacentCar(end, out Model.Car c2)) StateManager.ApplyLocal(new SetGladhandsConnected(c.id, c2.id, true));
|
||||||
{
|
|
||||||
StateManager.ApplyLocal(new SetGladhandsConnected(c.id, c2.id, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MrocHelperType.BleedAirSystem:
|
||||||
|
consist = consist.Where(c => c.NotMotivePower());
|
||||||
|
_log.ForContext("car", car).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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CalculateCostIfEnabled(Car car, MrocHelperType mrocHelperType, bool buttonsHaveCost, IEnumerable<Car> consist)
|
||||||
|
{
|
||||||
|
if (buttonsHaveCost)
|
||||||
|
{
|
||||||
|
float originalTimeCost = consist.CalculateCostForAutoEngineerEndGearSetting();
|
||||||
|
float timeCost = originalTimeCost;
|
||||||
|
float crewCost = timeCost / 3600; //hours of time deducted from caboose.
|
||||||
|
var tsString = crewCost.FormatCrewHours(OpsController_AnnounceCoalescedPayments_Patch.CrewHoursLoad().description);
|
||||||
|
Car? cabooseWithAvailCrew = NearbyCabooseWithAvailableCrew(car, crewCost, buttonsHaveCost);
|
||||||
|
if (cabooseWithAvailCrew == null) timeCost *= 1.5f;
|
||||||
|
var cabooseFoundDisplay = cabooseWithAvailCrew?.DisplayName ?? "No caboose";
|
||||||
|
|
||||||
|
_log.ForContext("car", car).Information($"{nameof(MrocConsistHelper)} {mrocHelperType} : [VACINITY CABEESE FOUND:{cabooseWithAvailCrew?.ToString() ?? "NONE"}] => Consist Length {consist.Count()} => costs {timeCost / 60} minutes of AI Engineer time, $5 per hour = ~${Math.Ceiling((decimal)(timeCost / 3600) * 5)} (*2 if no caboose nearby)");
|
||||||
|
|
||||||
|
|
||||||
|
Multiplayer.SendError(StateManager.Shared._playersManager.LocalPlayer, $"{(cabooseWithAvailCrew != null ? $"{cabooseWithAvailCrew.DisplayName} Hours Adjusted: ({tsString})\n" : string.Empty)}Wages: ~(${Math.Ceiling((decimal)(timeCost / 3600) * 5)})");
|
||||||
|
|
||||||
|
StateManager_OnDayDidChange_Patch.UnbilledAutoBrakeCrewRunDuration += timeCost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Car? NearbyCabooseWithAvailableCrew(Car car, float timeNeeded, bool decrement = false)
|
||||||
|
{
|
||||||
|
HashSet<string> carIdsCheckedAlready = new();
|
||||||
|
|
||||||
|
//check current car.
|
||||||
|
Car? output = car.CabooseWithSufficientCrewHours(timeNeeded, carIdsCheckedAlready, decrement);
|
||||||
|
if (output != null) return output; //short out if we are good
|
||||||
|
carIdsCheckedAlready.Add(car.id);
|
||||||
|
|
||||||
|
//check consist, for cabeese
|
||||||
|
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));
|
||||||
|
|
||||||
|
//then check near consist cars for cabeese
|
||||||
|
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
|
||||||
|
foreach (var c in consist)
|
||||||
|
{
|
||||||
|
output = c.HuntingForCabeeseNearCar(timeNeeded, tc, carIdsCheckedAlready, decrement);
|
||||||
|
if (output != null) return output; //short out if we are good
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
52
TweaksAndThings/Patches/CarPickable_Activate_Patch.cs
Normal file
52
TweaksAndThings/Patches/CarPickable_Activate_Patch.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using Railloader;
|
||||||
|
using RollingStock;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(CarPickable))]
|
||||||
|
[HarmonyPatch(nameof(CarPickable.Activate), typeof(PickableActivateEvent))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class CarPickable_Activate_Patch
|
||||||
|
{
|
||||||
|
|
||||||
|
static float clicked = 0;
|
||||||
|
static float clicktime = 0;
|
||||||
|
static float clickdelay = 0.5f;
|
||||||
|
|
||||||
|
private static bool Prefix(CarPickable __instance, PickableActivateEvent evt)
|
||||||
|
{
|
||||||
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
|
if (!tweaksAndThings.IsEnabled) return true;
|
||||||
|
|
||||||
|
if (OnPointerDown(evt))
|
||||||
|
{
|
||||||
|
CameraSelector.shared.FollowCar(__instance.car);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnPointerDown(PickableActivateEvent evt)
|
||||||
|
{
|
||||||
|
bool output = false;
|
||||||
|
if (evt.Activation == PickableActivation.Primary)
|
||||||
|
{
|
||||||
|
clicked++;
|
||||||
|
if (clicked == 1) clicktime = Time.time;
|
||||||
|
|
||||||
|
if (clicked > 1 && Time.time - clicktime < clickdelay)
|
||||||
|
{
|
||||||
|
clicked = 0;
|
||||||
|
clicktime = 0;
|
||||||
|
output = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (clicked > 2 || Time.time - clicktime > 1) clicked = 0;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using Model;
|
||||||
|
using Railloader;
|
||||||
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
using RollingStock;
|
||||||
|
using System.Linq;
|
||||||
|
using UI;
|
||||||
|
using UI.ContextMenu;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(CarPickable))]
|
||||||
|
[HarmonyPatch(nameof(CarPickable.HandleShowContextMenu), typeof(Car))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class CarPickable_HandleShowContextMenu_Patch
|
||||||
|
{
|
||||||
|
private static void Postfix(Car car)
|
||||||
|
{
|
||||||
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
|
if (!tweaksAndThings.IsEnabled) return;
|
||||||
|
|
||||||
|
bool buttonsHaveCost = tweaksAndThings.EndGearHelpersRequirePayment();
|
||||||
|
ContextMenu shared = ContextMenu.Shared;
|
||||||
|
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.EnumerateCoupled().Any(c => c.EndAirSystemIssue()))
|
||||||
|
{
|
||||||
|
shared.AddButton(ContextMenuQuadrant.Unused2, $"Air Up Consist", SpriteName.Select, delegate
|
||||||
|
{
|
||||||
|
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.GladhandAndAnglecock, buttonsHaveCost);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (car.EnumerateCoupled().Any(c => c.SupportsBleed()))
|
||||||
|
{
|
||||||
|
shared.AddButton(ContextMenuQuadrant.Unused2, $"Bleed Consist", SpriteName.Bleed, delegate
|
||||||
|
{
|
||||||
|
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.BleedAirSystem, buttonsHaveCost);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
shared.AddButton(ContextMenuQuadrant.Unused2, $"Follow", SpriteName.Inspect, delegate
|
||||||
|
{
|
||||||
|
CameraSelector.shared.FollowCar(car);
|
||||||
|
});
|
||||||
|
|
||||||
|
shared.BuildItemAngles();
|
||||||
|
shared.StartCoroutine(shared.AnimateButtonsShown());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Model;
|
using Model;
|
||||||
using Model.Definition.Data;
|
using Model.Definition.Data;
|
||||||
using Model.OpsNew;
|
using Model.Ops;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Extensions;
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
@@ -21,11 +21,11 @@ namespace RMROC451.TweaksAndThings.Patches;
|
|||||||
[HarmonyPatch(typeof(EngineRosterRow))]
|
[HarmonyPatch(typeof(EngineRosterRow))]
|
||||||
[HarmonyPatch(nameof(EngineRosterRow.Refresh))]
|
[HarmonyPatch(nameof(EngineRosterRow.Refresh))]
|
||||||
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
public class EngineRosterRow_Refresh_Patch
|
internal class EngineRosterRow_Refresh_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(EngineRosterRow __instance)
|
public static void Postfix(EngineRosterRow __instance)
|
||||||
{
|
{
|
||||||
TweaksAndThings? tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
TweaksAndThingsPlugin? tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
RosterFuelColumnSettings? rosterFuelColumnSettings = tweaksAndThings?.settings?.EngineRosterFuelColumnSettings;
|
RosterFuelColumnSettings? rosterFuelColumnSettings = tweaksAndThings?.settings?.EngineRosterFuelColumnSettings;
|
||||||
|
|
||||||
if (tweaksAndThings == null ||
|
if (tweaksAndThings == null ||
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace RMROC451.TweaksAndThings.Patches;
|
|||||||
[HarmonyPatch(typeof(ExpandedConsole))]
|
[HarmonyPatch(typeof(ExpandedConsole))]
|
||||||
[HarmonyPatch(nameof(ExpandedConsole.Add))]
|
[HarmonyPatch(nameof(ExpandedConsole.Add))]
|
||||||
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
public class ExpandedConsole_Add_Patch
|
internal class ExpandedConsole_Add_Patch
|
||||||
{
|
{
|
||||||
private static void Prefix(ref UI.Console.Console.Entry entry)
|
private static void Prefix(ref UI.Console.Console.Entry entry)
|
||||||
{
|
{
|
||||||
@@ -32,7 +32,7 @@ public class ExpandedConsole_Add_Patch
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
StateManager shared = StateManager.Shared;
|
StateManager shared = StateManager.Shared;
|
||||||
GameStorage gameStorage = shared.Storage;
|
GameStorage gameStorage = shared.Storage;
|
||||||
WebhookSettings settings = tweaksAndThings?.settings?.WebhookSettingsList?.FirstOrDefault(ws => ws.RailroadMark == gameStorage.RailroadMark);
|
WebhookSettings settings = tweaksAndThings?.settings?.WebhookSettingsList?.FirstOrDefault(ws => ws.RailroadMark == gameStorage.RailroadMark);
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
using Game;
|
||||||
|
using Game.State;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Model;
|
||||||
|
using Model.Definition.Data;
|
||||||
|
using Model.Ops.Definition;
|
||||||
|
using Model.Ops;
|
||||||
|
using Network;
|
||||||
|
using Railloader;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
using RollingStock;
|
||||||
|
using Serilog;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(CarExtensions))]
|
||||||
|
[HarmonyPatch(nameof(CarExtensions.LoadString), typeof(CarLoadInfo), typeof(Load))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class CarExtensions_LoadString_Patch
|
||||||
|
{
|
||||||
|
public static bool Prefix(CarLoadInfo info, Load load, ref string __result)
|
||||||
|
{
|
||||||
|
bool output = load.id == OpsController_AnnounceCoalescedPayments_Patch.CrewHoursLoad().id;
|
||||||
|
if (output) __result = info.Quantity.FormatCrewHours(load.description);
|
||||||
|
|
||||||
|
return !output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(CarPrototypeLibrary))]
|
||||||
|
[HarmonyPatch(nameof(CarPrototypeLibrary.LoadForId), typeof(string))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class CarPrototypeLibrary_LoadForId_Patch
|
||||||
|
{
|
||||||
|
public static bool Prefix(string loadId, ref Load __result)
|
||||||
|
{
|
||||||
|
Load load = OpsController_AnnounceCoalescedPayments_Patch.CrewHoursLoad();
|
||||||
|
if (loadId == load.id) __result = load;
|
||||||
|
|
||||||
|
return __result == null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(OpsController))]
|
||||||
|
[HarmonyPatch(nameof(OpsController.AnnounceCoalescedPayments))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class OpsController_AnnounceCoalescedPayments_Patch
|
||||||
|
{
|
||||||
|
static Dictionary<string, (bool spotted, bool filling)> CrewCarDict = [];
|
||||||
|
public static (bool spotted, bool filling) CrewCarStatus(Car car)
|
||||||
|
{
|
||||||
|
bool found = CrewCarDict.TryGetValue(car.id, out (bool spotted, bool filling) val);
|
||||||
|
|
||||||
|
if (!found) CrewCarDict.Add(car.id, (false, false));
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GameDateTime dateTime = TimeWeather.Now;
|
||||||
|
static readonly IEnumerable<Type> refillLocations = [
|
||||||
|
typeof(PassengerStop),
|
||||||
|
typeof(SimplePassengerStop),
|
||||||
|
typeof(TeamTrack),
|
||||||
|
typeof(RepairTrack)
|
||||||
|
];
|
||||||
|
|
||||||
|
public static Load CrewHoursLoad()
|
||||||
|
{
|
||||||
|
Load load = (Load)ScriptableObject.CreateInstance(typeof(Load));
|
||||||
|
load.name = "crew-hours";
|
||||||
|
load.description = "Crew";
|
||||||
|
load.units = LoadUnits.Quantity;
|
||||||
|
|
||||||
|
return load;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CarLoadCrewHelper(Car car, float deltaTime)
|
||||||
|
{
|
||||||
|
float rate2 = 24 * 2 * 8;// carLoadRate = 8 crew hours in 30 min loading; (24h * 2 to get half hour chunks * 8 hours to load in those chunks)
|
||||||
|
float num2 = 99999999; //QuantityInStorage for crew-hours (infinite where crew can be shuffling about)
|
||||||
|
float quantityToLoad = Mathf.Min(num2, IndustryComponent.RateToValue(rate2, deltaTime));
|
||||||
|
|
||||||
|
if (car.IsCaboose() && !CrewCarStatus(car).spotted)
|
||||||
|
{
|
||||||
|
CrewCarDict[car.id] = (true, CrewCarDict[car.id].filling);
|
||||||
|
}
|
||||||
|
if (car.IsCabooseAndStoppedForLoadRefresh())
|
||||||
|
{
|
||||||
|
if (!CrewCarDict[car.id].filling) Multiplayer.Broadcast($"{Hyperlink.To(car)}: \"Topping off caboose crew.\"");
|
||||||
|
CrewCarDict[car.id] = (CrewCarDict[car.id].spotted, true);
|
||||||
|
var data = car.QuantityCapacityOfLoad(CrewHoursLoad());
|
||||||
|
if ((data.quantity + quantityToLoad > data.capacity) && data.quantity < data.capacity)
|
||||||
|
{
|
||||||
|
Multiplayer.Broadcast($"{Hyperlink.To(car)}: \"Caboose crew topped off.\"");
|
||||||
|
CrewCarDict[car.id] = (CrewCarDict[car.id].spotted, false);
|
||||||
|
}
|
||||||
|
new OpsCarAdapter(car, OpsController.Shared).Load(CrewHoursLoad(), quantityToLoad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Prefix(IndustryComponent __instance)
|
||||||
|
{
|
||||||
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
|
if (!StateManager.IsHost || !tweaksAndThings.IsEnabled || !(tweaksAndThings?.settings?.EndGearHelpersRequirePayment ?? false)) return true;
|
||||||
|
|
||||||
|
|
||||||
|
TrainController tc = UnityEngine.Object.FindAnyObjectByType<TrainController>();
|
||||||
|
try {
|
||||||
|
|
||||||
|
var passengerStops = OpsController.Shared.AllIndustries
|
||||||
|
.SelectMany(i => i.TrackDisplayables.Where(t => refillLocations.Contains(t.GetType())));
|
||||||
|
//Log.Information($"{nameof(OpsController_AnnounceCoalescedPayments_Patch)} => Caboose Helper => PassengerStops => {string.Join(",", passengerStops)}");
|
||||||
|
|
||||||
|
var cabeese = passengerStops
|
||||||
|
.SelectMany(t => t.TrackSpans?.Select(s => (tc.CarsOnSpan(s) ?? []).Where(c => c.IsCaboose()))?.SelectMany(c => c?.Select(c2 => (t, c2))));
|
||||||
|
//Log.Information($"{nameof(OpsController_AnnounceCoalescedPayments_Patch)} => Caboose Helper => PassengerStops Cabeese => {string.Join(",", cabeese?.Select(c => $"{c.t} : {c.c2}") ?? [])}");
|
||||||
|
|
||||||
|
CrewCarDict = CrewCarDict.Where(kvp => cabeese.Select(c => c.c2.id).Contains(kvp.Key)).ToDictionary(k => k.Key, v => v.Value);
|
||||||
|
|
||||||
|
var deltaTime = (float)(TimeWeather.Now.TotalSeconds - dateTime.TotalSeconds);
|
||||||
|
foreach (var caboose in cabeese)
|
||||||
|
{
|
||||||
|
//Log.Information($"{nameof(OpsController_AnnounceCoalescedPayments_Patch)} => Caboose Helper ({deltaTime}) => {caboose.t} : {caboose.c2}");
|
||||||
|
CarLoadCrewHelper(caboose.c2, deltaTime);
|
||||||
|
}
|
||||||
|
dateTime = TimeWeather.Now;
|
||||||
|
} catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "error with announce caboose helper");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
50
TweaksAndThings/Patches/StateManager_OnDayDidChange_Patch.cs
Normal file
50
TweaksAndThings/Patches/StateManager_OnDayDidChange_Patch.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using Game.Events;
|
||||||
|
using Game.State;
|
||||||
|
using HarmonyLib;
|
||||||
|
using KeyValue.Runtime;
|
||||||
|
using Network;
|
||||||
|
using Railloader;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(StateManager))]
|
||||||
|
[HarmonyPatch(nameof(StateManager.OnDayDidChange), typeof(TimeDayDidChange))]
|
||||||
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
|
internal class StateManager_OnDayDidChange_Patch
|
||||||
|
{
|
||||||
|
private const string unbilledBrakeCrewDuration = "unbilledBrakeCrewDuration";
|
||||||
|
|
||||||
|
private static void Postfix(StateManager __instance)
|
||||||
|
{
|
||||||
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
|
if (!tweaksAndThings.IsEnabled || !(tweaksAndThings?.settings?.EndGearHelpersRequirePayment ?? false)) return;
|
||||||
|
if (StateManager.IsHost) PayAutoBrakeCrewWages(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PayAutoBrakeCrewWages(StateManager __instance)
|
||||||
|
{
|
||||||
|
float unbilledRunDuration = UnbilledAutoBrakeCrewRunDuration;
|
||||||
|
int num = Mathf.FloorToInt(unbilledRunDuration / 3600f * 5f);
|
||||||
|
float num2 = (float)num / 5f;
|
||||||
|
float unbilledAutoEngineerRunDuration2 = unbilledRunDuration - num2 * 3600f;
|
||||||
|
if (num > 0)
|
||||||
|
{
|
||||||
|
__instance.ApplyToBalance(-num, Ledger.Category.WagesAI, null, memo: "AI Brake Crew");
|
||||||
|
Multiplayer.Broadcast($"Paid {num:C0} for {num2:F1} hours of Brake Crew services.");
|
||||||
|
UnbilledAutoBrakeCrewRunDuration = unbilledAutoEngineerRunDuration2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float UnbilledAutoBrakeCrewRunDuration
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return StateManager.Shared._storage._gameKeyValueObject[unbilledBrakeCrewDuration].FloatValue;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
StateManager.Shared._storage._gameKeyValueObject[unbilledBrakeCrewDuration] = Value.Float(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,57 +1,50 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Model;
|
using Model;
|
||||||
using Model.OpsNew;
|
using Model.Ops;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Extensions;
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
using UI;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UI.Tags;
|
using UI.Tags;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace RMROC451.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))]
|
||||||
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
public class TagController_UpdateTag_Patch
|
internal class TagController_UpdateTag_Patch
|
||||||
{
|
{
|
||||||
private const string tagTitleAndIconDelimeter = "\n<width=100%><align=\"right\">";
|
private const string tagTitleAndIconDelimeter = "\n<width=100%><align=\"right\">";
|
||||||
private const string tagTitleFormat = "<align=left><margin-right={0}.5em>{1}</margin><line-height=0>";
|
private const string tagTitleFormat = "<align=left><margin-right={0}.5em>{1}</margin><line-height=0>";
|
||||||
|
|
||||||
private static void Postfix(Car car, TagCallout tagCallout)
|
private static void Postfix(Car car, TagCallout tagCallout)
|
||||||
{
|
{
|
||||||
TagController tagController = UnityEngine.Object.FindObjectOfType<TagController>();
|
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||||
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
|
||||||
|
|
||||||
if (!tweaksAndThings.IsEnabled || !tweaksAndThings.settings.HandBrakeAndAirTagModifiers)
|
if (!tweaksAndThings.IsEnabled || !tweaksAndThings.settings.HandBrakeAndAirTagModifiers)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProceedWithPostFix(car, tagCallout, tagController);
|
ProceedWithPostFix(car, tagCallout);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ProceedWithPostFix(Car car, TagCallout tagCallout, TagController tagController)
|
private static void ProceedWithPostFix(Car car, TagCallout tagCallout)
|
||||||
{
|
{
|
||||||
bool isAltDownWithCarIssue = GameInput.IsAltDown && car.CarOrEndGearIssue();
|
|
||||||
tagCallout.callout.Title = string.Format(tagTitleFormat, "{0}", car.DisplayName);
|
tagCallout.callout.Title = string.Format(tagTitleFormat, "{0}", car.DisplayName);
|
||||||
tagCallout.gameObject.SetActive(
|
List<string> tags = [];
|
||||||
tagCallout.gameObject.activeSelf &&
|
|
||||||
(!GameInput.IsAltDown || isAltDownWithCarIssue)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (tagCallout.gameObject.activeSelf && isAltDownWithCarIssue)
|
if (OpsController_AnnounceCoalescedPayments_Patch.CrewCarStatus(car).spotted) tags.Add("+");
|
||||||
{
|
if (car.HasHotbox) tags.Add(TextSprites.Hotbox);
|
||||||
tagController.ApplyImageColor(tagCallout, Color.black);
|
if (car.EndAirSystemIssue()) tags.Add(TextSprites.CycleWaybills);
|
||||||
}
|
if (car.HandbrakeApplied()) tags.Add(TextSprites.HandbrakeWheel);
|
||||||
|
|
||||||
tagCallout.callout.Title =
|
tagCallout.callout.Title =
|
||||||
(car.CarAndEndGearIssue(), car.EndAirSystemIssue(), car.HandbrakeApplied()) switch
|
tags.Any() switch
|
||||||
{
|
{
|
||||||
(true, _, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}{TextSprites.HandbrakeWheel}".Replace("{0}", "2"),
|
true => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{string.Join("", tags)}".Replace("{0}", tags.Count().ToString()),
|
||||||
(_, true, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}".Replace("{0}", "1"),
|
|
||||||
(_, _, true) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.HandbrakeWheel}".Replace("{0}", "1"),
|
|
||||||
_ => car.DisplayName
|
_ => car.DisplayName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,14 @@
|
|||||||
<!-- <MajorVersion>1</MajorVersion> -->
|
<!-- <MajorVersion>1</MajorVersion> -->
|
||||||
<!-- <MinorVersion>0</MinorVersion> -->
|
<!-- <MinorVersion>0</MinorVersion> -->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="mroc-cabeese.json" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="mroc-cabeese.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<GameAssembly Include="Assembly-CSharp" />
|
<GameAssembly Include="Assembly-CSharp" />
|
||||||
<GameAssembly Include="Railloader.Interchange" />
|
<GameAssembly Include="Railloader.Interchange" />
|
||||||
@@ -12,12 +20,14 @@
|
|||||||
<GameAssembly Include="KeyValue.Runtime" />
|
<GameAssembly Include="KeyValue.Runtime" />
|
||||||
<GameAssembly Include="Definition" />
|
<GameAssembly Include="Definition" />
|
||||||
<GameAssembly Include="Ops" />
|
<GameAssembly Include="Ops" />
|
||||||
|
<GameAssembly Include="StrangeCustoms" />
|
||||||
|
|
||||||
<GameAssembly Include="UnityEngine.CoreModule" />
|
<GameAssembly Include="UnityEngine.CoreModule" />
|
||||||
<GameAssembly Include="UnityEngine.UI" />
|
<GameAssembly Include="UnityEngine.UI" />
|
||||||
<GameAssembly Include="Unity.TextMeshPro" />
|
<GameAssembly Include="Unity.TextMeshPro" />
|
||||||
|
|
||||||
<GameAssembly Include="System.Net.Http" />
|
<GameAssembly Include="System.Net.Http" />
|
||||||
|
<GameAssembly Include="Core" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Krafs.Publicizer" Version="2.2.1">
|
<PackageReference Include="Krafs.Publicizer" Version="2.2.1">
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using RMROC451.TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
|
using UI.Builder;
|
||||||
|
using Model;
|
||||||
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
|
||||||
namespace RMROC451.TweaksAndThings;
|
namespace RMROC451.TweaksAndThings;
|
||||||
|
|
||||||
@@ -17,21 +20,31 @@ public class Settings
|
|||||||
public Settings(
|
public Settings(
|
||||||
List<WebhookSettings> webhookSettingsList,
|
List<WebhookSettings> webhookSettingsList,
|
||||||
bool handBrakeAndAirTagModifiers,
|
bool handBrakeAndAirTagModifiers,
|
||||||
RosterFuelColumnSettings engineRosterFuelColumnSettings
|
RosterFuelColumnSettings engineRosterFuelColumnSettings,
|
||||||
|
bool endGearHelpersRequirePayment,
|
||||||
|
bool requireConsistCabooseForOilerAndHotboxSpotter,
|
||||||
|
bool cabooseAllowsConsistInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
WebhookSettingsList = webhookSettingsList;
|
WebhookSettingsList = webhookSettingsList;
|
||||||
HandBrakeAndAirTagModifiers = handBrakeAndAirTagModifiers;
|
HandBrakeAndAirTagModifiers = handBrakeAndAirTagModifiers;
|
||||||
EngineRosterFuelColumnSettings = engineRosterFuelColumnSettings;
|
EngineRosterFuelColumnSettings = engineRosterFuelColumnSettings;
|
||||||
|
EndGearHelpersRequirePayment = endGearHelpersRequirePayment;
|
||||||
|
RequireConsistCabooseForOilerAndHotboxSpotter = requireConsistCabooseForOilerAndHotboxSpotter;
|
||||||
|
CabooseAllowsConsistInfo = cabooseAllowsConsistInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly UIState<string> _selectedTabState = new UIState<string>(null);
|
||||||
public List<WebhookSettings>? WebhookSettingsList;
|
public List<WebhookSettings>? WebhookSettingsList;
|
||||||
public bool HandBrakeAndAirTagModifiers;
|
public bool HandBrakeAndAirTagModifiers;
|
||||||
public RosterFuelColumnSettings? EngineRosterFuelColumnSettings;
|
public RosterFuelColumnSettings? EngineRosterFuelColumnSettings;
|
||||||
|
public bool EndGearHelpersRequirePayment;
|
||||||
|
public bool RequireConsistCabooseForOilerAndHotboxSpotter;
|
||||||
|
public bool CabooseAllowsConsistInfo;
|
||||||
|
|
||||||
internal void AddAnotherRow()
|
internal void AddAnotherRow()
|
||||||
{
|
{
|
||||||
WebhookSettingsList = !WebhookSettingsList?.Any() ?? false ? new[] { new WebhookSettings() }.ToList() : new List<WebhookSettings>();
|
WebhookSettingsList ??= new[] { new WebhookSettings() }.ToList();
|
||||||
if (!string.IsNullOrEmpty(WebhookSettingsList.OrderByDescending(wsl => wsl.WebhookUrl).Last().WebhookUrl))
|
if (!string.IsNullOrEmpty(WebhookSettingsList.OrderByDescending(wsl => wsl.WebhookUrl).Last().WebhookUrl))
|
||||||
{
|
{
|
||||||
WebhookSettingsList.Add(new());
|
WebhookSettingsList.Add(new());
|
||||||
@@ -74,3 +87,27 @@ public class RosterFuelColumnSettings
|
|||||||
public bool EngineRosterShowsFuelStatusAlways;
|
public bool EngineRosterShowsFuelStatusAlways;
|
||||||
public EngineRosterFuelDisplayColumn EngineRosterFuelStatusColumn;
|
public EngineRosterFuelDisplayColumn EngineRosterFuelStatusColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SettingsExtensions
|
||||||
|
{
|
||||||
|
public static List<WebhookSettings> SanitizeEmptySettings(this IEnumerable<WebhookSettings>? settings)
|
||||||
|
{
|
||||||
|
List<WebhookSettings> output =
|
||||||
|
settings?.Where(s => !string.IsNullOrEmpty(s.WebhookUrl))?.ToList() ??
|
||||||
|
new();
|
||||||
|
|
||||||
|
output.Add(new());
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CabooseAllowsConsistInfo(this TweaksAndThingsPlugin input) =>
|
||||||
|
input?.settings?.CabooseAllowsConsistInfo ?? false;
|
||||||
|
public static bool EndGearHelpersRequirePayment(this TweaksAndThingsPlugin input) =>
|
||||||
|
input?.settings?.EndGearHelpersRequirePayment ?? false;
|
||||||
|
public static bool RequireConsistCabooseForOilerAndHotboxSpotter(this TweaksAndThingsPlugin input) =>
|
||||||
|
input?.settings?.RequireConsistCabooseForOilerAndHotboxSpotter ?? false;
|
||||||
|
public static bool CabooseNonMotiveAllowedSetting(this TweaksAndThingsPlugin input, Car car) =>
|
||||||
|
input.EndGearHelpersRequirePayment() && car.set.Cars.CabooseInConsist() && car.NotMotivePower();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,10 +11,11 @@ using System.Net.Http;
|
|||||||
using UI.Builder;
|
using UI.Builder;
|
||||||
|
|
||||||
using RMROC451.TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
|
using RMROC451.TweaksAndThings.Commands;
|
||||||
|
|
||||||
namespace RMROC451.TweaksAndThings;
|
namespace RMROC451.TweaksAndThings;
|
||||||
|
|
||||||
public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHandler, IModTabHandler
|
public class TweaksAndThingsPlugin : SingletonPluginBase<TweaksAndThingsPlugin>, IUpdateHandler, IModTabHandler
|
||||||
{
|
{
|
||||||
private HttpClient client;
|
private HttpClient client;
|
||||||
internal HttpClient Client
|
internal HttpClient Client
|
||||||
@@ -28,16 +29,16 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal Settings? settings { get; private set; } = null;
|
internal Settings? settings { get; private set; } = null;
|
||||||
readonly ILogger logger = Log.ForContext<TweaksAndThings>();
|
readonly ILogger logger = Log.ForContext<TweaksAndThingsPlugin>();
|
||||||
IModdingContext moddingContext { get; set; }
|
IModdingContext moddingContext { get; set; }
|
||||||
IModDefinition modDefinition { get; set; }
|
IModDefinition modDefinition { get; set; }
|
||||||
|
|
||||||
static TweaksAndThings()
|
static TweaksAndThingsPlugin()
|
||||||
{
|
{
|
||||||
Log.Information("Hello! Static Constructor was called!");
|
Log.Information("Hello! Static Constructor was called!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TweaksAndThings(IModdingContext moddingContext, IModDefinition self)
|
public TweaksAndThingsPlugin(IModdingContext moddingContext, IModDefinition self)
|
||||||
{
|
{
|
||||||
this.modDefinition = self;
|
this.modDefinition = self;
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
|
|
||||||
logger.Information("Hello! Constructor was called for {modId}/{modVersion}!", self.Id, self.Version);
|
logger.Information("Hello! Constructor was called for {modId}/{modVersion}!", self.Id, self.Version);
|
||||||
|
|
||||||
//moddingContext.RegisterConsoleCommand(new EchoCommand());
|
moddingContext.RegisterConsoleCommand(new EchoCommand());
|
||||||
|
|
||||||
settings = moddingContext.LoadSettingsData<Settings>(self.Id);
|
settings = moddingContext.LoadSettingsData<Settings>(self.Id);
|
||||||
}
|
}
|
||||||
@@ -54,7 +55,7 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
{
|
{
|
||||||
logger.Information("OnEnable() was called!");
|
logger.Information("OnEnable() was called!");
|
||||||
var harmony = new Harmony(modDefinition.Id);
|
var harmony = new Harmony(modDefinition.Id);
|
||||||
harmony.PatchCategory(modDefinition.Id.Replace(".",string.Empty));
|
harmony.PatchCategory(modDefinition.Id.Replace(".", string.Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDisable()
|
public override void OnDisable()
|
||||||
@@ -77,16 +78,82 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
if (!settings?.WebhookSettingsList?.Any() ?? true) settings.WebhookSettingsList = new[] { new WebhookSettings() }.ToList();
|
if (!settings?.WebhookSettingsList?.Any() ?? true) settings.WebhookSettingsList = new[] { new WebhookSettings() }.ToList();
|
||||||
if (settings?.EngineRosterFuelColumnSettings == null) settings.EngineRosterFuelColumnSettings = new();
|
if (settings?.EngineRosterFuelColumnSettings == null) settings.EngineRosterFuelColumnSettings = new();
|
||||||
|
|
||||||
//WebhookUISection(ref builder);
|
|
||||||
//builder.AddExpandingVerticalSpacer();
|
settings.WebhookSettingsList =
|
||||||
WebhooksListUISection(ref builder);
|
settings?.WebhookSettingsList.SanitizeEmptySettings();
|
||||||
builder.AddExpandingVerticalSpacer();
|
|
||||||
HandbrakesAndAnglecocksUISection(ref builder);
|
builder.AddTabbedPanels(settings._selectedTabState, delegate (UITabbedPanelBuilder tabBuilder)
|
||||||
builder.AddExpandingVerticalSpacer();
|
{
|
||||||
EnginRosterShowsFuelStatusUISection(ref builder);
|
tabBuilder.AddTab("Caboose Mods", "cabooseUpdates", CabooseMods);
|
||||||
|
tabBuilder.AddTab("UI", "rosterUi", UiUpdates);
|
||||||
|
tabBuilder.AddTab("Webhooks", "webhooks", WebhooksListUISection);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnginRosterShowsFuelStatusUISection(ref UIPanelBuilder builder)
|
private static string cabooseUse => "Caboose Use";
|
||||||
|
private static string autoAiRequirment => "AutoAI\nRequirement";
|
||||||
|
|
||||||
|
private void CabooseMods(UIPanelBuilder builder)
|
||||||
|
{
|
||||||
|
builder.AddField(
|
||||||
|
cabooseUse,
|
||||||
|
builder.AddToggle(
|
||||||
|
() => settings?.EndGearHelpersRequirePayment ?? false,
|
||||||
|
delegate (bool enabled)
|
||||||
|
{
|
||||||
|
if (settings == null) settings = new();
|
||||||
|
settings.EndGearHelpersRequirePayment = enabled;
|
||||||
|
builder.Rebuild();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).Tooltip("Enable End Gear Helper Cost", @$"Will cost 1 minute of AI Brake Crew & Caboose Crew time per car in the consist when the new inspector buttons are utilized.
|
||||||
|
|
||||||
|
1.5x multiplier penalty to AI Brake Crew cost if no sufficiently crewed caboose nearby.
|
||||||
|
|
||||||
|
Caboose starts reloading `Crew Hours` at any Team or Repair track (no waybill), after being stationary for 30 seconds.
|
||||||
|
|
||||||
|
AutoOiler Update: Increases limit that crew will oiling a car from 75% -> 99%, also halves the time it takes (simulating crew from lead end and caboose handling half the train).
|
||||||
|
|
||||||
|
AutoOiler Update: if `{cabooseUse}` & `{autoAiRequirment.Replace("\n", " ")}` checked, then when a caboose is present, the AutoOiler will repair hotboxes afer oiling them to 100%.
|
||||||
|
|
||||||
|
AutoHotboxSpotter Update: decrease the random wait from 30 - 300 seconds to 15 - 30 seconds (Safety Is Everyone's Job)");
|
||||||
|
|
||||||
|
builder.AddField(
|
||||||
|
autoAiRequirment,
|
||||||
|
builder.AddToggle(
|
||||||
|
() => settings?.RequireConsistCabooseForOilerAndHotboxSpotter ?? false,
|
||||||
|
delegate (bool enabled)
|
||||||
|
{
|
||||||
|
if (settings == null) settings = new();
|
||||||
|
settings.RequireConsistCabooseForOilerAndHotboxSpotter = enabled;
|
||||||
|
builder.Rebuild();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).Tooltip("AI Engineer Requires Caboose", $@"A caboose is required in the consist to check for Hotboxes and perform Auto Oiler, if checked.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UiUpdates(UIPanelBuilder builder)
|
||||||
|
{
|
||||||
|
builder.AddField(
|
||||||
|
"Enable Tag Updates",
|
||||||
|
builder.AddToggle(
|
||||||
|
() => settings?.HandBrakeAndAirTagModifiers ?? false,
|
||||||
|
delegate (bool enabled)
|
||||||
|
{
|
||||||
|
if (settings == null) settings = new();
|
||||||
|
settings.HandBrakeAndAirTagModifiers = enabled;
|
||||||
|
builder.Rebuild();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).Tooltip("Enable Tag Updates", $@"Will suffix tag title with:
|
||||||
|
{TextSprites.CycleWaybills} if Air System issue.
|
||||||
|
{TextSprites.HandbrakeWheel} if there is a handbrake set.
|
||||||
|
{TextSprites.Hotbox} if a hotbox.");
|
||||||
|
|
||||||
|
EngineRosterShowsFuelStatusUISection(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EngineRosterShowsFuelStatusUISection(UIPanelBuilder builder)
|
||||||
{
|
{
|
||||||
var columns = Enum.GetValues(typeof(EngineRosterFuelDisplayColumn)).Cast<EngineRosterFuelDisplayColumn>().Select(i => i.ToString()).ToList();
|
var columns = Enum.GetValues(typeof(EngineRosterFuelDisplayColumn)).Cast<EngineRosterFuelDisplayColumn>().Select(i => i.ToString()).ToList();
|
||||||
builder.AddSection("Fuel Display in Engine Roster", delegate (UIPanelBuilder builder)
|
builder.AddSection("Fuel Display in Engine Roster", delegate (UIPanelBuilder builder)
|
||||||
@@ -96,12 +163,12 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
builder.AddDropdown(columns, (int)(settings?.EngineRosterFuelColumnSettings?.EngineRosterFuelStatusColumn ?? EngineRosterFuelDisplayColumn.None),
|
builder.AddDropdown(columns, (int)(settings?.EngineRosterFuelColumnSettings?.EngineRosterFuelStatusColumn ?? EngineRosterFuelDisplayColumn.None),
|
||||||
delegate (int column)
|
delegate (int column)
|
||||||
{
|
{
|
||||||
if (settings == null) settings = new() { WebhookSettingsList = new[] { new WebhookSettings() }.ToList(), EngineRosterFuelColumnSettings = new() };
|
if (settings == null) settings = new();
|
||||||
settings.EngineRosterFuelColumnSettings.EngineRosterFuelStatusColumn = (EngineRosterFuelDisplayColumn)column;
|
settings.EngineRosterFuelColumnSettings.EngineRosterFuelStatusColumn = (EngineRosterFuelDisplayColumn)column;
|
||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
).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)))}");
|
).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?",
|
||||||
@@ -109,7 +176,7 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
() => settings?.EngineRosterFuelColumnSettings?.EngineRosterShowsFuelStatusAlways ?? false,
|
() => settings?.EngineRosterFuelColumnSettings?.EngineRosterShowsFuelStatusAlways ?? false,
|
||||||
delegate (bool enabled)
|
delegate (bool enabled)
|
||||||
{
|
{
|
||||||
if (settings == null) settings = new() { WebhookSettingsList = new[] { new WebhookSettings() }.ToList(), EngineRosterFuelColumnSettings = new() };
|
if (settings == null) settings = new();
|
||||||
settings.EngineRosterFuelColumnSettings.EngineRosterShowsFuelStatusAlways = enabled;
|
settings.EngineRosterFuelColumnSettings.EngineRosterShowsFuelStatusAlways = enabled;
|
||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
}
|
}
|
||||||
@@ -118,26 +185,7 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandbrakesAndAnglecocksUISection(ref UIPanelBuilder builder)
|
private void WebhooksListUISection(UIPanelBuilder builder)
|
||||||
{
|
|
||||||
builder.AddSection("Tag Callout Handbrake and Air System Helper", delegate (UIPanelBuilder builder)
|
|
||||||
{
|
|
||||||
builder.AddField(
|
|
||||||
"Enable Tag Updates",
|
|
||||||
builder.AddToggle(
|
|
||||||
() => settings?.HandBrakeAndAirTagModifiers ?? false,
|
|
||||||
delegate (bool enabled)
|
|
||||||
{
|
|
||||||
if (settings == null) settings = new() { WebhookSettingsList = new[] { new WebhookSettings() }.ToList() };
|
|
||||||
settings.HandBrakeAndAirTagModifiers = enabled;
|
|
||||||
builder.Rebuild();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
).Tooltip("Enable Tag Updates", $"Will add {TextSprites.CycleWaybills} to the car tag title having Air System issues. Also prepends {TextSprites.HandbrakeWheel} if there is a handbrake set.\n\nHolding Left Alt while tags are displayed only shows tag titles that have issues.");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WebhooksListUISection(ref UIPanelBuilder builder)
|
|
||||||
{
|
{
|
||||||
builder.AddSection("Webhooks List", delegate (UIPanelBuilder builder)
|
builder.AddSection("Webhooks List", delegate (UIPanelBuilder builder)
|
||||||
{
|
{
|
||||||
@@ -152,7 +200,7 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
() => settings?.WebhookSettingsList[z]?.WebhookEnabled ?? false,
|
() => settings?.WebhookSettingsList[z]?.WebhookEnabled ?? false,
|
||||||
delegate (bool enabled)
|
delegate (bool enabled)
|
||||||
{
|
{
|
||||||
if (settings == null) settings = new() { WebhookSettingsList = new[] { new WebhookSettings() }.ToList() };
|
if (settings == null) settings = new();
|
||||||
settings.WebhookSettingsList[z].WebhookEnabled = enabled;
|
settings.WebhookSettingsList[z].WebhookEnabled = enabled;
|
||||||
settings.AddAnotherRow();
|
settings.AddAnotherRow();
|
||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
@@ -168,7 +216,7 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
settings?.WebhookSettingsList[z]?.RailroadMark,
|
settings?.WebhookSettingsList[z]?.RailroadMark,
|
||||||
delegate (string railroadMark)
|
delegate (string railroadMark)
|
||||||
{
|
{
|
||||||
if (settings == null) settings = new() { WebhookSettingsList = new[] { new WebhookSettings() }.ToList() };
|
if (settings == null) settings = new();
|
||||||
settings.WebhookSettingsList[z].RailroadMark = railroadMark;
|
settings.WebhookSettingsList[z].RailroadMark = railroadMark;
|
||||||
settings.AddAnotherRow();
|
settings.AddAnotherRow();
|
||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
@@ -184,7 +232,7 @@ public class TweaksAndThings : SingletonPluginBase<TweaksAndThings>, IUpdateHand
|
|||||||
settings?.WebhookSettingsList[z]?.WebhookUrl,
|
settings?.WebhookSettingsList[z]?.WebhookUrl,
|
||||||
delegate (string webhookUrl)
|
delegate (string webhookUrl)
|
||||||
{
|
{
|
||||||
if (settings == null) settings = new() { WebhookSettingsList = new[] { new WebhookSettings() }.ToList() };
|
if (settings == null) settings = new();
|
||||||
settings.WebhookSettingsList[z].WebhookUrl = webhookUrl;
|
settings.WebhookSettingsList[z].WebhookUrl = webhookUrl;
|
||||||
settings.AddAnotherRow();
|
settings.AddAnotherRow();
|
||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
23
TweaksAndThings/mroc-cabeese.json
Normal file
23
TweaksAndThings/mroc-cabeese.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"objects": [
|
||||||
|
{
|
||||||
|
"$find": [
|
||||||
|
{
|
||||||
|
"path": "definition.archetype",
|
||||||
|
"value": "Caboose"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"definition": {
|
||||||
|
"loadSlots": [
|
||||||
|
{
|
||||||
|
"$add": {
|
||||||
|
"maximumCapacity": 8,
|
||||||
|
"loadUnits": "Quantity",
|
||||||
|
"requiredLoadIdentifier": "crew-hours"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
12
updates.json
Normal file
12
updates.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"RMROC451.TweaksAndThings": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changelog": [
|
||||||
|
{
|
||||||
|
"version": "*",
|
||||||
|
"date": "2024-07-26T14:31:49.0948925Z",
|
||||||
|
"desc": "https://github.com/rmroc451/TweaksAndThings/releases"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user