Inline HasComponent entirely

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 12:23:18 +01:00
parent 88141ae6b8
commit 0feebbff00
117 changed files with 201 additions and 158 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Interaction;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -36,7 +37,7 @@ namespace Content.Shared.Buckle.Components
bool IDraggable.CanDrop(CanDropEvent args)
{
return args.Target.HasComponent<SharedStrapComponent>();
return IoCManager.Resolve<IEntityManager>().HasComponent<SharedStrapComponent>(args.Target.Uid);
}
bool IDraggable.Drop(DragDropEvent args)

View File

@@ -1,6 +1,7 @@
using Content.Shared.DragDrop;
using Content.Shared.Interaction;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -19,7 +20,7 @@ namespace Content.Shared.Climbing
public virtual bool CanDragDropOn(DragDropEvent eventArgs)
{
return eventArgs.Dragged.HasComponent<SharedClimbingComponent>();
return IoCManager.Resolve<IEntityManager>().HasComponent<SharedClimbingComponent>(eventArgs.Dragged.Uid);
}
public abstract bool DragDropOn(DragDropEvent eventArgs);

View File

@@ -3,6 +3,7 @@ using Content.Shared.Maps;
using Content.Shared.Window;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -22,7 +23,7 @@ namespace Content.Shared.Construction.Conditions
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.IncludeAnchored))
{
if (entity.HasComponent<SharedCanBuildWindowOnTopComponent>())
if (IoCManager.Resolve<IEntityManager>().HasComponent<SharedCanBuildWindowOnTopComponent>(entity.Uid))
result = true;
}

View File

@@ -2,6 +2,7 @@
using Content.Shared.Window;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -16,7 +17,7 @@ namespace Content.Shared.Construction.Conditions
{
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.IncludeAnchored))
{
if (entity.HasComponent<SharedWindowComponent>())
if (IoCManager.Resolve<IEntityManager>().HasComponent<SharedWindowComponent>(entity.Uid))
return false;
}

View File

@@ -54,7 +54,7 @@ namespace Content.Shared.Disposal
// TODO: Probably just need a disposable tag.
if (!entity.TryGetComponent(out SharedItemComponent? storable) &&
!entity.HasComponent<SharedBodyComponent>())
!IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity.Uid))
{
return false;
}

View File

@@ -3,6 +3,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Nutrition.Components;
using Content.Shared.Sound;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -23,7 +24,7 @@ namespace Content.Shared.Kitchen.Components
bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs)
{
if (!eventArgs.Dragged.HasComponent<SharedButcherableComponent>())
if (!IoCManager.Resolve<IEntityManager>().HasComponent<SharedButcherableComponent>(eventArgs.Dragged.Uid))
{
return false;
}

View File

@@ -5,6 +5,7 @@ using Content.Shared.Damage;
using Content.Shared.DragDrop;
using Content.Shared.FixedPoint;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
namespace Content.Shared.MedicalScanner
@@ -80,7 +81,7 @@ namespace Content.Shared.MedicalScanner
public bool CanInsert(IEntity entity)
{
return entity.HasComponent<SharedBodyComponent>();
return IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity.Uid);
}
bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs)

View File

@@ -19,7 +19,7 @@ namespace Content.Shared.Movement.Components
if (body == null)
entity.TryGetComponent(out body);
if (entity.HasComponent<MovementIgnoreGravityComponent>() ||
if (IoCManager.Resolve<IEntityManager>().HasComponent<MovementIgnoreGravityComponent>(entity.Uid) ||
(body?.BodyType & (BodyType.Static | BodyType.Kinematic)) != 0) return false;
var transform = entity.Transform;

View File

@@ -1,6 +1,7 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Players;
@@ -85,7 +86,7 @@ namespace Content.Shared.Movement.Components
protected override void Initialize()
{
base.Initialize();
if (!Owner.HasComponent<IMoverComponent>())
if (!IoCManager.Resolve<IEntityManager>().HasComponent<IMoverComponent>(Owner.Uid))
{
Owner.EnsureComponentWarn<SharedPlayerInputMoverComponent>();
}

View File

@@ -164,7 +164,7 @@ namespace Content.Shared.Movement
protected bool UseMobMovement(PhysicsComponent body)
{
return body.BodyStatus == BodyStatus.OnGround &&
body.Owner.HasComponent<MobStateComponent>() &&
IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(body.Owner.Uid) &&
// If we're being pulled then don't mess with our velocity.
(!body.Owner.TryGetComponent(out SharedPullableComponent? pullable) || !pullable.BeingPulled) &&
_blocker.CanMove(body.OwnerUid);

View File

@@ -29,7 +29,7 @@ namespace Content.Shared.Pulling
public bool CanPull(IEntity puller, IEntity pulled)
{
if (!puller.HasComponent<SharedPullerComponent>())
if (!IoCManager.Resolve<IEntityManager>().HasComponent<SharedPullerComponent>(puller.Uid))
{
return false;
}
@@ -198,7 +198,7 @@ namespace Content.Shared.Pulling
return false;
}
if (!pullable.Owner.HasComponent<PhysicsComponent>())
if (!IoCManager.Resolve<IEntityManager>().HasComponent<PhysicsComponent>(pullable.Owner.Uid))
{
return false;
}

View File

@@ -102,8 +102,8 @@ namespace Content.Shared.Singularity
{
var other = args.BodyB.Owner;
if ((!other.HasComponent<SharedContainmentFieldComponent>() &&
!other.HasComponent<SharedContainmentFieldGeneratorComponent>()) ||
if ((!IoCManager.Resolve<IEntityManager>().HasComponent<SharedContainmentFieldComponent>(other.Uid) &&
!IoCManager.Resolve<IEntityManager>().HasComponent<SharedContainmentFieldGeneratorComponent>(other.Uid)) ||
component.Level >= 4)
{
args.Cancel();

View File

@@ -4,6 +4,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.DragDrop;
using Content.Shared.Hands.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using static Content.Shared.Inventory.EquipmentSlotDefines;
@@ -16,7 +17,7 @@ namespace Content.Shared.Strip.Components
public bool CanBeStripped(IEntity by)
{
return by != Owner
&& by.HasComponent<SharedHandsComponent>()
&& IoCManager.Resolve<IEntityManager>().HasComponent<SharedHandsComponent>(@by.Uid)
&& EntitySystem.Get<ActionBlockerSystem>().CanInteract(by.Uid);
}

View File

@@ -44,7 +44,7 @@ namespace Content.Shared.Tabletop
return false;
}
if (!parent.HasComponent<MapComponent>() && !parent.HasComponent<IMapGridComponent>())
if (!IoCManager.Resolve<IEntityManager>().HasComponent<MapComponent>(parent.Uid) && !IoCManager.Resolve<IEntityManager>().HasComponent<IMapGridComponent>(parent.Uid))
{
return false;
}

View File

@@ -119,7 +119,7 @@ namespace Content.Shared.Throwing
// Unfortunately we can't check for hands containers as they have specific names.
if (thrownItem.Owner.TryGetContainerMan(out var containerManager) &&
containerManager.Owner.HasComponent<SharedHandsComponent>())
IoCManager.Resolve<IEntityManager>().HasComponent<SharedHandsComponent>(containerManager.Owner.Uid))
{
EntityManager.RemoveComponent(landing.Uid, thrownItem);
return;