Some manual TryGetComponent inlines
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user