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

@@ -3,6 +3,7 @@ using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
@@ -13,7 +14,7 @@ namespace Content.Client.Animations
{
public static void AnimateEntityPickup(IEntity entity, EntityCoordinates initialPosition, Vector2 finalPosition)
{
var animatableClone = entity.EntityManager.SpawnEntity("clientsideclone", initialPosition);
var animatableClone = IoCManager.Resolve<IEntityManager>().SpawnEntity("clientsideclone", initialPosition);
animatableClone.Name = entity.Name;
if (!entity.TryGetComponent(out SpriteComponent? sprite0))

View File

@@ -3,6 +3,7 @@ using Content.Shared.Body.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Content.Client.Body.UI
@@ -35,7 +36,7 @@ namespace Content.Client.Body.UI
return;
}
if (!Owner.Owner.EntityManager.TryGetEntity(scannerState.Uid, out _entity))
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(scannerState.Uid, out _entity))
{
throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner.Uid} at {Owner.Owner.Transform.MapPosition}");
}

View File

@@ -5,6 +5,7 @@ using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
@@ -98,7 +99,7 @@ namespace Content.Client.Chat.UI
_verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds);
}
if (!_senderEntity.Transform.Coordinates.IsValid(_senderEntity.EntityManager))
if (!_senderEntity.Transform.Coordinates.IsValid(IoCManager.Resolve<IEntityManager>()))
{
Modulate = Color.White.WithAlpha(0);
return;

View File

@@ -2,6 +2,7 @@ using System;
using Content.Shared.Doors;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using DrawDepthTag = Robust.Shared.GameObjects.DrawDepth;
@@ -38,7 +39,7 @@ namespace Content.Client.Doors
base.State = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new DoorStateChangedEvent(State), false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new DoorStateChangedEvent(State), false);
}
}

View File

@@ -76,7 +76,7 @@ namespace Content.Client.IconSmoothing
// ensures lastposition initial value is populated on spawn. Just calling
// the hook here would cause a dirty event to fire needlessly
UpdateLastPosition();
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, null, Mode));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, null, Mode));
}
if (Sprite != null && Mode == IconSmoothingMode.Corners)
@@ -260,7 +260,7 @@ namespace Content.Client.IconSmoothing
if (Owner.Transform.Anchored)
{
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
}
}
@@ -268,7 +268,7 @@ namespace Content.Client.IconSmoothing
{
if (Owner.Transform.Anchored)
{
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
UpdateLastPosition();
}
}
@@ -278,7 +278,7 @@ namespace Content.Client.IconSmoothing
{
foreach (var entity in candidates)
{
if (!Owner.EntityManager.TryGetComponent(entity, out IconSmoothComponent? other))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IconSmoothComponent? other))
{
continue;
}

View File

@@ -28,7 +28,7 @@ namespace Content.Client.Interactable.Components
if (Owner.TryGetComponent(out ISpriteComponent? sprite))
{
sprite.PostShader = MakeNewShader(inInteractionRange, renderScale);
sprite.RenderOrder = Owner.EntityManager.CurrentTick.Value;
sprite.RenderOrder = IoCManager.Resolve<IEntityManager>().CurrentTick.Value;
}
}

View File

@@ -94,7 +94,7 @@ namespace Content.Client.Inventory
foreach (var (slot, entityUid) in state.Entities)
{
if (!Owner.EntityManager.TryGetEntity(entityUid, out var entity))
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(entityUid, out var entity))
{
continue;
}
@@ -109,7 +109,7 @@ namespace Content.Client.Inventory
if (state.HoverEntity != null)
{
var (slot, (entityUid, fits)) = state.HoverEntity.Value;
var entity = Owner.EntityManager.GetEntity(entityUid);
var entity = IoCManager.Resolve<IEntityManager>().GetEntity(entityUid);
InterfaceController?.HoverInSlot(slot, entity, fits);
}

View File

@@ -194,7 +194,7 @@ namespace Content.Client.Items.UI
}
var collectMsg = new ItemStatusCollectMessage();
_entity.EntityManager.EventBus.RaiseLocalEvent(_entity.Uid, collectMsg);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(_entity.Uid, collectMsg);
foreach (var control in collectMsg.Controls)
{

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Client.Spawners
@@ -32,7 +33,7 @@ namespace Content.Client.Spawners
{
foreach (var proto in _prototypes)
{
var entity = Owner.EntityManager.SpawnEntity(proto, Owner.Transform.Coordinates);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(proto, Owner.Transform.Coordinates);
_entity.Add(entity);
}
}
@@ -41,7 +42,7 @@ namespace Content.Client.Spawners
{
foreach (var entity in _entity)
{
Owner.EntityManager.DeleteEntity(entity);
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity);
}
}
}

View File

@@ -67,7 +67,7 @@ namespace Content.Client.Storage
}
_storedEntities = state.StoredEntities
.Select(id => Owner.EntityManager.GetEntity(id))
.Select(id => IoCManager.Resolve<IEntityManager>().GetEntity(id))
.ToList();
}
@@ -101,7 +101,7 @@ namespace Content.Client.Storage
/// <param name="storageState"></param>
private void HandleStorageMessage(StorageHeldItemsMessage storageState)
{
_storedEntities = storageState.StoredEntities.Select(id => Owner.EntityManager.GetEntity(id)).ToList();
_storedEntities = storageState.StoredEntities.Select(id => IoCManager.Resolve<IEntityManager>().GetEntity(id)).ToList();
StorageSizeUsed = storageState.StorageSizeUsed;
StorageCapacityMax = storageState.StorageSizeMax;
_window?.BuildEntityList(storageState.StoredEntities.ToList());
@@ -118,7 +118,7 @@ namespace Content.Client.Storage
var entityId = msg.StoredEntities[i];
var initialPosition = msg.EntityPositions[i];
if (Owner.EntityManager.TryGetEntity(entityId, out var entity))
if (IoCManager.Resolve<IEntityManager>().TryGetEntity(entityId, out var entity))
{
ReusableAnimations.AnimateEntityPickup(entity, initialPosition, Owner.Transform.LocalPosition);
}
@@ -156,7 +156,7 @@ namespace Content.Client.Storage
#pragma warning restore 618
buttonEventArgs.Event.Handle();
}
else if (Owner.EntityManager.TryGetEntity(entityUid, out var entity))
else if (IoCManager.Resolve<IEntityManager>().TryGetEntity(entityUid, out var entity))
{
_itemSlotManager.OnButtonPressed(buttonEventArgs.Event, entity);
}
@@ -178,7 +178,7 @@ namespace Content.Client.Storage
/// </summary>
private void GenerateButton(EntityUid entityUid, EntityContainerButton button)
{
if (!Owner.EntityManager.TryGetEntity(entityUid, out var entity))
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(entityUid, out var entity))
return;
entity.TryGetComponent(out ISpriteComponent? sprite);

View File

@@ -72,7 +72,7 @@ namespace Content.Client.Suspicion
}
_overlayActive = true;
var overlay = new TraitorOverlay(Owner.EntityManager, _resourceCache, _eyeManager);
var overlay = new TraitorOverlay(IoCManager.Resolve<IEntityManager>(), _resourceCache, _eyeManager);
_overlayManager.AddOverlay(overlay);
}

View File

