mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-17 09:49:39 -06:00
initial work for 13
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user