mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-16 01:09:38 -06:00
initial work for 13
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -396,4 +396,3 @@ FodyWeavers.xsd
|
|||||||
|
|
||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
/TweaksAndThings/Commands/EchoCommand.cs
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
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.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user