@@ -42,7 +42,7 @@ namespace Content.Client.Wall.Components
{
base.Startup();
_overlayEntity = Owner.EntityManager.SpawnEntity("LowWallOverlay", Owner.Transform.Coordinates);
_overlayEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity("LowWallOverlay", Owner.Transform.Coordinates);
_overlayEntity.Transform.AttachParent(Owner);
_overlayEntity.Transform.LocalPosition = Vector2.Zero;
@@ -204,7 +204,7 @@ namespace Content.Client.Wall.Components
foreach (var entity in grid.GetLocal(coords))
{
if (Owner.EntityManager.TryGetComponent(entity, out WindowComponent? window))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out WindowComponent? window))
{
//window.UpdateSprite();
}
@@ -216,7 +216,7 @@ namespace Content.Client.Wall.Components
{
foreach (var entity in candidates)
{
if (!Owner.EntityManager.TryGetComponent(entity, out IconSmoothComponent? other))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IconSmoothComponent? other))
{
continue;
}

View File

@@ -85,7 +85,7 @@ namespace Content.Server.AI.Utility.AiLogic
{
var behaviorManager = IoCManager.Resolve<INpcBehaviorManager>();
behaviorManager.RebuildActions(this);
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new SleepAiMessage(this, false));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new SleepAiMessage(this, false));
}
base.Initialize();

View File

