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

@@ -31,7 +31,7 @@ namespace Content.Server.Storage.Components
// No contents, we do nothing
if (Contents.ContainedEntities.Count == 0) return;
var lockers = Owner.EntityManager.EntityQuery<EntityStorageComponent>().Select(c => c.Owner).ToList();
var lockers = IoCManager.Resolve<IEntityManager>().EntityQuery<EntityStorageComponent>().Select(c => c.Owner).ToList();
if (lockers.Contains(Owner))
lockers.Remove(Owner);

View File

@@ -218,14 +218,14 @@ namespace Content.Server.Storage.Components
// 5. if this is NOT AN ITEM, then mobs can always be eaten unless unless a previous law prevents it
// Let's not insert admin ghosts, yeah? This is really a a hack and should be replaced by attempt events
if (Owner.EntityManager.HasComponent<GhostComponent>(entity.Uid))
if (IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(entity.Uid))
continue;
// checks
var targetIsItem = Owner.EntityManager.HasComponent<SharedItemComponent>(entity.Uid);
var targetIsMob = Owner.EntityManager.HasComponent<SharedBodyComponent>(entity.Uid);
var storageIsItem = Owner.EntityManager.HasComponent<SharedItemComponent>(OwnerUid);
var targetIsItem = IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(entity.Uid);
var targetIsMob = IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity.Uid);
var storageIsItem = IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(OwnerUid);
var allowedToEat = false;

View File

@@ -49,7 +49,7 @@ namespace Content.Server.Storage.Components
private const string LoggerName = "Storage";
public Container? Storage;
private readonly Dictionary<IEntity, int> _sizeCache = new();
[DataField("occludesLight")]
@@ -462,13 +462,13 @@ namespace Content.Server.Storage.Components
var ownerTransform = Owner.Transform;
var playerTransform = player.Transform;
if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) ||
if (!playerTransform.Coordinates.InRange(IoCManager.Resolve<IEntityManager>(), ownerTransform.Coordinates, 2) ||
Owner.IsInContainer() && !playerTransform.ContainsEntity(ownerTransform))
{
break;
}
if (!Owner.EntityManager.TryGetEntity(remove.EntityUid, out var entity) || Storage?.Contains(entity) == false)
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(remove.EntityUid, out var entity) || Storage?.Contains(entity) == false)
{
break;
}

View File

@@ -51,7 +51,7 @@ namespace Content.Server.Storage.Components
for (var i = 0; i < storageItem.Amount; i++)
{
storage.Insert(
Owner.EntityManager.SpawnEntity(storageItem.PrototypeId, Owner.Transform.Coordinates));
IoCManager.Resolve<IEntityManager>().SpawnEntity(storageItem.PrototypeId, Owner.Transform.Coordinates));
}
if (!string.IsNullOrEmpty(storageItem.GroupId)) alreadySpawnedGroups.Add(storageItem.GroupId);