1
0

AcceptFactionInviteCommand.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Content.Shared.Civ14.CivFactions;
  2. using JetBrains.Annotations;
  3. using Robust.Shared.Console;
  4. using Robust.Shared.GameObjects;
  5. using Robust.Shared.IoC;
  6. using Robust.Shared.Network;
  7. namespace Content.Client.Commands
  8. {
  9. [UsedImplicitly]
  10. public sealed class AcceptFactionInviteCommand : IConsoleCommand
  11. {
  12. [Dependency] private readonly IEntityManager _entityManager = default!;
  13. public string Command => "acceptfactioninvite";
  14. public string Description => "Accepts an invitation to join a faction.";
  15. public string Help => $"Usage: {Command} \"<faction_name>\"";
  16. public void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. if (args.Length != 1)
  19. {
  20. shell.WriteError("Invalid number of arguments.");
  21. shell.WriteLine(Help);
  22. return;
  23. }
  24. var factionName = args[0];
  25. if (string.IsNullOrWhiteSpace(factionName))
  26. {
  27. shell.WriteError("Faction name cannot be empty.");
  28. return;
  29. }
  30. // Create and raise the network event to the server
  31. // AcceptFactionInviteEvent is defined in Content.Shared.Civ14.CivFactions
  32. // The server (CivFactionsSystem) handles this event.
  33. var acceptEvent = new AcceptFactionInviteEvent(factionName);
  34. _entityManager.RaisePredictiveEvent(acceptEvent);
  35. shell.WriteLine($"Sent request to join faction: '{factionName}'.");
  36. }
  37. }
  38. }