@@ -49,7 +49,7 @@ namespace Content.Server.AME
if (nodeOwner.TryGetComponent(out AMEShieldComponent? shield))
{
var nodeNeighbors = grid.GetCellsInSquareArea(nodeOwner.Transform.Coordinates, 1)
.Select(sgc => nodeOwner.EntityManager.GetEntity(sgc))
.Select(sgc => IoCManager.Resolve<IEntityManager>().GetEntity(sgc))
.Where(entity => entity != nodeOwner && entity.HasComponent<AMEShieldComponent>());
if (nodeNeighbors.Count() >= 8)

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Actions.Actions
foreach (var ent in ents)
{
var ghostBoo = new GhostBooEvent();
ent.EntityManager.EventBus.RaiseLocalEvent(ent.Uid, ghostBoo);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(ent.Uid, ghostBoo);
if (ghostBoo.Handled)
booCounter++;

View File

@@ -52,7 +52,7 @@ namespace Content.Server.Actions.Spells
}
// TODO: Look this is shitty and ideally a test would do it
var spawnedProto = caster.EntityManager.SpawnEntity(ItemProto, caster.Transform.MapPosition);
var spawnedProto = IoCManager.Resolve<IEntityManager>().SpawnEntity(ItemProto, caster.Transform.MapPosition);
if (!spawnedProto.TryGetComponent(out ItemComponent? itemComponent))
{

View File

@@ -10,6 +10,7 @@ using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Players;
@@ -174,7 +175,7 @@ namespace Content.Server.Atmos.Components
if (!_checkPlayer && _position.HasValue)
{
// Check if position is out of range => don't update
if (!_position.Value.InRange(Owner.EntityManager, pos, SharedInteractionSystem.InteractionRange))
if (!_position.Value.InRange(IoCManager.Resolve<IEntityManager>(), pos, SharedInteractionSystem.InteractionRange))
return;
pos = _position.Value;

View File

@@ -8,6 +8,7 @@ using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -57,7 +58,7 @@ namespace Content.Server.Body.Components
{
// Using MapPosition instead of Coordinates here prevents
// a crash within the character preview menu in the lobby
var entity = Owner.EntityManager.SpawnEntity(preset.PartIDs[slot.Id], Owner.Transform.MapPosition);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(preset.PartIDs[slot.Id], Owner.Transform.MapPosition);
if (!entity.TryGetComponent(out SharedBodyPartComponent? part))
{

View File

@@ -64,7 +64,7 @@ namespace Content.Server.Body.Components
// identical on it
foreach (var mechanismId in MechanismIds)
{
var entity = Owner.EntityManager.SpawnEntity(mechanismId, Owner.Transform.MapPosition);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(mechanismId, Owner.Transform.MapPosition);
if (!entity.TryGetComponent(out SharedMechanismComponent? mechanism))
{

View File

@@ -12,6 +12,7 @@ using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -159,7 +160,7 @@ namespace Content.Server.Body.Surgery.Components
#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);
}
private void UpdateSurgeryUIBodyPartRequest(IPlayerSession session, Dictionary<string, int> options)

View File

@@ -5,6 +5,7 @@ using Content.Shared.Interaction.Events;
using Content.Shared.Random.Helpers;
using Content.Shared.Tag;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Botany.Components
{
@@ -22,7 +23,7 @@ namespace Content.Server.Botany.Components
{
for (var i = 0; i < 2; i++)
{
var plank = Owner.EntityManager.SpawnEntity("MaterialWoodPlank1", Owner.Transform.Coordinates);
var plank = IoCManager.Resolve<IEntityManager>().SpawnEntity("MaterialWoodPlank1", Owner.Transform.Coordinates);
plank.RandomOffset(0.25f);
}

View File

@@ -37,7 +37,7 @@ namespace Content.Server.Botany.Components
for (var i = 0; i < random; i++)
{
produce.Seed.SpawnSeedPacket(Owner.Transform.Coordinates, Owner.EntityManager);
produce.Seed.SpawnSeedPacket(Owner.Transform.Coordinates, IoCManager.Resolve<IEntityManager>());
}
return true;

View File

@@ -335,7 +335,7 @@ namespace Content.Server.Buckle.Components
EntitySystem.Get<StandingStateSystem>().Stand(Owner.Uid);
}
_mobState?.CurrentState?.EnterState(Owner.Uid, Owner.EntityManager);
_mobState?.CurrentState?.EnterState(Owner.Uid, IoCManager.Resolve<IEntityManager>());
UpdateBuckleStatus();

View File

@@ -162,7 +162,7 @@ namespace Content.Server.Cargo.Components
// TODO replace with shuttle code
// TEMPORARY loop for spawning stuff on telepad (looks for a telepad adjacent to the console)
IEntity? cargoTelepad = null;
var indices = Owner.Transform.Coordinates.ToVector2i(Owner.EntityManager, _mapManager);
var indices = Owner.Transform.Coordinates.ToVector2i(IoCManager.Resolve<IEntityManager>(), _mapManager);
var offsets = new Vector2i[] { new Vector2i(0, 1), new Vector2i(1, 1), new Vector2i(1, 0), new Vector2i(1, -1),
new Vector2i(0, -1), new Vector2i(-1, -1), new Vector2i(-1, 0), new Vector2i(-1, 1), };
var adjacentEntities = new List<IEnumerable<IEntity>>(); //Probably better than IEnumerable.concat

View File

@@ -119,13 +119,13 @@ namespace Content.Server.Cargo.Components
if (!_prototypeManager.TryIndex(data.ProductId, out CargoProductPrototype? prototype))
return;
var product = Owner.EntityManager.SpawnEntity(prototype.Product, Owner.Transform.Coordinates);
var product = IoCManager.Resolve<IEntityManager>().SpawnEntity(prototype.Product, Owner.Transform.Coordinates);
product.Transform.Anchored = false;
// spawn a piece of paper.
var printed = Owner.EntityManager.SpawnEntity(PrinterOutput, Owner.Transform.Coordinates);
if (!Owner.EntityManager.TryGetComponent(printed.Uid, out PaperComponent paper))
var printed = IoCManager.Resolve<IEntityManager>().SpawnEntity(PrinterOutput, Owner.Transform.Coordinates);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(printed.Uid, out PaperComponent paper))
return;
// fill in the order data
@@ -138,7 +138,7 @@ namespace Content.Server.Cargo.Components
("approver", data.Approver)));
// attempt to attach the label
if (Owner.EntityManager.TryGetComponent(product.Uid, out PaperLabelComponent label))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(product.Uid, out PaperLabelComponent label))
{
EntitySystem.Get<ItemSlotsSystem>().TryInsert(OwnerUid, label.LabelSlot, printed);
}

View File

@@ -26,6 +26,7 @@ using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using Robust.Shared.Log;
using Content.Server.Labels.Components;
using Robust.Shared.IoC;
namespace Content.Server.Chemistry.Components
{
@@ -301,7 +302,7 @@ namespace Content.Server.Chemistry.Components
var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(30));
for (int i = 0; i < bottleAmount; i++)
{
var bottle = Owner.EntityManager.SpawnEntity("ChemistryEmptyBottle01", Owner.Transform.Coordinates);
var bottle = IoCManager.Resolve<IEntityManager>().SpawnEntity("ChemistryEmptyBottle01", Owner.Transform.Coordinates);
//Adding label
LabelComponent labelComponent = bottle.EnsureComponent<LabelComponent>();
@@ -343,7 +344,7 @@ namespace Content.Server.Chemistry.Components
var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(50));
for (int i = 0; i < pillAmount; i++)
{
var pill = Owner.EntityManager.SpawnEntity("pill", Owner.Transform.Coordinates);
var pill = IoCManager.Resolve<IEntityManager>().SpawnEntity("pill", Owner.Transform.Coordinates);
//Adding label
LabelComponent labelComponent = pill.EnsureComponent<LabelComponent>();

View File

@@ -7,6 +7,7 @@ using Content.Shared.FixedPoint;
using Content.Shared.Foam;
using Content.Shared.Inventory;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.Components
@@ -78,7 +79,7 @@ namespace Content.Server.Chemistry.Components
{
if (!string.IsNullOrEmpty(_foamedMetalPrototype))
{
Owner.EntityManager.SpawnEntity(_foamedMetalPrototype, Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(_foamedMetalPrototype, Owner.Transform.Coordinates);
}
Owner.QueueDelete();

View File

@@ -10,6 +10,7 @@ using Content.Shared.Popups;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Player;
@@ -124,7 +125,7 @@ namespace Content.Server.Chemistry.Components
public override ComponentState GetComponentState()
{
var solutionSys = Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var solutionSys = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
return solutionSys.TryGetSolution(Owner.Uid, SolutionName, out var solution)
? new HyposprayComponentState(solution.CurrentVolume, solution.MaxVolume)
: new HyposprayComponentState(FixedPoint2.Zero, FixedPoint2.Zero);

View File

@@ -12,6 +12,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Popups;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -303,7 +304,7 @@ namespace Content.Server.Chemistry.Components
public override ComponentState GetComponentState()
{
Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>()
IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SolutionContainerSystem>()
.TryGetSolution(Owner.Uid, SolutionName, out var solution);
var currentVolume = solution?.CurrentVolume ?? FixedPoint2.Zero;

View File

@@ -74,16 +74,16 @@ namespace Content.Server.Chemistry.Components
var coords = Owner.Transform.Coordinates;
foreach (var neighbor in grid.GetInDir(coords, dir))
{
if (Owner.EntityManager.TryGetComponent(neighbor,
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(neighbor,
out SolutionAreaEffectComponent? comp) && comp.Inception == Inception)
return;
if (Owner.EntityManager.TryGetComponent(neighbor,
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(neighbor,
out AirtightComponent? airtight) && airtight.AirBlocked)
return;
}
var newEffect = Owner.EntityManager.SpawnEntity(Owner.Prototype.ID, grid.DirectionToGrid(coords, dir));
var newEffect = IoCManager.Resolve<IEntityManager>().SpawnEntity(Owner.Prototype.ID, grid.DirectionToGrid(coords, dir));
if (!newEffect.TryGetComponent(out SolutionAreaEffectComponent? effectComponent))
{
@@ -133,7 +133,7 @@ namespace Content.Server.Chemistry.Components
var chemistry = EntitySystem.Get<ReactiveSystem>();
var mapGrid = MapManager.GetGrid(Owner.Transform.GridID);
var tile = mapGrid.GetTileRef(Owner.Transform.Coordinates.ToVector2i(Owner.EntityManager, MapManager));
var tile = mapGrid.GetTileRef(Owner.Transform.Coordinates.ToVector2i(IoCManager.Resolve<IEntityManager>(), MapManager));
var solutionFraction = 1 / Math.Floor(averageExposures);

View File

@@ -40,7 +40,7 @@ namespace Content.Server.Chemistry.EntitySystems
owner.PopupMessageEveryone(Loc.GetString("rehydratable-component-expands-message", ("owner", owner)));
if (!string.IsNullOrEmpty(component.TargetPrototype))
{
var ent = component.Owner.EntityManager.SpawnEntity(component.TargetPrototype,
var ent = IoCManager.Resolve<IEntityManager>().SpawnEntity(component.TargetPrototype,
owner.Transform.Coordinates);
ent.Transform.AttachToGridOrMap();
}

View File

@@ -107,7 +107,7 @@ namespace Content.Server.Cloning.Components
if (cloningSystem.ClonesWaitingForMind.TryGetValue(mind, out var cloneUid))
{
if (Owner.EntityManager.TryGetEntity(cloneUid, out var clone) &&
if (IoCManager.Resolve<IEntityManager>().TryGetEntity(cloneUid, out var clone) &&
clone.TryGetComponent<MobStateComponent>(out var cloneState) &&
!cloneState.IsDead() &&
clone.TryGetComponent(out MindComponent? cloneMindComp) &&
@@ -135,7 +135,7 @@ namespace Content.Server.Cloning.Components
return; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
}
var mob = Owner.EntityManager.SpawnEntity("MobHuman", Owner.Transform.MapPosition);
var mob = IoCManager.Resolve<IEntityManager>().SpawnEntity("MobHuman", Owner.Transform.MapPosition);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(mob.Uid, dna.Profile);

View File

@@ -5,6 +5,7 @@ using Content.Server.Power.Components;
using Content.Shared.Computer;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -78,7 +79,7 @@ namespace Content.Server.Computer
return;
}
var board = Owner.EntityManager.SpawnEntity(_boardPrototype, Owner.Transform.Coordinates);
var board = IoCManager.Resolve<IEntityManager>().SpawnEntity(_boardPrototype, Owner.Transform.Coordinates);
if(!container.Insert(board))
Logger.Warning($"Couldn't insert board {board} to computer {Owner}!");

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Content.Server.Stack;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Components
@@ -52,7 +53,7 @@ namespace Content.Server.Construction.Components
if (string.IsNullOrEmpty(BoardPrototype))
return;
var entityManager = Owner.EntityManager;
var entityManager = IoCManager.Resolve<IEntityManager>();
if (existedBoard || existedParts)
{
@@ -88,7 +89,7 @@ namespace Content.Server.Construction.Components
{
var stack = EntitySystem.Get<StackSystem>().Spawn(amount, stackType, Owner.Transform.Coordinates);
if (!partContainer.Insert(Owner.EntityManager.GetEntity(stack)))
if (!partContainer.Insert(IoCManager.Resolve<IEntityManager>().GetEntity(stack)))
throw new Exception($"Couldn't insert machine material of type {stackType} to machine with prototype {Owner.Prototype?.ID ?? "N/A"}");
}

View File

@@ -318,7 +318,7 @@ namespace Content.Server.Construction.Components
if (splitStack == null)
return false;
if(!_partContainer.Insert(Owner.EntityManager.GetEntity(splitStack.Value)))
if(!_partContainer.Insert(IoCManager.Resolve<IEntityManager>().GetEntity(splitStack.Value)))
return false;
_materialProgress[type] += needed;

View File

@@ -8,6 +8,7 @@ using Content.Shared.Stacks;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.ViewVariables;
@@ -65,7 +66,7 @@ namespace Content.Server.Construction.Components
// spawn each result after refine
foreach (var result in _refineResult!)
{
var droppedEnt = Owner.EntityManager.SpawnEntity(result, resultPosition);
var droppedEnt = IoCManager.Resolve<IEntityManager>().SpawnEntity(result, resultPosition);
// TODO: If something has a stack... Just use a prototype with a single thing in the stack.
// This is not a good way to do it.

View File

@@ -125,13 +125,13 @@ namespace Content.Server.Crayon
return true;
}
if (!eventArgs.ClickLocation.IsValid(Owner.EntityManager))
if (!eventArgs.ClickLocation.IsValid(IoCManager.Resolve<IEntityManager>()))
{
eventArgs.User.PopupMessage(Loc.GetString("crayon-interact-invalid-location"));
return true;
}
var entity = Owner.EntityManager.SpawnEntity("CrayonDecal", eventArgs.ClickLocation);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity("CrayonDecal", eventArgs.ClickLocation);
if (entity.TryGetComponent(out AppearanceComponent? appearance))
{
appearance.SetData(CrayonVisuals.State, SelectedState);

View File

@@ -14,6 +14,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
@@ -207,7 +208,7 @@ namespace Content.Server.Cuffs.Components
}
var attempt = new UncuffAttemptEvent(user.Uid, Owner.Uid);
Owner.EntityManager.EventBus.RaiseLocalEvent(user.Uid, attempt);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(user.Uid, attempt);
if (attempt.Cancelled)
{

View File

@@ -21,7 +21,7 @@ namespace Content.Server.Disposal.Tube.Components
public bool TryInsert(DisposalUnitComponent from)
{
var holder = Owner.EntityManager.SpawnEntity(HolderPrototypeId, Owner.Transform.MapPosition);
var holder = IoCManager.Resolve<IEntityManager>().SpawnEntity(HolderPrototypeId, Owner.Transform.MapPosition);
var holderComponent = holder.GetComponent<DisposalHolderComponent>();
foreach (var entity in from.ContainedEntities.ToArray())

View File

@@ -7,6 +7,7 @@ using Content.Shared.Doors;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -175,7 +176,7 @@ namespace Content.Server.Doors.Components
_boltLightsWirePulsed ? StatusLightState.On : StatusLightState.Off, "BLTL");
var ev = new DoorGetCloseTimeModifierEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
var timingStatus =
new StatusLightData(Color.Orange, !AutoClose ? StatusLightState.Off :

View File

@@ -21,6 +21,7 @@ using Content.Shared.Tools;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Player;
@@ -77,7 +78,7 @@ namespace Content.Server.Doors.Components
_ => throw new ArgumentOutOfRangeException(),
};
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new DoorStateChangedEvent(State), false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new DoorStateChangedEvent(State), false);
_autoCloseCancelTokenSource?.Cancel();
Dirty();
@@ -257,7 +258,7 @@ namespace Content.Server.Doors.Components
return;
DoorClickShouldActivateEvent ev = new DoorClickShouldActivateEvent(eventArgs);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
if (ev.Handled)
return;
@@ -276,7 +277,7 @@ namespace Content.Server.Doors.Components
public void TryOpen(IEntity? user=null)
{
var msg = new DoorOpenAttemptEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, msg);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, msg);
if (msg.Cancelled) return;
@@ -354,7 +355,7 @@ namespace Content.Server.Doors.Components
}
var ev = new BeforeDoorOpenedEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
return !ev.Cancelled;
}
@@ -402,7 +403,7 @@ namespace Content.Server.Doors.Components
EntitySystem.Get<AirtightSystem>().SetAirblocked(airtight, false);
}
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, false));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, false));
}
private void QuickOpen(bool refresh)
@@ -424,7 +425,7 @@ namespace Content.Server.Doors.Components
public void TryClose(IEntity? user=null)
{
var msg = new DoorCloseAttemptEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, msg);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, msg);
if (msg.Cancelled) return;
@@ -460,7 +461,7 @@ namespace Content.Server.Doors.Components
public bool CanCloseGeneric()
{
var ev = new BeforeDoorClosedEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
if (ev.Cancelled)
return false;
@@ -470,7 +471,7 @@ namespace Content.Server.Doors.Components
private bool SafetyCheck()
{
var ev = new DoorSafetyEnabledEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
return ev.Safety || _inhibitCrush;
}
@@ -547,7 +548,7 @@ namespace Content.Server.Doors.Components
EntitySystem.Get<AirtightSystem>().SetAirblocked(airtight, true);
}
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, true));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, true));
}
/// <summary>
@@ -603,7 +604,7 @@ namespace Content.Server.Doors.Components
public void Deny()
{
var ev = new BeforeDoorDeniedEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
if (ev.Cancelled)
return;
@@ -650,14 +651,14 @@ namespace Content.Server.Doors.Components
return;
var autoev = new BeforeDoorAutoCloseEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, autoev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, autoev, false);
if (autoev.Cancelled)
return;
_autoCloseCancelTokenSource = new();
var ev = new DoorGetCloseTimeModifierEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
var realCloseTime = AutoCloseDelay * ev.CloseTimeModifier;
Owner.SpawnRepeatingTimer(realCloseTime, async () =>
@@ -683,10 +684,10 @@ namespace Content.Server.Doors.Components
if (tool.Qualities.Contains(_pryingQuality) && !IsWeldedShut)
{
var ev = new DoorGetPryTimeModifierEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
var canEv = new BeforeDoorPryEvent(eventArgs);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, canEv, false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, canEv, false);
if (canEv.Cancelled) return false;
@@ -695,7 +696,7 @@ namespace Content.Server.Doors.Components
if (successfulPry && !IsWeldedShut)
{
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new OnDoorPryEvent(eventArgs), false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new OnDoorPryEvent(eventArgs), false);
if (State == DoorState.Closed)
{
Open();

View File

@@ -135,7 +135,7 @@ namespace Content.Server.Explosion.Components
if (_unspawnedCount > 0)
{
_unspawnedCount--;
grenade = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.MapPosition);
grenade = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.MapPosition);
return true;
}

