Some manual GetComponentOrNull inlines

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 15:09:45 +01:00
parent a5b57c8e10
commit 61be228ad0
10 changed files with 48 additions and 25 deletions

View File

@@ -123,7 +123,11 @@ namespace Content.Server.Administration
private PlayerInfo GetPlayerInfo(IPlayerSession session)
{
var name = session.Name;
var username = session.AttachedEntity?.Name ?? string.Empty;
var username = string.Empty;
if(session.AttachedEntity != null)
username = session.AttachedEntity.Name;
var antag = session.ContentData()?.Mind?.AllRoles.Any(r => r.Antagonist) ?? false;
var uid = session.AttachedEntity?.Uid ?? EntityUid.Invalid;

View File

@@ -180,7 +180,7 @@ namespace Content.Server.Administration
// Make ghost role verb
if (_groupController.CanCommand(player, "makeghostrole") &&
!(args.Target.GetComponentOrNull<MindComponent>()?.HasMind ?? false))
!(IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MindComponent>(args.TargetUid)?.HasMind ?? false))
{
Verb verb = new();
verb.Text = Loc.GetString("make-ghost-role-verb-get-data-text");
@@ -194,7 +194,7 @@ namespace Content.Server.Administration
// Configuration verb. Is this even used for anything!?
if (_groupController.CanAdminMenu(player) &&
IoCManager.Resolve<IEntityManager>().TryGetComponent<ConfigurationComponent?>(args.Target.Uid, out var config))
IoCManager.Resolve<IEntityManager>().TryGetComponent<ConfigurationComponent?>(args.TargetUid, out var config))
{
Verb verb = new();
verb.Text = Loc.GetString("configure-verb-get-data-text");

View File

@@ -53,9 +53,11 @@ namespace Content.Server.Administration.Commands
public static void PerformRejuvenate(IEntity target)
{
target.GetComponentOrNull<MobStateComponent>()?.UpdateState(0);
target.GetComponentOrNull<HungerComponent>()?.ResetFood();
target.GetComponentOrNull<ThirstComponent>()?.ResetThirst();
var targetUid = target.Uid;
var entMan = IoCManager.Resolve<IEntityManager>();
entMan.GetComponentOrNull<MobStateComponent>(targetUid)?.UpdateState(0);
entMan.GetComponentOrNull<HungerComponent>(targetUid)?.ResetFood();
entMan.GetComponentOrNull<ThirstComponent>(targetUid)?.ResetThirst();
EntitySystem.Get<StatusEffectsSystem>().TryRemoveAllStatusEffects(target.Uid);