initial work for 13

This commit is contained in:
2024-06-21 00:23:45 -05:00
parent 0adcbfa787
commit fc43d54815
5 changed files with 48 additions and 2 deletions

1
.gitignore vendored
View File

@@ -396,4 +396,3 @@ FodyWeavers.xsd
# JetBrains Rider # JetBrains Rider
*.sln.iml *.sln.iml
/TweaksAndThings/Commands/EchoCommand.cs

View File

@@ -5,6 +5,7 @@ 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
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

View File

@@ -0,0 +1,44 @@
using Game.State;
using Helpers;
using Model.OpsNew;
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;
}
}

View File

@@ -24,6 +24,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)
{ {

View File

@@ -11,6 +11,7 @@ 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;
@@ -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);
} }