View File

@@ -1,6 +1,7 @@
using Content.Server.Throwing;
using Content.Shared.Acts;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Server.Explosion.Components
@@ -16,11 +17,11 @@ namespace Content.Server.Explosion.Components
return;
var sourceLocation = eventArgs.Source;
var targetLocation = Owner.EntityManager.GetComponent<TransformComponent>(eventArgs.Target).Coordinates;
var targetLocation = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(eventArgs.Target).Coordinates;
if (sourceLocation.Equals(targetLocation)) return;
var offset = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager));
var offset = (targetLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - sourceLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()));
//Don't throw if the direction is center (0,0)
if (offset == Vector2.Zero) return;

View File

@@ -100,7 +100,7 @@ namespace Content.Server.Fluids.Components
return true;
var playerPos = eventArgs.User.Transform.Coordinates;
var entManager = Owner.EntityManager;
var entManager = IoCManager.Resolve<IEntityManager>();
if (eventArgs.ClickLocation.GetGridId(entManager) != playerPos.GetGridId(entManager))
return true;
@@ -126,7 +126,7 @@ namespace Content.Server.Fluids.Components
var target = eventArgs.User.Transform.Coordinates.Offset((diffNorm + rotation.ToVec()).Normalized * diffLength + quarter);
if (target.TryDistance(Owner.EntityManager, playerPos, out var distance) && distance > SprayDistance)
if (target.TryDistance(IoCManager.Resolve<IEntityManager>(), playerPos, out var distance) && distance > SprayDistance)
target = eventArgs.User.Transform.Coordinates.Offset(diffNorm * SprayDistance);
var solution = EntitySystem.Get<SolutionContainerSystem>().SplitSolution(Owner.Uid, contents, _transferAmount);

