Inline EntityManager

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:11:52 +01:00
parent bd18574412
commit 5e177ae734
108 changed files with 250 additions and 199 deletions

View File

@@ -304,7 +304,7 @@ namespace Content.Shared.Body.Components
foreach (var mechanism in _mechanisms)
{
Owner.EntityManager.EventBus.RaiseLocalEvent(mechanism.OwnerUid, new AddedToBodyEvent(body));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.OwnerUid, new AddedToBodyEvent(body));
}
}
@@ -319,7 +319,7 @@ namespace Content.Shared.Body.Components
foreach (var mechanism in _mechanisms)
{
Owner.EntityManager.EventBus.RaiseLocalEvent(mechanism.OwnerUid, new RemovedFromBodyEvent(old));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.OwnerUid, new RemovedFromBodyEvent(old));
}
}

View File

@@ -2,6 +2,7 @@
using Content.Shared.Body.Events;
using Content.Shared.Body.Part;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -36,11 +37,11 @@ namespace Content.Shared.Body.Components
{
if (old.Body == null)
{
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new RemovedFromPartEvent(old));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new RemovedFromPartEvent(old));
}
else
{
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new RemovedFromPartInBodyEvent(old.Body, old));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new RemovedFromPartInBodyEvent(old.Body, old));
}
}
@@ -48,11 +49,11 @@ namespace Content.Shared.Body.Components
{
if (value.Body == null)
{
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new AddedToPartEvent(value));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new AddedToPartEvent(value));
}
else
{
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new AddedToPartInBodyEvent(value.Body, value));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new AddedToPartInBodyEvent(value.Body, value));
}
}
}

View File

@@ -7,6 +7,7 @@ using Content.Shared.MobState.Components;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
@@ -163,7 +164,7 @@ namespace Content.Shared.Examine
public static bool InRangeUnOccluded(IEntity origin, EntityCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true)
{
var originPos = origin.Transform.MapPosition;
var otherPos = other.ToMap(origin.EntityManager);
var otherPos = other.ToMap(IoCManager.Resolve<IEntityManager>());
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}
@@ -186,7 +187,7 @@ namespace Content.Shared.Examine
public static bool InRangeUnOccluded(DragDropEvent args, float range, Ignored? predicate, bool ignoreInsideBlocker = true)
{
var originPos = args.User.Transform.MapPosition;
var otherPos = args.DropLocation.ToMap(args.User.EntityManager);
var otherPos = args.DropLocation.ToMap(IoCManager.Resolve<IEntityManager>());
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}
@@ -194,7 +195,7 @@ namespace Content.Shared.Examine
public static bool InRangeUnOccluded(AfterInteractEventArgs args, float range, Ignored? predicate, bool ignoreInsideBlocker = true)
{
var originPos = args.User.Transform.MapPosition;
var otherPos = args.Target?.Transform.MapPosition ?? args.ClickLocation.ToMap(args.User.EntityManager);
var otherPos = args.Target?.Transform.MapPosition ?? args.ClickLocation.ToMap(IoCManager.Resolve<IEntityManager>());
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}

View File

@@ -97,7 +97,7 @@ namespace Content.Shared.Hands.Components
UpdateHandVisualizer();
Dirty();
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this });
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this });
}
public void UpdateHandVisualizer()
@@ -491,7 +491,7 @@ namespace Content.Shared.Hands.Components
private Vector2 GetFinalDropCoordinates(EntityCoordinates targetCoords)
{
var origin = Owner.Transform.MapPosition;
var target = targetCoords.ToMap(Owner.EntityManager);
var target = targetCoords.ToMap(IoCManager.Resolve<IEntityManager>());
var dropVector = target.Position - origin.Position;
var requestedDropDistance = dropVector.Length;
@@ -771,7 +771,7 @@ namespace Content.Shared.Hands.Components
private void HandCountChanged()
{
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new HandCountChangedEvent(Owner));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new HandCountChangedEvent(Owner));
}
/// <summary>

View File

@@ -262,7 +262,7 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null,
bool ignoreInsideBlocker = false)
{
var originPosition = origin.ToMap(other.EntityManager);
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>());
var otherPosition = other.Transform.MapPosition;
return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask,
@@ -277,7 +277,7 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null,
bool ignoreInsideBlocker = false)
{
var originPosition = origin.ToMap(other.Owner.EntityManager);
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>());
var otherPosition = other.Owner.Transform.MapPosition;
return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask,
@@ -292,7 +292,7 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null,
bool ignoreInsideBlocker = false)
{
var originPosition = origin.ToMap(other.Owner.EntityManager);
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>());
var otherPosition = other.Owner.Transform.MapPosition;
return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask,

