Inline TryGetComponent completely, for real
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.Actions.Behaviors
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace Content.Shared.Actions.Behaviors
|
||||
{
|
||||
Performer = performer;
|
||||
ActionType = actionType;
|
||||
if (!Performer.TryGetComponent(out PerformerActions))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Performer.Uid, out PerformerActions))
|
||||
{
|
||||
throw new InvalidOperationException($"performer {performer.Name} tried to perform action {actionType} " +
|
||||
$" but the performer had no actions component," +
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.Actions.Behaviors.Item
|
||||
{
|
||||
@@ -40,7 +41,7 @@ namespace Content.Shared.Actions.Behaviors.Item
|
||||
Performer = performer;
|
||||
ActionType = actionType;
|
||||
Item = item;
|
||||
if (!Item.TryGetComponent(out ItemActions))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Item.Uid, out ItemActions))
|
||||
{
|
||||
throw new InvalidOperationException($"performer {performer.Name} tried to perform item action {actionType} " +
|
||||
$" for item {Item.Name} but the item had no ItemActionsComponent," +
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -183,7 +184,7 @@ namespace Content.Shared.Actions.Components
|
||||
void IEquippedHand.EquippedHand(EquippedHandEventArgs eventArgs)
|
||||
{
|
||||
// this entity cannot be granted actions if no actions component
|
||||
if (!eventArgs.User.TryGetComponent<SharedActionsComponent>(out var actionsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedActionsComponent?>(eventArgs.User.Uid, out var actionsComponent))
|
||||
return;
|
||||
Holder = eventArgs.User;
|
||||
_holderActionsComponent = actionsComponent;
|
||||
@@ -195,7 +196,7 @@ namespace Content.Shared.Actions.Components
|
||||
void IEquipped.Equipped(EquippedEventArgs eventArgs)
|
||||
{
|
||||
// this entity cannot be granted actions if no actions component
|
||||
if (!eventArgs.User.TryGetComponent<SharedActionsComponent>(out var actionsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedActionsComponent?>(eventArgs.User.Uid, out var actionsComponent))
|
||||
return;
|
||||
Holder = eventArgs.User;
|
||||
_holderActionsComponent = actionsComponent;
|
||||
|
||||
@@ -547,7 +547,7 @@ namespace Content.Shared.Body.Components
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out SharedBodyPartComponent? part))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SharedBodyPartComponent? part))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace Content.Shared.Body.Components
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out SharedMechanismComponent? mechanism))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SharedMechanismComponent? mechanism))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Buckle.Components
|
||||
@@ -32,7 +33,7 @@ namespace Content.Shared.Buckle.Components
|
||||
|
||||
bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
if (!eventArgs.Dragged.TryGetComponent(out SharedBuckleComponent? buckleComponent)) return false;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Dragged.Uid, out SharedBuckleComponent? buckleComponent)) return false;
|
||||
bool Ignored(IEntity entity) => entity == eventArgs.User || entity == eventArgs.Dragged || entity == eventArgs.Target;
|
||||
|
||||
return eventArgs.Target.InRangeUnobstructed(eventArgs.Dragged, buckleComponent.Range, predicate: Ignored);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.CombatMode
|
||||
{
|
||||
@@ -16,7 +17,7 @@ namespace Content.Shared.CombatMode
|
||||
{
|
||||
var entity = eventArgs.SenderSession?.AttachedEntity;
|
||||
|
||||
if (entity == null || !entity.TryGetComponent(out SharedCombatModeComponent? combatModeComponent))
|
||||
if (entity == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SharedCombatModeComponent? combatModeComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Content.Shared.Construction.Steps
|
||||
|
||||
public bool EntityValid(IEntity entity, [NotNullWhen(true)] out SharedStackComponent? stack)
|
||||
{
|
||||
if (entity.TryGetComponent(out SharedStackComponent? otherStack) && otherStack.StackTypeId.Equals(MaterialPrototypeId) && otherStack.Count >= Amount)
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SharedStackComponent? otherStack) && otherStack.StackTypeId.Equals(MaterialPrototypeId) && otherStack.Count >= Amount)
|
||||
stack = otherStack;
|
||||
else
|
||||
stack = null;
|
||||
|
||||
@@ -53,17 +53,17 @@ namespace Content.Shared.Disposal
|
||||
return false;
|
||||
|
||||
// TODO: Probably just need a disposable tag.
|
||||
if (!entity.TryGetComponent(out SharedItemComponent? storable) &&
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SharedItemComponent? storable) &&
|
||||
!IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity.Uid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!entity.TryGetComponent(out IPhysBody? physics) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics) ||
|
||||
!physics.CanCollide && storable == null)
|
||||
{
|
||||
if (!(entity.TryGetComponent(out MobStateComponent? damageState) && damageState.IsDead()))
|
||||
if (!(IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out MobStateComponent? damageState) && damageState.IsDead()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Content.Shared.Examine
|
||||
[Pure]
|
||||
public virtual bool CanExamine(IEntity examiner, MapCoordinates target, Ignored? predicate = null)
|
||||
{
|
||||
if (!examiner.TryGetComponent(out ExaminerComponent? examinerComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(examiner.Uid, out ExaminerComponent? examinerComponent))
|
||||
return false;
|
||||
|
||||
if (!examinerComponent.DoRangeCheck)
|
||||
@@ -128,7 +128,7 @@ namespace Content.Shared.Examine
|
||||
|
||||
foreach (var result in rayResults)
|
||||
{
|
||||
if (!result.HitEntity.TryGetComponent(out OccluderComponent? o))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(result.HitEntity.Uid, out OccluderComponent? o))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Content.Shared.Hands.Components
|
||||
|
||||
public void UpdateHandVisualizer()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
|
||||
return;
|
||||
|
||||
var hands = new List<HandVisualState>();
|
||||
@@ -111,7 +111,7 @@ namespace Content.Shared.Hands.Components
|
||||
if (hand.HeldEntity == null)
|
||||
continue;
|
||||
|
||||
if (!hand.HeldEntity.TryGetComponent(out SharedItemComponent? item) || item.RsiPath == null)
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(hand.HeldEntity.Uid, out SharedItemComponent? item) || item.RsiPath == null)
|
||||
continue;
|
||||
|
||||
var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color);
|
||||
|
||||
@@ -3,6 +3,7 @@ using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.Hands
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace Content.Shared.Hands
|
||||
{
|
||||
var entity = eventArgs.SenderSession.AttachedEntity;
|
||||
|
||||
if (entity == null || !entity.TryGetComponent(out SharedHandsComponent? hands))
|
||||
if (entity == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SharedHandsComponent? hands))
|
||||
return;
|
||||
|
||||
hands.ActiveHand = msg.HandName;
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Content.Shared.Interaction
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.TryGetComponent(out SharedBuckleComponent? buckle) && buckle.Buckled)
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out SharedBuckleComponent? buckle) && buckle.Buckled)
|
||||
{
|
||||
var suid = buckle.LastEntityBuckledTo;
|
||||
if (suid != null)
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Content.Shared.Interaction
|
||||
|
||||
foreach (var result in rayResults)
|
||||
{
|
||||
if (!result.HitEntity.TryGetComponent(out IPhysBody? p))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(result.HitEntity.Uid, out IPhysBody? p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -441,7 +441,7 @@ namespace Content.Shared.Interaction
|
||||
|
||||
protected void InteractionActivate(IEntity user, IEntity used)
|
||||
{
|
||||
if (used.TryGetComponent<UseDelayComponent>(out var delayComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<UseDelayComponent?>(used.Uid, out var delayComponent))
|
||||
{
|
||||
if (delayComponent.ActiveDelay)
|
||||
return;
|
||||
@@ -469,7 +469,7 @@ namespace Content.Shared.Interaction
|
||||
return;
|
||||
}
|
||||
|
||||
if (!used.TryGetComponent(out IActivate? activateComp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(used.Uid, out IActivate? activateComp))
|
||||
return;
|
||||
|
||||
var activateEventArgs = new ActivateEventArgs(user, used);
|
||||
@@ -503,7 +503,7 @@ namespace Content.Shared.Interaction
|
||||
/// </summary>
|
||||
public void UseInteraction(IEntity user, IEntity used)
|
||||
{
|
||||
if (used.TryGetComponent<UseDelayComponent>(out var delayComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<UseDelayComponent?>(used.Uid, out var delayComponent))
|
||||
{
|
||||
if (delayComponent.ActiveDelay)
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Inventory;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Players;
|
||||
@@ -117,7 +118,7 @@ namespace Content.Shared.Item
|
||||
if (user.Transform.MapID != Owner.Transform.MapID)
|
||||
return false;
|
||||
|
||||
if (!Owner.TryGetComponent(out IPhysBody? physics) || physics.BodyType == BodyType.Static)
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out IPhysBody? physics) || physics.BodyType == BodyType.Static)
|
||||
return false;
|
||||
|
||||
return user.InRangeUnobstructed(Owner, ignoreInsideBlocker: true, popup: popup);
|
||||
@@ -140,7 +141,7 @@ namespace Content.Shared.Item
|
||||
if (!CanPickup(user))
|
||||
return false;
|
||||
|
||||
if (!user.TryGetComponent(out SharedHandsComponent? hands))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out SharedHandsComponent? hands))
|
||||
return false;
|
||||
|
||||
var activeHand = hands.ActiveHand;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Shared.MobState.Components
|
||||
|
||||
protected override void OnRemove()
|
||||
{
|
||||
if (Owner.TryGetComponent(out SharedAlertsComponent? status))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SharedAlertsComponent? status))
|
||||
{
|
||||
status.ClearAlert(AlertType.HumanHealth);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Shared.Movement.Components
|
||||
public static bool IsWeightless(this IEntity entity, PhysicsComponent? body = null, EntityCoordinates? coords = null, IMapManager? mapManager = null, IEntityManager? entityManager = null)
|
||||
{
|
||||
if (body == null)
|
||||
entity.TryGetComponent(out body);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out body);
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<MovementIgnoreGravityComponent>(entity.Uid) ||
|
||||
(body?.BodyType & (BodyType.Static | BodyType.Kinematic)) != 0) return false;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Content.Shared.Movement.EntitySystems
|
||||
|
||||
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return;
|
||||
|
||||
if (!ourFixture.Body.Owner.TryGetComponent(out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(ourFixture.Body.Owner.Uid, out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
|
||||
|
||||
otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrength * frameTime);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Content.Shared.Movement
|
||||
return body.BodyStatus == BodyStatus.OnGround &&
|
||||
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) &&
|
||||
(!IoCManager.Resolve<IEntityManager>().TryGetComponent(body.Owner.Uid, out SharedPullableComponent? pullable) || !pullable.BeingPulled) &&
|
||||
_blocker.CanMove(body.OwnerUid);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Content.Shared.Movement
|
||||
!otherCollider.CanCollide ||
|
||||
((collider.CollisionMask & otherCollider.CollisionLayer) == 0 &&
|
||||
(otherCollider.CollisionMask & collider.CollisionLayer) == 0) ||
|
||||
(otherCollider.Owner.TryGetComponent(out SharedPullableComponent? pullable) && pullable.BeingPulled))
|
||||
(IoCManager.Resolve<IEntityManager>().TryGetComponent(otherCollider.Owner.Uid, out SharedPullableComponent? pullable) && pullable.BeingPulled))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -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) || !args.Thrown.TryGetComponent(out CreamPieComponent? creamPie)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().EntityExists(args.Thrown.Uid) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Thrown.Uid, out CreamPieComponent? creamPie)) return;
|
||||
|
||||
SetCreamPied(uid, creamPied, true);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Content.Shared.Placeable
|
||||
if (!surface.IsPlaceable)
|
||||
return;
|
||||
|
||||
if(!args.User.TryGetComponent<SharedHandsComponent>(out var handComponent))
|
||||
if(!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedHandsComponent?>(args.User.Uid, out var handComponent))
|
||||
return;
|
||||
|
||||
if (!args.ClickLocation.IsValid(IoCManager.Resolve<IEntityManager>()))
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Content.Shared.Pulling.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent<SharedPullerComponent>(out var comp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullerComponent?>(entity.Uid, out var comp))
|
||||
{
|
||||
Logger.Error($"Entity {state.Puller.Value} for pulling had no Puller component");
|
||||
// ensure it disconnects from any different puller, still
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Shared.Pulling.Systems
|
||||
if (args.Puller.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ShowAlert(AlertType.Pulling);
|
||||
|
||||
RefreshMovementSpeed(component);
|
||||
@@ -62,7 +62,7 @@ namespace Content.Shared.Pulling.Systems
|
||||
if (args.Puller.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ClearAlert(AlertType.Pulling);
|
||||
|
||||
RefreshMovementSpeed(component);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Content.Shared.Pulling
|
||||
ForceSetMovingTo(pullable, null);
|
||||
|
||||
// Joint shutdown
|
||||
if (puller.Owner.TryGetComponent<JointComponent>(out var jointComp))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<JointComponent?>(puller.Owner.Uid, out var jointComp))
|
||||
{
|
||||
if (jointComp.GetJoints.Contains(pullable.PullJoint!))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pulled.TryGetComponent<IPhysBody>(out var _physics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<IPhysBody?>(pulled.Uid, out var _physics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (puller.TryGetComponent<SharedBuckleComponent>(out var buckle))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBuckleComponent?>(puller.Uid, out var buckle))
|
||||
{
|
||||
// Prevent people pulling the chair they're on, etc.
|
||||
if (buckle.Buckled && (buckle.LastEntityBuckledTo == pulled.Uid))
|
||||
@@ -102,11 +102,11 @@ namespace Content.Shared.Pulling
|
||||
|
||||
public bool TryStartPull(IEntity puller, IEntity pullable)
|
||||
{
|
||||
if (!puller.TryGetComponent<SharedPullerComponent>(out var pullerComp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullerComponent?>(puller.Uid, out var pullerComp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!pullable.TryGetComponent<SharedPullableComponent>(out var pullableComp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullableComponent?>(pullable.Uid, out var pullableComp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -126,12 +126,12 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!puller.Owner.TryGetComponent<PhysicsComponent>(out var pullerPhysics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(puller.Owner.Uid, out var pullerPhysics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pullable.Owner.TryGetComponent<PhysicsComponent>(out var pullablePhysics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(pullable.Owner.Uid, out var pullablePhysics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Content.Shared.Pulling
|
||||
var oldPullable = puller.Pulling;
|
||||
if (oldPullable != null)
|
||||
{
|
||||
if (oldPullable.TryGetComponent<SharedPullableComponent>(out var oldPullableComp))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullableComponent?>(oldPullable.Uid, out var oldPullableComp))
|
||||
{
|
||||
if (!TryStopPull(oldPullableComp))
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Content.Shared.Pulling
|
||||
if (args.Pulled.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ShowAlert(AlertType.Pulled);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Content.Shared.Pulling
|
||||
if (args.Pulled.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ClearAlert(AlertType.Pulled);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Content.Shared.Pulling
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pulled.TryGetComponent(out IPhysBody? physics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulled.Uid, out IPhysBody? physics))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -183,16 +183,16 @@ namespace Content.Shared.Pulling
|
||||
// TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message.
|
||||
private void HandleContainerInsert(EntInsertedIntoContainerMessage message)
|
||||
{
|
||||
if (message.Entity.TryGetComponent(out SharedPullableComponent? pullable))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(message.Entity.Uid, out SharedPullableComponent? pullable))
|
||||
{
|
||||
TryStopPull(pullable);
|
||||
}
|
||||
|
||||
if (message.Entity.TryGetComponent(out SharedPullerComponent? puller))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(message.Entity.Uid, out SharedPullerComponent? puller))
|
||||
{
|
||||
if (puller.Pulling == null) return;
|
||||
|
||||
if (!puller.Pulling.TryGetComponent(out SharedPullableComponent? pulling))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(puller.Pulling.Uid, out SharedPullableComponent? pulling))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pulled.TryGetComponent(out SharedPullableComponent? pullable))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulled.Uid, out SharedPullableComponent? pullable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ namespace Content.Shared.Pulling
|
||||
private void UpdatePulledRotation(IEntity puller, IEntity pulled)
|
||||
{
|
||||
// TODO: update once ComponentReference works with directed event bus.
|
||||
if (!pulled.TryGetComponent(out RotatableComponent? rotatable))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulled.Uid, out RotatableComponent? rotatable))
|
||||
return;
|
||||
|
||||
if (!rotatable.RotateWhilePulling)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Content.Shared.Shuttles.Components
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(state.Console.Value, out var consoleEnt) ||
|
||||
!consoleEnt.TryGetComponent(out SharedShuttleConsoleComponent? shuttleConsoleComponent))
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(consoleEnt.Uid, out SharedShuttleConsoleComponent? shuttleConsoleComponent))
|
||||
{
|
||||
Logger.Warning($"Unable to set Helmsman console to {state.Console.Value}");
|
||||
return;
|
||||
|
||||
@@ -68,12 +68,12 @@ namespace Content.Shared.Singularity
|
||||
|
||||
singularity.Level = value;
|
||||
|
||||
if (singularity.Owner.TryGetComponent(out SharedRadiationPulseComponent? pulse))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(singularity.Owner.Uid, out SharedRadiationPulseComponent? pulse))
|
||||
{
|
||||
pulse.RadsPerSecond = 10 * value;
|
||||
}
|
||||
|
||||
if (singularity.Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(singularity.Owner.Uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(SingularityVisuals.Level, value);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace Content.Shared.Singularity
|
||||
circle.Radius = value - 0.5f;
|
||||
}
|
||||
|
||||
if (singularity.Owner.TryGetComponent(out SingularityDistortionComponent? distortion))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(singularity.Owner.Uid, out SingularityDistortionComponent? distortion))
|
||||
{
|
||||
distortion.Falloff = GetFalloff(value);
|
||||
distortion.Intensity = GetIntensity(value);
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Content.Shared.Slippery
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out PhysicsComponent? otherPhysics) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out PhysicsComponent? otherPhysics) ||
|
||||
!body.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
|
||||
{
|
||||
component.Colliding.Remove(uid);
|
||||
|
||||
@@ -7,6 +7,7 @@ using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Placeable;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace Content.Shared.Storage
|
||||
|
||||
bool IDraggable.CanDrop(CanDropEvent args)
|
||||
{
|
||||
return args.Target.TryGetComponent(out PlaceableSurfaceComponent? placeable) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Target.Uid, out PlaceableSurfaceComponent? placeable) &&
|
||||
placeable.IsPlaceable;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.DragDrop;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Shared.Strip.Components
|
||||
{
|
||||
@@ -13,7 +14,7 @@ namespace Content.Shared.Strip.Components
|
||||
|
||||
bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
if (!eventArgs.Dragged.TryGetComponent(out SharedStrippableComponent? strippable)) return false;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Dragged.Uid, out SharedStrippableComponent? strippable)) return false;
|
||||
return strippable.CanBeStripped(Owner);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Tag
|
||||
@@ -71,7 +72,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool TryAddTag(this IEntity entity, string id)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.AddTag(id);
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool TryAddTags(this IEntity entity, params string[] ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.AddTags(ids);
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool TryAddTags(this IEntity entity, IEnumerable<string> ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.AddTags(ids);
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool HasTag(this IEntity entity, string id)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.HasTag(id);
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool HasAllTags(this IEntity entity, params string[] ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.HasAllTags(ids);
|
||||
}
|
||||
|
||||
@@ -152,7 +153,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool HasAllTags(this IEntity entity, IEnumerable<string> ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.HasAllTags(ids);
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool HasAnyTag(this IEntity entity, params string[] ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.HasAnyTag(ids);
|
||||
}
|
||||
|
||||
@@ -182,7 +183,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool HasAnyTag(this IEntity entity, IEnumerable<string> ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.HasAnyTag(ids);
|
||||
}
|
||||
|
||||
@@ -199,7 +200,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool RemoveTag(this IEntity entity, string id)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.RemoveTag(id);
|
||||
}
|
||||
|
||||
@@ -216,7 +217,7 @@ namespace Content.Shared.Tag
|
||||
/// </returns>
|
||||
public static bool RemoveTags(this IEntity entity, params string[] ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.RemoveTags(ids);
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ namespace Content.Shared.Tag
|
||||
/// </exception>
|
||||
public static bool RemoveTags(this IEntity entity, IEnumerable<string> ids)
|
||||
{
|
||||
return entity.TryGetComponent(out TagComponent? tagComponent) &&
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out TagComponent? tagComponent) &&
|
||||
tagComponent.RemoveTags(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Content.Shared.Throwing
|
||||
|
||||
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
|
||||
{
|
||||
if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out PhysicsComponent? physicsComponent) ||
|
||||
physicsComponent.Fixtures.Count != 1) return;
|
||||
|
||||
if (_fixtures.GetFixtureOrNull(physicsComponent, ThrowingFixture) != null)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Content.Shared.Timing
|
||||
|
||||
_lastUseTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
|
||||
if (Owner.TryGetComponent(out ItemCooldownComponent? cooldown))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ItemCooldownComponent? cooldown))
|
||||
{
|
||||
cooldown.CooldownStart = _lastUseTime;
|
||||
cooldown.CooldownEnd = _lastUseTime + TimeSpan.FromSeconds(Delay);
|
||||
@@ -59,7 +59,7 @@ namespace Content.Shared.Timing
|
||||
cancellationTokenSource?.Cancel();
|
||||
ActiveDelay = false;
|
||||
|
||||
if (Owner.TryGetComponent(out ItemCooldownComponent? cooldown))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ItemCooldownComponent? cooldown))
|
||||
{
|
||||
cooldown.CooldownEnd = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ namespace Content.Shared.Verbs
|
||||
var canInteract = force || _actionBlockerSystem.CanInteract(user.Uid);
|
||||
|
||||
IEntity? @using = null;
|
||||
if (user.TryGetComponent(out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user.Uid)))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user.Uid)))
|
||||
{
|
||||
hands.TryGetActiveHeldEntity(out @using);
|
||||
|
||||
// Check whether the "Held" entity is a virtual pull entity. If yes, set that as the entity being "Used".
|
||||
// This allows you to do things like buckle a dragged person onto a surgery table, without click-dragging
|
||||
// their sprite.
|
||||
if (@using != null && @using.TryGetComponent<HandVirtualItemComponent>(out var pull))
|
||||
if (@using != null && IoCManager.Resolve<IEntityManager>().TryGetComponent<HandVirtualItemComponent?>(@using.Uid, out var pull))
|
||||
{
|
||||
@using = IoCManager.Resolve<IEntityManager>().GetEntity(pull.BlockingEntity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user