View File

@@ -328,7 +328,7 @@ namespace Content.Server.Fluids.EntitySystems
}
puddle ??= () =>
puddleComponent.Owner.EntityManager.SpawnEntity(puddleComponent.Owner.Prototype?.ID,
IoCManager.Resolve<IEntityManager>().SpawnEntity(puddleComponent.Owner.Prototype?.ID,
mapGrid.DirectionToGrid(coords, direction))
.GetComponent<PuddleComponent>();

View File

@@ -5,6 +5,7 @@ using Content.Server.Players;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -41,10 +42,10 @@ namespace Content.Server.Ghost.Roles.Components
if (string.IsNullOrEmpty(Prototype))
throw new NullReferenceException("Prototype string cannot be null or empty!");
var mob = Owner.EntityManager.SpawnEntity(Prototype, Owner.Transform.Coordinates);
var mob = IoCManager.Resolve<IEntityManager>().SpawnEntity(Prototype, Owner.Transform.Coordinates);
if (MakeSentient)
MakeSentientCommand.MakeSentient(mob.Uid, Owner.EntityManager);
MakeSentientCommand.MakeSentient(mob.Uid, IoCManager.Resolve<IEntityManager>());
mob.EnsureComponent<MindComponent>();

View File

@@ -4,6 +4,7 @@ using Content.Server.Mind.Components;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Content.Server.Ghost.Roles.Components
@@ -29,7 +30,7 @@ namespace Content.Server.Ghost.Roles.Components
return false;
if (MakeSentient)
MakeSentientCommand.MakeSentient(OwnerUid, Owner.EntityManager);
MakeSentientCommand.MakeSentient(OwnerUid, IoCManager.Resolve<IEntityManager>());
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, OwnerUid, OwnerUid, this);

View File

@@ -45,7 +45,7 @@ namespace Content.Server.Hands.Components
}
if (heldEntity.TryGetComponent(out SpriteComponent? sprite))
{
sprite.RenderOrder = heldEntity.EntityManager.CurrentTick.Value;
sprite.RenderOrder = IoCManager.Resolve<IEntityManager>().CurrentTick.Value;
}
}
@@ -58,7 +58,7 @@ namespace Content.Server.Hands.Components
if (finalPosition.EqualsApprox(initialPosition.Position))
return;
Owner.EntityManager.EntityNetManager!.SendSystemNetworkMessage(
IoCManager.Resolve<IEntityManager>().EntityNetManager!.SendSystemNetworkMessage(
new PickupAnimationMessage(entity.Uid, finalPosition, initialPosition));
}

View File

@@ -1,5 +1,6 @@
using Content.Server.Inventory.Components;
using Content.Server.Items;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using static Content.Shared.Inventory.EquipmentSlotDefines;
@@ -10,7 +11,7 @@ namespace Content.Server.Inventory
{
public static bool SpawnItemInSlot(this InventoryComponent inventory, Slots slot, string prototype, bool mobCheck = false)
{
var entityManager = inventory.Owner.EntityManager;
var entityManager = IoCManager.Resolve<IEntityManager>();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
var user = inventory.Owner;

View File

@@ -30,7 +30,7 @@ namespace Content.Server.Jobs
if (!EntitySystem.Get<HolidaySystem>().IsCurrentlyHoliday(Holiday))
return;
var entity = mob.EntityManager.SpawnEntity(Prototype, mob.Transform.Coordinates);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(Prototype, mob.Transform.Coordinates);
if (!entity.TryGetComponent(out ItemComponent? item) || !mob.TryGetComponent(out HandsComponent? hands))
return;

View File

@@ -12,6 +12,7 @@ using Content.Shared.Nutrition.Components;
using Content.Shared.Popups;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
@@ -39,7 +40,7 @@ namespace Content.Server.Kitchen.Components
if (!string.IsNullOrEmpty(_meatPrototype))
{
var meat = Owner.EntityManager.SpawnEntity(_meatPrototype, Owner.Transform.Coordinates);
var meat = IoCManager.Resolve<IEntityManager>().SpawnEntity(_meatPrototype, Owner.Transform.Coordinates);
meat.Name = _meatName;
}

View File

@@ -365,13 +365,13 @@ namespace Content.Server.Kitchen.Components
if (recipeToCook != null)
{
SubtractContents(recipeToCook);
Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates);
}
else
{
VaporizeReagents();
VaporizeSolids();
Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
}
}
@@ -424,9 +424,9 @@ namespace Content.Server.Kitchen.Components
private void EjectSolid(EntityUid entityId)
{
if (Owner.EntityManager.EntityExists(entityId))
if (IoCManager.Resolve<IEntityManager>().EntityExists(entityId))
{
_storage.Remove(Owner.EntityManager.GetEntity(entityId));
_storage.Remove(IoCManager.Resolve<IEntityManager>().GetEntity(entityId));
}
}

View File

@@ -14,6 +14,7 @@ using Content.Shared.Research.Prototypes;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Content.Server.Lathe.Components
@@ -122,7 +123,7 @@ namespace Content.Server.Lathe.Components
{
Producing = false;
_producingRecipe = null;
Owner.EntityManager.SpawnEntity(recipe.Result, Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(recipe.Result, Owner.Transform.Coordinates);
UserInterface?.SendMessage(new LatheStoppedProducingRecipeMessage());
State = LatheState.Base;
SetAppearance(LatheVisualState.Idle);

View File

@@ -5,6 +5,7 @@ using Content.Shared.Examine;
using Content.Shared.Light.Component;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
@@ -30,7 +31,7 @@ namespace Content.Server.Light.Components
return;
_state = value;
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new EmergencyLightMessage(this, _state));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new EmergencyLightMessage(this, _state));
}
}

View File

@@ -17,6 +17,7 @@ using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Player;
@@ -71,7 +72,7 @@ namespace Content.Server.Light.Components
protected override void OnRemove()
{
base.OnRemove();
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this));
IoCManager.Resolve<IEntityManager>().EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this));
}
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
@@ -119,7 +120,7 @@ namespace Content.Server.Light.Components
SetState(false);
Activated = false;
UpdateLightAction();
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this));
IoCManager.Resolve<IEntityManager>().EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this));
if (makeNoise)
{
@@ -158,7 +159,7 @@ namespace Content.Server.Light.Components
Activated = true;
UpdateLightAction();
SetState(true);
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this));
IoCManager.Resolve<IEntityManager>().EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this));
SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound.GetSound(), Owner);
return true;

View File

