Some manual TryGetComponent inlines
This commit is contained in:
@@ -2,6 +2,7 @@ using Content.Shared.Atmos.Piping;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -13,7 +14,7 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.OwnerUid, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if (component.TryGetData(PipeColorVisuals.Color, out Color color))
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace Content.Client.Storage
|
||||
{
|
||||
var controlledEntity = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (controlledEntity?.TryGetComponent(out HandsComponent? hands) ?? false)
|
||||
if (controlledEntity != null && controlledEntity.TryGetComponent(out HandsComponent? hands))
|
||||
{
|
||||
#pragma warning disable 618
|
||||
StorageEntity.SendNetworkMessage(new InsertEntityMessage());
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || (!IoCManager.Resolve<IEntityManager>().EntityExists(target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !target.TryGetComponent(out DamageableComponent? damageableComponent))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().EntityExists(target.Uid) || !target.TryGetComponent(out DamageableComponent? damageableComponent))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || (!IoCManager.Resolve<IEntityManager>().EntityExists(target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !target.TryGetComponent<FoodComponent>(out var foodComp) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Uid, foodComp.SolutionName, out var food))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().EntityExists(target.Uid)
|
||||
|| !target.TryGetComponent<FoodComponent>(out var foodComp)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Uid, foodComp.SolutionName, out var food))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Content.Server.DeviceNetwork.Systems
|
||||
/// <param name="uid">The Entity containing a DeviceNetworkComponent</param>
|
||||
public void Connect(EntityUid uid)
|
||||
{
|
||||
if (EntityManager.GetEntity(uid).TryGetComponent<DeviceNetworkComponent>(out var component))
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(uid, out var component))
|
||||
{
|
||||
AddConnection(component);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace Content.Server.DeviceNetwork.Systems
|
||||
/// <param name="uid">The Entity containing a DeviceNetworkComponent</param>
|
||||
public void Disconnect(EntityUid uid)
|
||||
{
|
||||
if (EntityManager.GetEntity(uid).TryGetComponent<DeviceNetworkComponent>(out var component))
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(uid, out var component))
|
||||
{
|
||||
RemoveConnection(component);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Content.Server.Light.Components
|
||||
|
||||
public void OnUpdate(float frameTime)
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !Owner.TryGetComponent(out BatteryComponent? battery) || ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPaused))
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner.Uid) || !Owner.TryGetComponent(out BatteryComponent? battery) || IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPaused))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,11 +134,12 @@ namespace Content.Server.Medical.Components
|
||||
if (Powered)
|
||||
{
|
||||
var body = _bodyContainer.ContainedEntity;
|
||||
var state = body?.GetComponentOrNull<MobStateComponent>();
|
||||
if (body == null)
|
||||
return MedicalScannerStatus.Open;
|
||||
|
||||
return state == null
|
||||
? MedicalScannerStatus.Open
|
||||
: GetStatusFromDamageState(state);
|
||||
var state = body.GetComponentOrNull<MobStateComponent>();
|
||||
|
||||
return state == null ? MedicalScannerStatus.Open : GetStatusFromDamageState(state);
|
||||
}
|
||||
|
||||
return MedicalScannerStatus.Off;
|
||||
|
||||
@@ -189,7 +189,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
Dirty();
|
||||
}
|
||||
|
||||
return chamberEntity?.GetComponentOrNull<AmmoComponent>()?.TakeBullet(spawnAt);
|
||||
if (chamberEntity == null)
|
||||
return null;
|
||||
|
||||
return chamberEntity.GetComponentOrNull<AmmoComponent>()?.TakeBullet(spawnAt);
|
||||
}
|
||||
|
||||
protected override bool WeaponCanFire()
|
||||
|
||||
@@ -430,7 +430,8 @@ namespace Content.Server.WireHacking
|
||||
|
||||
var activeHandEntity = handsComponent.GetActiveHand?.Owner;
|
||||
ToolComponent? tool = null;
|
||||
activeHandEntity?.TryGetComponent(out tool);
|
||||
if(activeHandEntity != null)
|
||||
activeHandEntity.TryGetComponent(out tool);
|
||||
var toolSystem = EntitySystem.Get<ToolSystem>();
|
||||
|
||||
switch (msg.Action)
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Content.Shared.Nutrition.EntitySystems
|
||||
|
||||
private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args)
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(args.Thrown.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(args.Thrown.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !args.Thrown.TryGetComponent(out CreamPieComponent? creamPie)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().EntityExists(args.Thrown.Uid) || !args.Thrown.TryGetComponent(out CreamPieComponent? creamPie)) return;
|
||||
|
||||
SetCreamPied(uid, creamPied, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user