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

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.Access.Systems;
@@ -135,6 +136,9 @@ namespace Content.Server.Access.Components
{
var targetIdComponent = IoCManager.Resolve<IEntityManager>().GetComponent<IdCardComponent>(targetIdEntity.Uid);
var targetAccessComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AccessComponent>(targetIdEntity.Uid);
var name = string.Empty;
if(PrivilegedIdSlot.Item != null)
name = PrivilegedIdSlot.Item.Name;
newState = new IdCardConsoleBoundUserInterfaceState(
PrivilegedIdSlot.HasItem,
PrivilegedIdIsAuthorized(),
@@ -142,7 +146,7 @@ namespace Content.Server.Access.Components
targetIdComponent.FullName,
targetIdComponent.JobTitle,
targetAccessComponent.Tags.ToArray(),
PrivilegedIdSlot.Item?.Name ?? string.Empty,
name,
targetIdEntity.Name);
}
UserInterface?.SetState(newState);

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);

View File

@@ -3,6 +3,7 @@ using Content.Shared.Pulling;
using Content.Shared.Pulling.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Alert.Click
@@ -17,11 +18,10 @@ namespace Content.Server.Alert.Click
public void AlertClicked(ClickAlertEventArgs args)
{
var ps = EntitySystem.Get<SharedPullingSystem>();
var playerTargetPullable = ps.GetPulled(args.Player)?
.GetComponentOrNull<SharedPullableComponent>();
if (playerTargetPullable != null)
var playerTarget = ps.GetPulled(args.Player);
if (playerTarget != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerTarget.Uid, out SharedPullableComponent playerPullable))
{
ps.TryStopPull(playerTargetPullable);
ps.TryStopPull(playerPullable);
}
}
}