@@ -59,7 +59,7 @@ namespace Content.Server.Mind.Components
public void InternalEjectMind()
{
if (!Deleted)
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new MindRemovedMessage());
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new MindRemovedMessage());
Mind = null;
}
@@ -71,7 +71,7 @@ namespace Content.Server.Mind.Components
public void InternalAssignMind(Mind value)
{
Mind = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new MindAddedMessage());
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new MindAddedMessage());
}
protected override void Shutdown()
@@ -103,13 +103,13 @@ namespace Content.Server.Mind.Components
// Async this so that we don't throw if the grid we're on is being deleted.
var mapMan = IoCManager.Resolve<IMapManager>();
var gridId = spawnPosition.GetGridId(Owner.EntityManager);
var gridId = spawnPosition.GetGridId(IoCManager.Resolve<IEntityManager>());
if (gridId == GridId.Invalid || !mapMan.GridExists(gridId))
{
spawnPosition = EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
}
var ghost = Owner.EntityManager.SpawnEntity("MobObserver", spawnPosition);
var ghost = IoCManager.Resolve<IEntityManager>().SpawnEntity("MobObserver", spawnPosition);
var ghostComponent = ghost.GetComponent<GhostComponent>();
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghostComponent, false);

View File

@@ -184,7 +184,8 @@ namespace Content.Server.Mind
role.Greet();
var message = new RoleAddedEvent(role);
OwnedEntity?.EntityManager.EventBus.RaiseLocalEvent(OwnedEntity.Uid, message);
IEntity? tempQualifier = OwnedEntity;
(tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null).EventBus.RaiseLocalEvent(OwnedEntity.Uid, message);
return role;
}
@@ -206,7 +207,8 @@ namespace Content.Server.Mind
_roles.Remove(role);
var message = new RoleRemovedEvent(role);
OwnedEntity?.EntityManager.EventBus.RaiseLocalEvent(OwnedEntity.Uid, message);
IEntity? tempQualifier = OwnedEntity;
(tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null).EventBus.RaiseLocalEvent(OwnedEntity.Uid, message);
}
public bool HasRole<T>() where T : Role
@@ -380,7 +382,7 @@ namespace Content.Server.Mind
oldVisitingEnt.RemoveComponent<VisitingMindComponent>();
}
oldVisitingEnt.EntityManager.EventBus.RaiseLocalEvent(oldVisitingEnt.Uid, new MindUnvisitedMessage());
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(oldVisitingEnt.Uid, new MindUnvisitedMessage());
}
public bool TryGetSession([NotNullWhen(true)] out IPlayerSession? session)

View File

@@ -15,6 +15,7 @@ using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -119,7 +120,7 @@ namespace Content.Server.Morgue.Components
item.Delete();
}
var ash = Owner.EntityManager.SpawnEntity("Ash", Owner.Transform.Coordinates);
var ash = IoCManager.Resolve<IEntityManager>().SpawnEntity("Ash", Owner.Transform.Coordinates);
Contents.Insert(ash);
}

View File

@@ -100,7 +100,7 @@ namespace Content.Server.Morgue.Components
if (_tray == null)
{
_tray = Owner.EntityManager.SpawnEntity(_trayPrototypeId, Owner.Transform.Coordinates);
_tray = IoCManager.Resolve<IEntityManager>().SpawnEntity(_trayPrototypeId, Owner.Transform.Coordinates);
var trayComp = _tray.EnsureComponent<MorgueTrayComponent>();
trayComp.Morgue = Owner;
}

View File

@@ -173,7 +173,7 @@ namespace Content.Server.NodeContainer.Nodes
var position = Owner.Transform.Coordinates;
foreach (var entity in grid.GetInDir(position, pipeDir.ToDirection()))
{
if (!Owner.EntityManager.TryGetComponent<NodeContainerComponent>(entity, out var container))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<NodeContainerComponent>(entity, out var container))
continue;
foreach (var node in container.Nodes.Values)
@@ -196,7 +196,7 @@ namespace Content.Server.NodeContainer.Nodes
var position = Owner.Transform.Coordinates;
foreach (var entity in grid.GetLocal(position))
{
if (!Owner.EntityManager.TryGetComponent<NodeContainerComponent>(entity, out var container))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<NodeContainerComponent>(entity, out var container))
continue;
foreach (var node in container.Nodes.Values)

View File

@@ -197,7 +197,7 @@ namespace Content.Server.Nutrition.EntitySystems
{
//We're empty. Become trash.
var position = component.Owner.Transform.Coordinates;
var finisher = component.Owner.EntityManager.SpawnEntity(component.TrashPrototype, position);
var finisher = IoCManager.Resolve<IEntityManager>().SpawnEntity(component.TrashPrototype, position);
// If the user is holding the item
if (userUid != null &&

View File

@@ -390,7 +390,7 @@ namespace Content.Server.ParticleAccelerator.Components
var coords = Owner.Transform.Coordinates;
foreach (var maybeFuel in grid.GetCardinalNeighborCells(coords))
{
if (Owner.EntityManager.TryGetComponent(maybeFuel, out _partFuelChamber))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(maybeFuel, out _partFuelChamber))
{
break;
}
@@ -464,7 +464,7 @@ namespace Content.Server.ParticleAccelerator.Components
var coords = Owner.Transform.Coordinates;
foreach (var ent in grid.GetOffset(coords, offset))
{
if (Owner.EntityManager.TryGetComponent(ent, out part) && !part.Deleted)
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(ent, out part) && !part.Deleted)
{
return true;
}

View File

@@ -1,5 +1,6 @@
using Content.Shared.Singularity.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -15,7 +16,7 @@ namespace Content.Server.ParticleAccelerator.Components
public void Fire(ParticleAcceleratorPowerState strength)
{
var projectile = Owner.EntityManager.SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates);
var projectile = IoCManager.Resolve<IEntityManager>().SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates);
if (!projectile.TryGetComponent<ParticleProjectileComponent>(out var particleProjectileComponent))
{

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Content.Shared.Pulling;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Controllers;
using Robust.Shared.Maths;
@@ -74,7 +75,7 @@ namespace Content.Server.Physics.Controllers
// Now that's over with...
var pullerPosition = puller.Transform.MapPosition;
var movingTo = pullable.MovingTo.Value.ToMap(pullable.Owner.EntityManager);
var movingTo = pullable.MovingTo.Value.ToMap(IoCManager.Resolve<IEntityManager>());
if (movingTo.MapId != pullerPosition.MapId)
{
_pullableSystem.StopMoveTo(pullable);

View File

@@ -85,7 +85,7 @@ namespace Content.Server.Power.Components
#pragma warning disable 618
SendMessage(new PowerChangedMessage(Powered));
#pragma warning restore 618
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower));
if (Owner.TryGetComponent<AppearanceComponent>(out var appearance))
{

View File

@@ -7,6 +7,7 @@ using Content.Shared.Interaction;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.ViewVariables;
@@ -47,7 +48,7 @@ namespace Content.Server.Power.Components
if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner.Uid, eventArgs.User.Uid)) return false;
Owner.Delete();
var droppedEnt = Owner.EntityManager.SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation);
var droppedEnt = IoCManager.Resolve<IEntityManager>().SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation);
// TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated...
if (droppedEnt.TryGetComponent<StackComponent>(out var stack))

View File

@@ -40,7 +40,7 @@ namespace Content.Server.Power.Components
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
return false;
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager), out var grid))
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(IoCManager.Resolve<IEntityManager>()), out var grid))
return false;
var snapPos = grid.TileIndicesFor(eventArgs.ClickLocation);
@@ -51,7 +51,7 @@ namespace Content.Server.Power.Components
foreach (var anchored in grid.GetAnchoredEntities(snapPos))
{
if (Owner.EntityManager.TryGetComponent<CableComponent>(anchored, out var wire) && wire.CableType == _blockingCableType)
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<CableComponent>(anchored, out var wire) && wire.CableType == _blockingCableType)
{
return false;
}
@@ -61,7 +61,7 @@ namespace Content.Server.Power.Components
&& !EntitySystem.Get<StackSystem>().Use(Owner.Uid, 1, stack))
return false;
Owner.EntityManager.SpawnEntity(_cablePrototypeID, grid.GridTileToLocal(snapPos));
IoCManager.Resolve<IEntityManager>().SpawnEntity(_cablePrototypeID, grid.GridTileToLocal(snapPos));
return true;
}
}

