-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Convert suicide and ghost commands to LEC. #38652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert suicide and ghost commands to LEC. #38652
Conversation
|
@VerinSenpai I am not a maintainer, but as a Triager, I am going to suggest that you follow the format that you get when making the PR. This current PR does not include the info that both triagers and maintainers need to properly review the PR. Such as a CL, technical details, etc. This means I cannot add the triage labels, and a maintainer may outright choose to close it (or they may not, up to them.) |
|
I added some technical details for it since this one does a bit more than just an LEC conversion. This change doesn't require a cl entry so I've omitted that as well as the media categories so the PR looks cleaner. I've been a bit lax lately as most of these PRs are just the same shit different day type deals. I'll bear that in mind though for the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small (Large) requested change.
| if (!_gameTicker.PlayerGameStatuses.TryGetValue(player.UserId, out var playerStatus) || | ||
| playerStatus is not PlayerGameStatus.JoinedGame) | ||
| { | ||
| shell.WriteLine(Loc.GetString("suicide-command-error-lobby")); | ||
| return; | ||
| } | ||
|
|
||
| public void Execute(IConsoleShell shell, string argStr, string[] args) | ||
| if (player.AttachedEntity is { Valid: true } frozen && | ||
| EntityManager.HasComponent<AdminFrozenComponent>(frozen)) | ||
| { | ||
| if (shell.Player is not { } player) | ||
| { | ||
| shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server")); | ||
| return; | ||
| } | ||
|
|
||
| if (player.Status != SessionStatus.InGame || player.AttachedEntity == null) | ||
| return; | ||
|
|
||
| var minds = _e.System<SharedMindSystem>(); | ||
|
|
||
| // This check also proves mind not-null for at the end when the mob is ghosted. | ||
| if (!minds.TryGetMind(player, out var mindId, out var mindComp) || | ||
| mindComp.OwnedEntity is not { Valid: true } victim) | ||
| { | ||
| shell.WriteLine(Loc.GetString("suicide-command-no-mind")); | ||
| return; | ||
| } | ||
|
|
||
| var suicideSystem = _e.System<SuicideSystem>(); | ||
|
|
||
| if (_e.HasComponent<AdminFrozenComponent>(victim)) | ||
| { | ||
| var deniedMessage = Loc.GetString("suicide-command-denied"); | ||
| shell.WriteLine(deniedMessage); | ||
| _e.System<PopupSystem>() | ||
| .PopupEntity(deniedMessage, victim, victim); | ||
| return; | ||
| } | ||
|
|
||
| if (suicideSystem.Suicide(victim)) | ||
| return; | ||
|
|
||
| shell.WriteLine(Loc.GetString("ghost-command-denied")); | ||
| var deniedMessage = Loc.GetString("suicide-command-denied"); | ||
| shell.WriteLine(deniedMessage); | ||
| _popupSystem.PopupEntity(deniedMessage, frozen, frozen); | ||
| return; | ||
| } | ||
|
|
||
| if (!_mindSystem.TryGetMind(player, out _, out var mindComp) || | ||
| mindComp.OwnedEntity is not { Valid: true } victim) | ||
| { | ||
| shell.WriteLine(Loc.GetString("suicide-command-no-mind")); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be deboilerplated and moved to a helper system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You got it.
|
Ive opted to close this for now. Im instead going to let Pok take over localizing this and begin work on the mentioned command helpers. |
About the PR
Also unified the structure of both commands. Do suggest any improvements that can be made.
Technical details
Converts the suicide and ghost commands to LocalizedEntityCommands and performed cleanup that comes with that. The commands were already localized but this does make a few minor changes such as switching the suicide command to using its own denied message.
Also unifies the code between the two commands. I'm sure this can be deduplicated better with methods in the future so I'll keep that in mind.
Requirements