View File

@@ -203,7 +203,7 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
{
var originPosition = origin.ToMap(other.EntityManager);
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>());
var otherPosition = other.Transform.MapPosition;
return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range,
@@ -217,7 +217,7 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
{
var originPosition = origin.ToMap(other.Owner.EntityManager);
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>());
var otherPosition = other.Owner.Transform.MapPosition;
return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range,
@@ -231,7 +231,7 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
{
var originPosition = origin.ToMap(other.Owner.EntityManager);
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>());
var otherPosition = other.Owner.Transform.MapPosition;
return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range,

View File

@@ -8,6 +8,7 @@ using Content.Shared.FixedPoint;
using Content.Shared.MobState.State;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -290,7 +291,7 @@ namespace Content.Shared.MobState.Components
{
if (!current.HasValue)
{
old?.ExitState(OwnerUid, Owner.EntityManager);
old?.ExitState(OwnerUid, IoCManager.Resolve<IEntityManager>());
return;
}
@@ -300,22 +301,22 @@ namespace Content.Shared.MobState.Components
if (state == old)
{
state.UpdateState(OwnerUid, threshold, Owner.EntityManager);
state.UpdateState(OwnerUid, threshold, IoCManager.Resolve<IEntityManager>());
return;
}
old?.ExitState(OwnerUid, Owner.EntityManager);
old?.ExitState(OwnerUid, IoCManager.Resolve<IEntityManager>());
CurrentState = state;
state.EnterState(OwnerUid, Owner.EntityManager);
state.UpdateState(OwnerUid, threshold, Owner.EntityManager);
state.EnterState(OwnerUid, IoCManager.Resolve<IEntityManager>());
state.UpdateState(OwnerUid, threshold, IoCManager.Resolve<IEntityManager>());
var message = new MobStateChangedMessage(this, old, state);
#pragma warning disable 618
SendMessage(message);
#pragma warning restore 618
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, message);
Dirty();
}

View File

@@ -45,7 +45,7 @@ namespace Content.Shared.Movement.Components
coords ??= transform.Coordinates;
if (!coords.Value.IsValid(entity.EntityManager))
if (!coords.Value.IsValid(IoCManager.Resolve<IEntityManager>()))
{
return true;
}

View File

@@ -5,6 +5,7 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Players;
@@ -57,7 +58,7 @@ namespace Content.Shared.Movement.EntitySystems
mobState.IsAlive()))
{
var relayMoveEvent = new RelayMovementEntityEvent(owner);
owner.EntityManager.EventBus.RaiseLocalEvent(owner.Transform.ParentUid, relayMoveEvent);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(owner.Transform.ParentUid, relayMoveEvent);
}
}

View File

@@ -2,6 +2,7 @@ using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Shared.Placeable
@@ -54,7 +55,7 @@ namespace Content.Shared.Placeable
if(!args.User.TryGetComponent<SharedHandsComponent>(out var handComponent))
return;
if (!args.ClickLocation.IsValid(args.User.EntityManager))
if (!args.ClickLocation.IsValid(IoCManager.Resolve<IEntityManager>()))
return;
if(!handComponent.TryDropEntity(args.Used, surface.Owner.Transform.Coordinates))

View File

@@ -4,6 +4,7 @@ using Robust.Shared.Analyzers;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Physics;
@@ -58,7 +59,7 @@ namespace Content.Shared.Pulling.Components
return;
}
if (!Owner.EntityManager.TryGetEntity(state.Puller.Value, out var entity))
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(state.Puller.Value, out var entity))
{
Logger.Error($"Invalid entity {state.Puller.Value} for pulling");
return;

View File

@@ -1,6 +1,7 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Players;
@@ -37,7 +38,7 @@ namespace Content.Shared.Shuttles.Components
return;
}
if (!Owner.EntityManager.TryGetEntity(state.Console.Value, out var consoleEnt) ||
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(state.Console.Value, out var consoleEnt) ||
!consoleEnt.TryGetComponent(out SharedShuttleConsoleComponent? shuttleConsoleComponent))
{
Logger.Warning($"Unable to set Helmsman console to {state.Console.Value}");