View File

@@ -87,7 +87,7 @@ namespace Content.Server.Power.EntitySystems
if (EntityManager.TryGetComponent<ExtensionCableReceiverComponent>(entity.Uid, out var receiver) &&
receiver.Connectable &&
receiver.Provider == null &&
entity.Transform.Coordinates.TryDistance(owner.EntityManager, owner.Transform.Coordinates, out var distance) &&
entity.Transform.Coordinates.TryDistance(IoCManager.Resolve<IEntityManager>(), owner.Transform.Coordinates, out var distance) &&
distance < Math.Min(range, receiver.ReceptionRange))
{
yield return receiver;
@@ -185,7 +185,7 @@ namespace Content.Server.Power.EntitySystems
if (!provider.Connectable) continue;
if (!entity.Transform.Coordinates.TryDistance(owner.EntityManager, owner.Transform.Coordinates, out var distance)) continue;
if (!entity.Transform.Coordinates.TryDistance(IoCManager.Resolve<IEntityManager>(), owner.Transform.Coordinates, out var distance)) continue;
if (!(distance < Math.Min(range, provider.TransferRange))) continue;

View File

@@ -7,6 +7,7 @@ using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -148,7 +149,7 @@ namespace Content.Server.PowerCell.Components
SoundSystem.Play(Filter.Pvs(Owner), CellRemoveSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f));
}
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(true), false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(true), false);
return cell;
}
@@ -171,7 +172,7 @@ namespace Content.Server.PowerCell.Components
SoundSystem.Play(Filter.Pvs(Owner), CellInsertSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f));
}
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(false), false);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(false), false);
return true;
}
@@ -198,7 +199,7 @@ namespace Content.Server.PowerCell.Components
};
}
var cell = Owner.EntityManager.SpawnEntity(type, Owner.Transform.Coordinates);
var cell = IoCManager.Resolve<IEntityManager>().SpawnEntity(type, Owner.Transform.Coordinates);
_cellContainer.Insert(cell);
}
}

View File

@@ -59,7 +59,7 @@ namespace Content.Server.Projectiles.Components
var gridOrMap = user.Transform.GridID == GridId.Invalid ? mapManager.GetMapEntityId(user.Transform.MapID) :
mapManager.GetGrid(user.Transform.GridID).GridEntityId;
var parentXform = Owner.EntityManager.GetComponent<TransformComponent>(gridOrMap);
var parentXform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(gridOrMap);
var localCoordinates = new EntityCoordinates(gridOrMap, parentXform.InvWorldMatrix.Transform(user.Transform.WorldPosition));
var localAngle = angle - parentXform.WorldRotation;

View File

@@ -1,5 +1,6 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Recycling.Components
@@ -32,7 +33,7 @@ namespace Content.Server.Recycling.Components
{
for (var i = 0; i < Math.Max(_amount * efficiency, 1); i++)
{
Owner.EntityManager.SpawnEntity(_prototype, Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(_prototype, Owner.Transform.Coordinates);
}
}

View File

@@ -2,6 +2,7 @@ using Content.Shared.Popups;
using Content.Shared.Rotatable;
using Content.Shared.Verbs;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
@@ -83,7 +84,7 @@ namespace Content.Server.Rotatable
}
var oldTransform = component.Owner.Transform;
var entity = component.Owner.EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(component.MirrorEntity, oldTransform.Coordinates);
var newTransform = entity.Transform;
newTransform.LocalRotation = oldTransform.LocalRotation;
newTransform.Anchored = false;

View File

@@ -166,7 +166,7 @@ namespace Content.Server.Singularity.EntitySystems
private void Fire(EmitterComponent component)
{
var projectile = component.Owner.EntityManager.SpawnEntity(component.BoltType, component.Owner.Transform.Coordinates);
var projectile = IoCManager.Resolve<IEntityManager>().SpawnEntity(component.BoltType, component.Owner.Transform.Coordinates);
if (!projectile.TryGetComponent<PhysicsComponent>(out var physicsComponent))
{

View File

@@ -62,7 +62,7 @@ namespace Content.Server.Spawners.Components
}
if(!Owner.Deleted)
Owner.EntityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
}
public virtual void MapInit()

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Spawners.Components
{
if (RarePrototypes.Count > 0 && (RareChance == 1.0f || _robustRandom.Prob(RareChance)))
{
Owner.EntityManager.SpawnEntity(_robustRandom.Pick(RarePrototypes), Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(_robustRandom.Pick(RarePrototypes), Owner.Transform.Coordinates);
return;
}
@@ -54,7 +54,7 @@ namespace Content.Server.Spawners.Components
var x_negative = random.Prob(0.5f) ? -1 : 1;
var y_negative = random.Prob(0.5f) ? -1 : 1;
var entity = Owner.EntityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
entity.Transform.LocalPosition += new Vector2(random.NextFloat() * Offset * x_negative, random.NextFloat() * Offset * y_negative);
}

View File

@@ -76,7 +76,7 @@ namespace Content.Server.Spawners.Components
for (int i = 0; i < number; i++)
{
var entity = _robustRandom.Pick(Prototypes);
Owner.EntityManager.SpawnEntity(entity, Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(entity, Owner.Transform.Coordinates);
}
}
}

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

@@ -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);

View File

@@ -5,6 +5,7 @@ using Content.Shared.MobState.Components;
using Content.Shared.Tag;
using Content.Shared.Throwing;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
@@ -96,7 +97,7 @@ namespace Content.Server.Throwing
if (user != null && pushbackRatio > 0.0f && user.TryGetComponent(out IPhysBody? body))
{
var msg = new ThrowPushbackAttemptEvent();
body.Owner.EntityManager.EventBus.RaiseLocalEvent(body.Owner.Uid, msg);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(body.Owner.Uid, msg);
if (!msg.Cancelled)
{

View File

@@ -64,10 +64,10 @@ namespace Content.Server.Tiles
var mapManager = IoCManager.Resolve<IMapManager>();
var location = eventArgs.ClickLocation.AlignWithClosestGridTile();
var locationMap = location.ToMap(Owner.EntityManager);
var locationMap = location.ToMap(IoCManager.Resolve<IEntityManager>());
if (locationMap.MapId == MapId.Nullspace)
return true;
mapManager.TryGetGrid(location.GetGridId(Owner.EntityManager), out var mapGrid);
mapManager.TryGetGrid(location.GetGridId(IoCManager.Resolve<IEntityManager>()), out var mapGrid);
if (_outputTiles == null)
return true;

View File

@@ -37,7 +37,7 @@ namespace Content.Server.Tools.Components
if (!Owner.TryGetComponent<ToolComponent>(out var tool) && _toolComponentNeeded)
return;
if (!_mapManager.TryGetGrid(clickLocation.GetGridId(Owner.EntityManager), out var mapGrid))
if (!_mapManager.TryGetGrid(clickLocation.GetGridId(IoCManager.Resolve<IEntityManager>()), out var mapGrid))
return;
var tile = mapGrid.GetTileRef(clickLocation);
@@ -55,7 +55,7 @@ namespace Content.Server.Tools.Components
if (_toolComponentNeeded && !await EntitySystem.Get<ToolSystem>().UseTool(Owner.Uid, user.Uid, null, 0f, 0f, _qualityNeeded, toolComponent:tool))
return;
coordinates.PryTile(Owner.EntityManager, _mapManager);
coordinates.PryTile(IoCManager.Resolve<IEntityManager>(), _mapManager);
}
}
}

