Skip to content

Commit

Permalink
Update AdminLanguageCommand.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
KayzelW committed Oct 1, 2024
1 parent 266c2c4 commit 3346cb4
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions Content.Server/Backmen/Language/Commands/AdminLanguageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,20 @@ public sealed class AdminLanguageCommand : ToolshedCommand
public EntityUid AddLanguage(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<string, Prototype<LanguagePrototype>> @ref,
[CommandArgument] bool canSpeak = true,
[CommandArgument] bool canUnderstand = true
[CommandArgument] Prototype<LanguagePrototype> prototype,
[CommandArgument] bool? canSpeak = true,
[CommandArgument] bool? canUnderstand = true
)
{
var language = @ref.Evaluate(ctx)!;

if (language == SharedLanguageSystem.UniversalPrototype)
if (prototype.Id == SharedLanguageSystem.UniversalPrototype)
{
EnsureComp<UniversalLanguageSpeakerComponent>(input);
Languages.UpdateEntityLanguages(input);
}
else
{
EnsureComp<LanguageSpeakerComponent>(input);
Languages.AddLanguage(input, language, canSpeak, canUnderstand);
Languages.AddLanguage(input, prototype.Id, canSpeak ?? true, canUnderstand ?? true);
}

return input;
Expand All @@ -45,20 +43,19 @@ public EntityUid AddLanguage(
public EntityUid RemoveLanguage(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<string, Prototype<LanguagePrototype>> @ref,
[CommandArgument] bool removeSpeak = true,
[CommandArgument] bool removeUnderstand = true
[CommandArgument] Prototype<LanguagePrototype> prototype,
[CommandArgument] bool? removeSpeak = true,
[CommandArgument] bool? removeUnderstand = true
)
{
var language = @ref.Evaluate(ctx)!;
if (language == SharedLanguageSystem.UniversalPrototype && HasComp<UniversalLanguageSpeakerComponent>(input))
if (prototype.Id == SharedLanguageSystem.UniversalPrototype && HasComp<UniversalLanguageSpeakerComponent>(input))
{
RemComp<UniversalLanguageSpeakerComponent>(input);
EnsureComp<LanguageSpeakerComponent>(input);
}

// We execute this branch even in case of universal so that it gets removed if it was added manually to the LanguageSpeaker
Languages.RemoveLanguage(input, language, removeSpeak, removeUnderstand);
Languages.RemoveLanguage(input, prototype.Id, removeSpeak ?? true, removeUnderstand ?? true);

return input;
}
Expand Down

0 comments on commit 3346cb4

Please sign in to comment.