Inline GetComponentOrNull

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 15:32:05 +01:00
parent ee4ff9cfe8
commit 2654775bf0
30 changed files with 55 additions and 32 deletions

View File

@@ -110,7 +110,7 @@ namespace Content.Shared.Body.Components
public BodyPartSymmetry Symmetry { get; private set; } = BodyPartSymmetry.None;
[ViewVariables]
public ISurgeryData? SurgeryDataComponent => Owner.GetComponentOrNull<ISurgeryData>();
public ISurgeryData? SurgeryDataComponent => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ISurgeryData>(Owner.Uid);
protected virtual void OnAddMechanism(SharedMechanismComponent mechanism)
{

View File

@@ -59,7 +59,7 @@ namespace Content.Shared.Friction
Mover.UseMobMovement(body.OwnerUid)) continue;
var surfaceFriction = GetTileFriction(body);
var bodyModifier = body.Owner.GetComponentOrNull<SharedTileFrictionModifier>()?.Modifier ?? 1.0f;
var bodyModifier = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SharedTileFrictionModifier>(body.Owner.Uid)?.Modifier ?? 1.0f;
var friction = _frictionModifier * surfaceFriction * bodyModifier;
ReduceLinearVelocity(prediction, body, friction, frameTime);

View File

@@ -60,7 +60,7 @@ namespace Content.Shared.MobState.Components
else
{
// Initialize with some amount of damage, defaulting to 0.
UpdateState(Owner.GetComponentOrNull<DamageableComponent>()?.TotalDamage ?? FixedPoint2.Zero);
UpdateState(IoCManager.Resolve<IEntityManager>().GetComponentOrNull<DamageableComponent>(Owner.Uid)?.TotalDamage ?? FixedPoint2.Zero);
}
}

View File

@@ -55,7 +55,7 @@ namespace Content.Shared.Singularity
value = Math.Clamp(value, 0, 6);
var physics = singularity.Owner.GetComponentOrNull<PhysicsComponent>();
var physics = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<PhysicsComponent>(singularity.Owner.Uid);
if (singularity.Level > 1 && value <= 1)
{