View File

@@ -106,7 +106,7 @@ namespace Content.Server.TraitorDeathMatch.Components
}
// 4 is the per-PDA bonus amount.
var accounts = Owner.EntityManager.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
var accounts = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
var transferAmount = victimAccount.Balance + 4;
accounts.SetBalance(victimAccount, 0);
accounts.AddToBalance(userAccount, transferAmount);

View File

@@ -185,7 +185,7 @@ namespace Content.Server.VendingMachines
{
_ejecting = false;
TrySetVisualState(VendingMachineVisualState.Normal);
Owner.EntityManager.SpawnEntity(id, Owner.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(id, Owner.Transform.Coordinates);
});
SoundSystem.Play(Filter.Pvs(Owner), _soundVend.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));

View File

@@ -82,7 +82,7 @@ namespace Content.Server.Weapon.Melee
var target = args.TargetEntity;
var location = args.User.Transform.Coordinates;
var diff = args.ClickLocation.ToMapPos(owner.EntityManager) - location.ToMapPos(owner.EntityManager);
var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - location.ToMapPos(IoCManager.Resolve<IEntityManager>());
var angle = Angle.FromWorldVec(diff);
if (target != null)
@@ -139,7 +139,7 @@ namespace Content.Server.Weapon.Melee
var owner = EntityManager.GetEntity(uid);
var location = args.User.Transform.Coordinates;
var diff = args.ClickLocation.ToMapPos(owner.EntityManager) - location.ToMapPos(owner.EntityManager);
var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - location.ToMapPos(IoCManager.Resolve<IEntityManager>());
var angle = Angle.FromWorldVec(diff);
// This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes.
@@ -220,7 +220,7 @@ namespace Content.Server.Weapon.Melee
return;
var location = args.User.Transform.Coordinates;
var diff = args.ClickLocation.ToMapPos(owner.EntityManager) - location.ToMapPos(owner.EntityManager);
var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - location.ToMapPos(IoCManager.Resolve<IEntityManager>());
var angle = Angle.FromWorldVec(diff);
var hitEvent = new MeleeInteractEvent(args.Target, args.User);

View File

@@ -10,6 +10,7 @@ using Content.Shared.Popups;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
@@ -90,7 +91,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
if (_unspawnedCount > 0)
{
ammo = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
ammo = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
// when dumping from held ammo box, this detaches the spawned ammo from the player.
ammo.Transform.AttachParentToContainerOrGrid();

View File

@@ -122,7 +122,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
appearanceComponent.SetData(AmmoVisuals.Spent, true);
}
var entity = Owner.EntityManager.SpawnEntity(_projectileId, spawnAt);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_projectileId, spawnAt);
return entity;
}

View File

@@ -10,6 +10,7 @@ using Content.Shared.Popups;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
@@ -127,7 +128,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
else if (_unspawnedCount > 0)
{
_unspawnedCount--;
ammo = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
ammo = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
}
UpdateAppearance();

View File

@@ -8,6 +8,7 @@ using Content.Shared.Popups;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -129,7 +130,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
if (_unspawnedCount > 0)
{
entity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
_unspawnedCount--;
}

View File

@@ -10,6 +10,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
@@ -110,7 +111,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_unspawnedCount > 0)
{
_unspawnedCount--;
var chamberEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
var chamberEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
_chamberContainer.Insert(chamberEntity);
}
}
@@ -319,7 +320,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
else if (_unspawnedCount > 0)
{
_unspawnedCount--;
var ammoEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
var ammoEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
_chamberContainer.Insert(ammoEntity);
return true;
}

View File

@@ -9,6 +9,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
@@ -182,7 +183,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_unspawnedCount > 0)
{
_unspawnedCount--;
var ammoEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
var ammoEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
_chamberContainer.Insert(ammoEntity);
}

View File

@@ -114,7 +114,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
for (var i = 0; i < _unspawnedCount; i++)
{
var entity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
_ammoSlots[idx] = entity;
_ammoContainer.Insert(entity);
idx++;

View File

@@ -11,6 +11,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Players;
@@ -96,7 +97,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
_powerCellContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-powercell-container", out var existing);
if (!existing && _powerCellPrototype != null)
{
var powerCellEntity = Owner.EntityManager.SpawnEntity(_powerCellPrototype, Owner.Transform.Coordinates);
var powerCellEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_powerCellPrototype, Owner.Transform.Coordinates);
_powerCellContainer.Insert(powerCellEntity);
}
@@ -133,7 +134,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
var ammo = _ammoContainer.ContainedEntity;
if (ammo == null)
{
ammo = Owner.EntityManager.SpawnEntity(_ammoPrototype, Owner.Transform.Coordinates);
ammo = IoCManager.Resolve<IEntityManager>().SpawnEntity(_ammoPrototype, Owner.Transform.Coordinates);
_ammoContainer.Insert(ammo);
}
@@ -174,7 +175,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
}
else
{
entity = Owner.EntityManager.SpawnEntity(_ammoPrototype, spawnAt);
entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_ammoPrototype, spawnAt);
}
if (entity.TryGetComponent(out ProjectileComponent? projectileComponent))

View File

@@ -14,6 +14,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
@@ -179,7 +180,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (!existing && _magFillPrototype != null)
{
var magEntity = Owner.EntityManager.SpawnEntity(_magFillPrototype, Owner.Transform.Coordinates);
var magEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_magFillPrototype, Owner.Transform.Coordinates);
MagazineContainer.Insert(magEntity);
}
Dirty();

View File

@@ -330,7 +330,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
else
{
projectile =
Owner.EntityManager.SpawnEntity(baseProjectile.Prototype?.ID, baseProjectile.Transform.Coordinates);
IoCManager.Resolve<IEntityManager>().SpawnEntity(baseProjectile.Prototype?.ID, baseProjectile.Transform.Coordinates);
}
firedProjectiles[i] = projectile.Uid;
@@ -366,8 +366,8 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
projectile.Transform.WorldRotation = projectileAngle + MathHelper.PiOver2;
}
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new GunShotEvent(firedProjectiles));
Owner.EntityManager.EventBus.RaiseLocalEvent(ammo.Uid, new AmmoShotEvent(firedProjectiles));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new GunShotEvent(firedProjectiles));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(ammo.Uid, new AmmoShotEvent(firedProjectiles));
}
/// <summary>
@@ -391,7 +391,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
/// </summary>
private void FireHitscan(IEntity shooter, HitscanComponent hitscan, Angle angle)
{
var ray = new CollisionRay(Owner.Transform.Coordinates.ToMapPos(Owner.EntityManager), angle.ToVec(), (int) hitscan.CollisionMask);
var ray = new CollisionRay(Owner.Transform.Coordinates.ToMapPos(IoCManager.Resolve<IEntityManager>()), angle.ToVec(), (int) hitscan.CollisionMask);
var physicsManager = EntitySystem.Get<SharedPhysicsSystem>();
var rayCastResults = physicsManager.IntersectRay(Owner.Transform.MapID, ray, hitscan.MaxLength, shooter, false).ToList();

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>

Some files were not shown because too many files have changed in this diff Show More