Even more resolve removals.

This commit is contained in:
Vera Aguilera Puerto
2021-12-08 17:32:32 +01:00
parent 684cb76173
commit cdc8336695
61 changed files with 364 additions and 278 deletions

View File

@@ -119,7 +119,7 @@ namespace Content.Server.Atmos.Components
public static bool IsMovedByPressure(this EntityUid entity, [NotNullWhen(true)] out MovedByPressureComponent? moved) public static bool IsMovedByPressure(this EntityUid entity, [NotNullWhen(true)] out MovedByPressureComponent? moved)
{ {
return _entMan.TryGetComponent(entity, out moved) && return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out moved) &&
moved.Enabled; moved.Enabled;
} }
} }

View File

@@ -23,6 +23,7 @@ namespace Content.Server.Nutrition.Components
[RegisterComponent] [RegisterComponent]
public sealed class HungerComponent : SharedHungerComponent public sealed class HungerComponent : SharedHungerComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
private float _accumulatedFrameTime; private float _accumulatedFrameTime;
@@ -88,13 +89,13 @@ namespace Content.Server.Nutrition.Components
{ {
// Revert slow speed if required // Revert slow speed if required
if (_lastHungerThreshold == HungerThreshold.Starving && _currentHungerThreshold != HungerThreshold.Dead && if (_lastHungerThreshold == HungerThreshold.Starving && _currentHungerThreshold != HungerThreshold.Dead &&
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MovementSpeedModifierComponent? movementSlowdownComponent)) _entMan.TryGetComponent(Owner, out MovementSpeedModifierComponent? movementSlowdownComponent))
{ {
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner); EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
} }
// Update UI // Update UI
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ServerAlertsComponent? alertsComponent); _entMan.TryGetComponent(Owner, out ServerAlertsComponent? alertsComponent);
if (HungerThresholdAlertTypes.TryGetValue(_currentHungerThreshold, out var alertId)) if (HungerThresholdAlertTypes.TryGetValue(_currentHungerThreshold, out var alertId))
{ {
@@ -185,7 +186,7 @@ namespace Content.Server.Nutrition.Components
return; return;
// --> Current Hunger is below dead threshold // --> Current Hunger is below dead threshold
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MobStateComponent? mobState)) if (!_entMan.TryGetComponent(Owner, out MobStateComponent? mobState))
return; return;
if (!mobState.IsDead()) if (!mobState.IsDead())

View File

@@ -23,6 +23,7 @@ namespace Content.Server.Nutrition.Components
[RegisterComponent] [RegisterComponent]
public sealed class ThirstComponent : SharedThirstComponent public sealed class ThirstComponent : SharedThirstComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
private float _accumulatedFrameTime; private float _accumulatedFrameTime;
@@ -87,13 +88,13 @@ namespace Content.Server.Nutrition.Components
{ {
// Revert slow speed if required // Revert slow speed if required
if (_lastThirstThreshold == ThirstThreshold.Parched && _currentThirstThreshold != ThirstThreshold.Dead && if (_lastThirstThreshold == ThirstThreshold.Parched && _currentThirstThreshold != ThirstThreshold.Dead &&
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MovementSpeedModifierComponent? movementSlowdownComponent)) _entMan.TryGetComponent(Owner, out MovementSpeedModifierComponent? movementSlowdownComponent))
{ {
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner); EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
} }
// Update UI // Update UI
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ServerAlertsComponent? alertsComponent); _entMan.TryGetComponent(Owner, out ServerAlertsComponent? alertsComponent);
if (ThirstThresholdAlertTypes.TryGetValue(_currentThirstThreshold, out var alertId)) if (ThirstThresholdAlertTypes.TryGetValue(_currentThirstThreshold, out var alertId))
{ {
@@ -182,7 +183,7 @@ namespace Content.Server.Nutrition.Components
return; return;
// --> Current Hunger is below dead threshold // --> Current Hunger is below dead threshold
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MobStateComponent? mobState)) if (!_entMan.TryGetComponent(Owner, out MobStateComponent? mobState))
return; return;
if (!mobState.IsDead()) if (!mobState.IsDead())

View File

@@ -96,7 +96,7 @@ namespace Content.Server.Nutrition.EntitySystems
// This is awful. I hate this so much. // This is awful. I hate this so much.
// TODO: Please, someone refactor containers and free me from this bullshit. // TODO: Please, someone refactor containers and free me from this bullshit.
if (!smokable.Owner.TryGetContainerMan(out var containerManager) || if (!smokable.Owner.TryGetContainerMan(out var containerManager) ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(containerManager.Owner, out BloodstreamComponent? bloodstream)) !EntityManager.TryGetComponent(containerManager.Owner, out BloodstreamComponent? bloodstream))
continue; continue;
_reactiveSystem.ReactionEntity(containerManager.Owner, ReactionMethod.Ingestion, inhaledSolution); _reactiveSystem.ReactionEntity(containerManager.Owner, ReactionMethod.Ingestion, inhaledSolution);

View File

@@ -19,18 +19,20 @@ namespace Content.Server.PDA
{ {
IdCardComponent? firstIdInPda = null; IdCardComponent? firstIdInPda = null;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player, out HandsComponent? hands)) var entMan = IoCManager.Resolve<IEntityManager>();
if (entMan.TryGetComponent(player, out HandsComponent? hands))
{ {
foreach (var item in hands.GetAllHeldItems()) foreach (var item in hands.GetAllHeldItems())
{ {
if (firstIdInPda == null && if (firstIdInPda == null &&
IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Owner, out PDAComponent? pda) && entMan.TryGetComponent(item.Owner, out PDAComponent? pda) &&
pda.ContainedID != null) pda.ContainedID != null)
{ {
firstIdInPda = pda.ContainedID; firstIdInPda = pda.ContainedID;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Owner, out IdCardComponent? card)) if (entMan.TryGetComponent(item.Owner, out IdCardComponent? card))
{ {
return card; return card;
} }
@@ -44,18 +46,18 @@ namespace Content.Server.PDA
IdCardComponent? firstIdInInventory = null; IdCardComponent? firstIdInInventory = null;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player, out InventoryComponent? inventory)) if (entMan.TryGetComponent(player, out InventoryComponent? inventory))
{ {
foreach (var item in inventory.GetAllHeldItems()) foreach (var item in inventory.GetAllHeldItems())
{ {
if (firstIdInInventory == null && if (firstIdInInventory == null &&
IoCManager.Resolve<IEntityManager>().TryGetComponent(item, out PDAComponent? pda) && entMan.TryGetComponent(item, out PDAComponent? pda) &&
pda.ContainedID != null) pda.ContainedID != null)
{ {
firstIdInInventory = pda.ContainedID; firstIdInInventory = pda.ContainedID;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(item, out IdCardComponent? card)) if (entMan.TryGetComponent(item, out IdCardComponent? card))
{ {
return card; return card;
} }

View File

@@ -19,6 +19,8 @@ namespace Content.Server.Paper
public class PaperComponent : SharedPaperComponent, IExamine, IInteractUsing, IUse public class PaperComponent : SharedPaperComponent, IExamine, IInteractUsing, IUse
#pragma warning restore 618 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private PaperAction _mode; private PaperAction _mode;
[DataField("content")] [DataField("content")]
public string Content { get; set; } = ""; public string Content { get; set; } = "";
@@ -43,7 +45,7 @@ namespace Content.Server.Paper
Content = content + '\n'; Content = content + '\n';
UpdateUserInterface(); UpdateUserInterface();
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (!_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
return; return;
var status = string.IsNullOrWhiteSpace(content) var status = string.IsNullOrWhiteSpace(content)
@@ -74,7 +76,7 @@ namespace Content.Server.Paper
bool IUse.UseEntity(UseEntityEventArgs eventArgs) bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
return false; return false;
_mode = PaperAction.Read; _mode = PaperAction.Read;
@@ -91,12 +93,12 @@ namespace Content.Server.Paper
Content += msg.Text + '\n'; Content += msg.Text + '\n';
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(PaperVisuals.Status, PaperStatus.Written); appearance.SetData(PaperVisuals.Status, PaperStatus.Written);
} }
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityDescription = ""; _entMan.GetComponent<MetaDataComponent>(Owner).EntityDescription = "";
UpdateUserInterface(); UpdateUserInterface();
} }
@@ -104,7 +106,7 @@ namespace Content.Server.Paper
{ {
if (!eventArgs.Using.HasTag("Write")) if (!eventArgs.Using.HasTag("Write"))
return false; return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
return false; return false;
_mode = PaperAction.Write; _mode = PaperAction.Write;

View File

@@ -36,6 +36,7 @@ namespace Content.Server.ParticleAccelerator.Components
[RegisterComponent] [RegisterComponent]
public class ParticleAcceleratorControlBoxComponent : ParticleAcceleratorPartComponent, IActivate, IWires public class ParticleAcceleratorControlBoxComponent : ParticleAcceleratorPartComponent, IActivate, IWires
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
public override string Name => "ParticleAcceleratorControlBox"; public override string Name => "ParticleAcceleratorControlBox";
@@ -221,12 +222,12 @@ namespace Content.Server.ParticleAccelerator.Components
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
{ {
return; return;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<WiresComponent?>(Owner, out var wires) && wires.IsPanelOpen) if (_entMan.TryGetComponent<WiresComponent?>(Owner, out var wires) && wires.IsPanelOpen)
{ {
wires.OpenInterface(actor.PlayerSession); wires.OpenInterface(actor.PlayerSession);
} }
@@ -333,7 +334,7 @@ namespace Content.Server.ParticleAccelerator.Components
private void UpdateWireStatus() private void UpdateWireStatus()
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out WiresComponent? wires)) if (!_entMan.TryGetComponent(Owner, out WiresComponent? wires))
{ {
return; return;
} }
@@ -383,13 +384,13 @@ namespace Content.Server.ParticleAccelerator.Components
_partEmitterRight = null; _partEmitterRight = null;
// Find fuel chamber first by scanning cardinals. // Find fuel chamber first by scanning cardinals.
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Anchored) if (_entMan.GetComponent<TransformComponent>(Owner).Anchored)
{ {
var grid = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID); var grid = _mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridID);
var coords = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates; var coords = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
foreach (var maybeFuel in grid.GetCardinalNeighborCells(coords)) foreach (var maybeFuel in grid.GetCardinalNeighborCells(coords))
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(maybeFuel, out _partFuelChamber)) if (_entMan.TryGetComponent(maybeFuel, out _partFuelChamber))
{ {
break; break;
} }
@@ -405,7 +406,7 @@ namespace Content.Server.ParticleAccelerator.Components
// Align ourselves to match fuel chamber orientation. // Align ourselves to match fuel chamber orientation.
// This means that if you mess up the orientation of the control box it's not a big deal, // This means that if you mess up the orientation of the control box it's not a big deal,
// because the sprite is far from obvious about the orientation. // because the sprite is far from obvious about the orientation.
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_partFuelChamber.Owner).LocalRotation; _entMan.GetComponent<TransformComponent>(Owner).LocalRotation = _entMan.GetComponent<TransformComponent>(_partFuelChamber.Owner).LocalRotation;
var offsetEndCap = RotateOffset((1, 1)); var offsetEndCap = RotateOffset((1, 1));
var offsetPowerBox = RotateOffset((1, -1)); var offsetPowerBox = RotateOffset((1, -1));
@@ -451,7 +452,7 @@ namespace Content.Server.ParticleAccelerator.Components
Vector2i RotateOffset(in Vector2i vec) Vector2i RotateOffset(in Vector2i vec)
{ {
var rot = new Angle(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation); var rot = new Angle(_entMan.GetComponent<TransformComponent>(Owner).LocalRotation);
return (Vector2i) rot.RotateVec(vec); return (Vector2i) rot.RotateVec(vec);
} }
} }
@@ -459,11 +460,11 @@ namespace Content.Server.ParticleAccelerator.Components
private bool ScanPart<T>(Vector2i offset, [NotNullWhen(true)] out T? part) private bool ScanPart<T>(Vector2i offset, [NotNullWhen(true)] out T? part)
where T : ParticleAcceleratorPartComponent where T : ParticleAcceleratorPartComponent
{ {
var grid = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID); var grid = _mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridID);
var coords = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates; var coords = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
foreach (var ent in grid.GetOffset(coords, offset)) foreach (var ent in grid.GetOffset(coords, offset))
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(ent, out part) && !part.Deleted) if (_entMan.TryGetComponent(ent, out part) && !part.Deleted)
{ {
return true; return true;
} }
@@ -576,7 +577,7 @@ namespace Content.Server.ParticleAccelerator.Components
private void UpdateAppearance() private void UpdateAppearance()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(ParticleAcceleratorVisuals.VisualState, appearance.SetData(ParticleAcceleratorVisuals.VisualState,
_apcPowerReceiverComponent!.Powered _apcPowerReceiverComponent!.Powered
@@ -682,7 +683,7 @@ namespace Content.Server.ParticleAccelerator.Components
private void UpdatePartVisualState(ParticleAcceleratorPartComponent? component) private void UpdatePartVisualState(ParticleAcceleratorPartComponent? component)
{ {
if (component == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(component.Owner, out var appearanceComponent)) if (component == null || !_entMan.TryGetComponent<AppearanceComponent?>(component.Owner, out var appearanceComponent))
{ {
return; return;
} }

View File

@@ -13,6 +13,8 @@ namespace Content.Server.ParticleAccelerator.Components
[RegisterComponent] [RegisterComponent]
public class ParticleProjectileComponent : Component public class ParticleProjectileComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "ParticleProjectile"; public override string Name => "ParticleProjectile";
public ParticleAcceleratorPowerState State; public ParticleAcceleratorPowerState State;
@@ -20,21 +22,21 @@ namespace Content.Server.ParticleAccelerator.Components
{ {
State = state; State = state;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(Owner, out var physicsComponent)) if (!_entMan.TryGetComponent<PhysicsComponent?>(Owner, out var physicsComponent))
{ {
Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent"); Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
return; return;
} }
physicsComponent.BodyStatus = BodyStatus.InAir; physicsComponent.BodyStatus = BodyStatus.InAir;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ProjectileComponent?>(Owner, out var projectileComponent)) if (!_entMan.TryGetComponent<ProjectileComponent?>(Owner, out var projectileComponent))
{ {
Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent"); Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent");
return; return;
} }
projectileComponent.IgnoreEntity(firer); projectileComponent.IgnoreEntity(firer);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SinguloFoodComponent?>(Owner, out var singuloFoodComponent)) if (!_entMan.TryGetComponent<SinguloFoodComponent?>(Owner, out var singuloFoodComponent))
{ {
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent"); Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent");
return; return;
@@ -59,7 +61,7 @@ namespace Content.Server.ParticleAccelerator.Components
_ => "0" _ => "0"
}; };
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(Owner, out var spriteComponent)) if (!_entMan.TryGetComponent<SpriteComponent?>(Owner, out var spriteComponent))
{ {
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent"); Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent");
return; return;
@@ -69,8 +71,8 @@ namespace Content.Server.ParticleAccelerator.Components
physicsComponent physicsComponent
.LinearVelocity = angle.ToWorldVec() * 20f; .LinearVelocity = angle.ToWorldVec() * 20f;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation = angle; _entMan.GetComponent<TransformComponent>(Owner).LocalRotation = angle;
Timer.Spawn(3000, () => IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner)); Timer.Spawn(3000, () => _entMan.DeleteEntity(Owner));
} }
} }
} }

View File

@@ -41,11 +41,12 @@ namespace Content.Server.Physics.Controllers
} }
var direction = system.GetAngle(comp).ToVec(); var direction = system.GetAngle(comp).ToVec();
var ownerPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(comp.Owner).WorldPosition; var entMan = IoCManager.Resolve<IEntityManager>();
var ownerPos = entMan.GetComponent<TransformComponent>(comp.Owner).WorldPosition;
foreach (var (entity, physics) in EntitySystem.Get<ConveyorSystem>().GetEntitiesToMove(comp)) foreach (var (entity, physics) in EntitySystem.Get<ConveyorSystem>().GetEntitiesToMove(comp))
{ {
var itemRelativeToConveyor = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition - ownerPos; var itemRelativeToConveyor = entMan.GetComponent<TransformComponent>(entity).WorldPosition - ownerPos;
physics.LinearVelocity += Convey(direction, comp.Speed, frameTime, itemRelativeToConveyor); physics.LinearVelocity += Convey(direction, comp.Speed, frameTime, itemRelativeToConveyor);
} }
} }

View File

@@ -270,7 +270,7 @@ namespace Content.Server.Physics.Controllers
{ {
if (!mover.Owner.HasTag("FootstepSound")) return; if (!mover.Owner.HasTag("FootstepSound")) return;
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mover.Owner); var transform = EntityManager.GetComponent<TransformComponent>(mover.Owner);
var coordinates = transform.Coordinates; var coordinates = transform.Coordinates;
var gridId = coordinates.GetGridId(EntityManager); var gridId = coordinates.GetGridId(EntityManager);
var distanceNeeded = mover.Sprinting ? StepSoundMoveDistanceRunning : StepSoundMoveDistanceWalking; var distanceNeeded = mover.Sprinting ? StepSoundMoveDistanceRunning : StepSoundMoveDistanceWalking;
@@ -302,9 +302,9 @@ namespace Content.Server.Physics.Controllers
mobMover.StepSoundDistance -= distanceNeeded; mobMover.StepSoundDistance -= distanceNeeded;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<InventoryComponent?>(mover.Owner, out var inventory) if (EntityManager.TryGetComponent<InventoryComponent?>(mover.Owner, out var inventory)
&& inventory.TryGetSlotItem<ItemComponent>(EquipmentSlotDefines.Slots.SHOES, out var item) && inventory.TryGetSlotItem<ItemComponent>(EquipmentSlotDefines.Slots.SHOES, out var item)
&& IoCManager.Resolve<IEntityManager>().TryGetComponent<FootstepModifierComponent?>(item.Owner, out var modifier)) && EntityManager.TryGetComponent<FootstepModifierComponent?>(item.Owner, out var modifier))
{ {
modifier.PlayFootstep(); modifier.PlayFootstep();
} }
@@ -351,7 +351,7 @@ namespace Content.Server.Physics.Controllers
SoundSystem.Play( SoundSystem.Play(
Filter.Pvs(coordinates), Filter.Pvs(coordinates),
soundToPlay, soundToPlay,
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mover).Coordinates, EntityManager.GetComponent<TransformComponent>(mover).Coordinates,
sprinting ? AudioParams.Default.WithVolume(0.75f) : null); sprinting ? AudioParams.Default.WithVolume(0.75f) : null);
} }
} }

View File

@@ -21,7 +21,7 @@ namespace Content.Server.Physics.Controllers
foreach (var (singularity, physics) in EntityManager.EntityQuery<ServerSingularityComponent, PhysicsComponent>()) foreach (var (singularity, physics) in EntityManager.EntityQuery<ServerSingularityComponent, PhysicsComponent>())
{ {
if (IoCManager.Resolve<IEntityManager>().HasComponent<ActorComponent>(singularity.Owner) || if (EntityManager.HasComponent<ActorComponent>(singularity.Owner) ||
singularity.BeingDeletedByAnotherSingularity) continue; singularity.BeingDeletedByAnotherSingularity) continue;
singularity.MoveAccumulator -= frameTime; singularity.MoveAccumulator -= frameTime;

View File

@@ -11,6 +11,8 @@ namespace Content.Server.Plants.Components
[RegisterComponent] [RegisterComponent]
public class RandomPottedPlantComponent : Component, IMapInit public class RandomPottedPlantComponent : Component, IMapInit
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "RandomPottedPlant"; public override string Name => "RandomPottedPlant";
private static readonly string[] RegularPlantStates; private static readonly string[] RegularPlantStates;
@@ -61,7 +63,7 @@ namespace Content.Server.Plants.Components
if (_selectedState != null) if (_selectedState != null)
{ {
IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(Owner).LayerSetState(0, _selectedState); _entMan.GetComponent<SpriteComponent>(Owner).LayerSetState(0, _selectedState);
} }
} }
@@ -72,7 +74,7 @@ namespace Content.Server.Plants.Components
var list = _plastic ? PlasticPlantStates : RegularPlantStates; var list = _plastic ? PlasticPlantStates : RegularPlantStates;
_selectedState = random.Pick(list); _selectedState = random.Pick(list);
IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(Owner).LayerSetState(0, _selectedState); _entMan.GetComponent<SpriteComponent>(Owner).LayerSetState(0, _selectedState);
} }
} }
} }

View File

@@ -11,6 +11,8 @@ namespace Content.Server.Pointing.Components
[RegisterComponent] [RegisterComponent]
public class PointingArrowComponent : SharedPointingArrowComponent public class PointingArrowComponent : SharedPointingArrowComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
/// <summary> /// <summary>
/// The current amount of seconds left on this arrow. /// The current amount of seconds left on this arrow.
/// </summary> /// </summary>
@@ -58,7 +60,7 @@ namespace Content.Server.Pointing.Components
{ {
base.Startup(); base.Startup();
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SpriteComponent? sprite)) if (_entMan.TryGetComponent(Owner, out SpriteComponent? sprite))
{ {
sprite.DrawDepth = (int) DrawDepth.Overlays; sprite.DrawDepth = (int) DrawDepth.Overlays;
} }
@@ -67,7 +69,7 @@ namespace Content.Server.Pointing.Components
public void Update(float frameTime) public void Update(float frameTime)
{ {
var movement = _speed * frameTime * (_up ? 1 : -1); var movement = _speed * frameTime * (_up ? 1 : -1);
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalPosition += (0, movement); _entMan.GetComponent<TransformComponent>(Owner).LocalPosition += (0, movement);
_duration -= frameTime; _duration -= frameTime;
_currentStep -= frameTime; _currentStep -= frameTime;
@@ -76,12 +78,12 @@ namespace Content.Server.Pointing.Components
{ {
if (_rogue) if (_rogue)
{ {
IoCManager.Resolve<IEntityManager>().RemoveComponent<PointingArrowComponent>(Owner); _entMan.RemoveComponent<PointingArrowComponent>(Owner);
IoCManager.Resolve<IEntityManager>().AddComponent<RoguePointingArrowComponent>(Owner); _entMan.AddComponent<RoguePointingArrowComponent>(Owner);
return; return;
} }
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
return; return;
} }

View File

@@ -24,6 +24,7 @@ namespace Content.Server.Power.Components
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
public class ApcComponent : BaseApcNetComponent, IActivate public class ApcComponent : BaseApcNetComponent, IActivate
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "Apc"; public override string Name => "Apc";
@@ -56,7 +57,7 @@ namespace Content.Server.Power.Components
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ApcUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ApcUiKey.Key);
public BatteryComponent? Battery => IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? batteryComponent) ? batteryComponent : null; public BatteryComponent? Battery => _entMan.TryGetComponent(Owner, out BatteryComponent? batteryComponent) ? batteryComponent : null;
[ComponentDependency] private AccessReader? _accessReader = null; [ComponentDependency] private AccessReader? _accessReader = null;
@@ -94,7 +95,7 @@ namespace Content.Server.Power.Components
if (_accessReader == null || accessSystem.IsAllowed(_accessReader, attached)) if (_accessReader == null || accessSystem.IsAllowed(_accessReader, attached))
{ {
MainBreakerEnabled = !MainBreakerEnabled; MainBreakerEnabled = !MainBreakerEnabled;
IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner).CanDischarge = MainBreakerEnabled; _entMan.GetComponent<PowerNetworkBatteryComponent>(Owner).CanDischarge = MainBreakerEnabled;
_uiDirty = true; _uiDirty = true;
SoundSystem.Play(Filter.Pvs(Owner), _onReceiveMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); SoundSystem.Play(Filter.Pvs(Owner), _onReceiveMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
@@ -113,12 +114,12 @@ namespace Content.Server.Power.Components
_lastChargeState = newState; _lastChargeState = newState;
_lastChargeStateChange = _gameTiming.CurTime; _lastChargeStateChange = _gameTiming.CurTime;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(ApcVisuals.ChargeState, newState); appearance.SetData(ApcVisuals.ChargeState, newState);
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SharedPointLightComponent? light)) if (_entMan.TryGetComponent(Owner, out SharedPointLightComponent? light))
{ {
light.Color = newState switch light.Color = newState switch
{ {
@@ -131,7 +132,7 @@ namespace Content.Server.Power.Components
} }
} }
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? battery); _entMan.TryGetComponent(Owner, out BatteryComponent? battery);
var newCharge = battery?.CurrentCharge; var newCharge = battery?.CurrentCharge;
if (newCharge != null && newCharge != _lastCharge && _lastChargeChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime) if (newCharge != null && newCharge != _lastCharge && _lastChargeChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime)
@@ -158,7 +159,7 @@ namespace Content.Server.Power.Components
private ApcChargeState CalcChargeState() private ApcChargeState CalcChargeState()
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? battery)) if (!_entMan.TryGetComponent(Owner, out BatteryComponent? battery))
{ {
return ApcChargeState.Lack; return ApcChargeState.Lack;
} }
@@ -170,7 +171,7 @@ namespace Content.Server.Power.Components
return ApcChargeState.Full; return ApcChargeState.Full;
} }
var netBattery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner); var netBattery = _entMan.GetComponent<PowerNetworkBatteryComponent>(Owner);
var delta = netBattery.CurrentSupply - netBattery.CurrentReceiving; var delta = netBattery.CurrentSupply - netBattery.CurrentReceiving;
return delta < 0 ? ApcChargeState.Charging : ApcChargeState.Lack; return delta < 0 ? ApcChargeState.Charging : ApcChargeState.Lack;
@@ -182,7 +183,7 @@ namespace Content.Server.Power.Components
if (bat == null) if (bat == null)
return ApcExternalPowerState.None; return ApcExternalPowerState.None;
var netBat = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner); var netBat = _entMan.GetComponent<PowerNetworkBatteryComponent>(Owner);
if (netBat.CurrentReceiving == 0 && netBat.LoadingNetworkDemand != 0) if (netBat.CurrentReceiving == 0 && netBat.LoadingNetworkDemand != 0)
{ {
return ApcExternalPowerState.None; return ApcExternalPowerState.None;
@@ -199,7 +200,7 @@ namespace Content.Server.Power.Components
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
{ {
return; return;
} }

View File

@@ -24,6 +24,8 @@ namespace Content.Server.Power.Components
public class ApcPowerReceiverComponent : Component, IExamine public class ApcPowerReceiverComponent : Component, IExamine
#pragma warning restore 618 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "ApcPowerReceiver"; public override string Name => "ApcPowerReceiver";
[ViewVariables] [ViewVariables]
@@ -85,9 +87,9 @@ namespace Content.Server.Power.Components
#pragma warning disable 618 #pragma warning disable 618
SendMessage(new PowerChangedMessage(Powered)); SendMessage(new PowerChangedMessage(Powered));
#pragma warning restore 618 #pragma warning restore 618
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower)); _entMan.EventBus.RaiseLocalEvent(Owner, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower));
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(Owner, out var appearance)) if (_entMan.TryGetComponent<AppearanceComponent?>(Owner, out var appearance))
{ {
appearance.SetData(PowerDeviceVisuals.Powered, Powered); appearance.SetData(PowerDeviceVisuals.Powered, Powered);
} }

View File

@@ -19,6 +19,8 @@ namespace Content.Server.Power.Components
[ComponentReference(typeof(IInteractUsing))] [ComponentReference(typeof(IInteractUsing))]
public abstract class BaseCharger : Component, IActivate, IInteractUsing public abstract class BaseCharger : Component, IActivate, IInteractUsing
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[ViewVariables] [ViewVariables]
private BatteryComponent? _heldBattery; private BatteryComponent? _heldBattery;
@@ -97,12 +99,12 @@ namespace Content.Server.Power.Components
Container.Remove(heldItem); Container.Remove(heldItem);
_heldBattery = null; _heldBattery = null;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent)) if (_entMan.TryGetComponent(user, out HandsComponent? handsComponent))
{ {
handsComponent.PutInHandOrDrop(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(heldItem)); handsComponent.PutInHandOrDrop(_entMan.GetComponent<ItemComponent>(heldItem));
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(heldItem, out ServerBatteryBarrelComponent? batteryBarrelComponent)) if (_entMan.TryGetComponent(heldItem, out ServerBatteryBarrelComponent? batteryBarrelComponent))
{ {
batteryBarrelComponent.UpdateAppearance(); batteryBarrelComponent.UpdateAppearance();
} }
@@ -117,7 +119,7 @@ namespace Content.Server.Power.Components
private CellChargerStatus GetStatus() private CellChargerStatus GetStatus()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) && if (_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) &&
!receiver.Powered) !receiver.Powered)
{ {
return CellChargerStatus.Off; return CellChargerStatus.Off;
@@ -160,13 +162,13 @@ namespace Content.Server.Power.Components
// Not called UpdateAppearance just because it messes with the load // Not called UpdateAppearance just because it messes with the load
var status = GetStatus(); var status = GetStatus();
if (_status == status || if (_status == status ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver)) !_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver))
{ {
return; return;
} }
_status = status; _status = status;
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance); _entMan.TryGetComponent(Owner, out AppearanceComponent? appearance);
switch (_status) switch (_status)
{ {
@@ -205,7 +207,7 @@ namespace Content.Server.Power.Components
private void TransferPower(float frameTime) private void TransferPower(float frameTime)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) && if (_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) &&
!receiver.Powered) !receiver.Powered)
{ {
return; return;

View File

@@ -18,6 +18,8 @@ namespace Content.Server.Power.Components
public abstract class BaseNetConnectorComponent<TNetType> : Component, IBaseNetConnectorComponent<TNetType> public abstract class BaseNetConnectorComponent<TNetType> : Component, IBaseNetConnectorComponent<TNetType>
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public Voltage Voltage { get => _voltage; set => SetVoltage(value); } public Voltage Voltage { get => _voltage; set => SetVoltage(value); }
[DataField("voltage")] [DataField("voltage")]
@@ -68,7 +70,7 @@ namespace Content.Server.Power.Components
private bool TryFindNet([NotNullWhen(true)] out TNetType? foundNet) private bool TryFindNet([NotNullWhen(true)] out TNetType? foundNet)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<NodeContainerComponent?>(Owner, out var container)) if (_entMan.TryGetComponent<NodeContainerComponent?>(Owner, out var container))
{ {
var compatibleNet = container.Nodes.Values var compatibleNet = container.Nodes.Values
.Where(node => (NodeId == null || NodeId == node.Name) && node.NodeGroupID == (NodeGroupID) Voltage) .Where(node => (NodeId == null || NodeId == node.Name) && node.NodeGroupID == (NodeGroupID) Voltage)

View File

@@ -18,6 +18,8 @@ namespace Content.Server.Power.Components
[RegisterComponent] [RegisterComponent]
public class CableComponent : Component, IInteractUsing public class CableComponent : Component, IInteractUsing
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "Cable"; public override string Name => "Cable";
[ViewVariables] [ViewVariables]
@@ -45,11 +47,11 @@ namespace Content.Server.Power.Components
if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner, eventArgs.User)) return false; if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner, eventArgs.User)) return false;
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
var droppedEnt = IoCManager.Resolve<IEntityManager>().SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation); var droppedEnt = _entMan.SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation);
// TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated... // TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated...
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(droppedEnt, out var stack)) if (_entMan.TryGetComponent<StackComponent?>(droppedEnt, out var stack))
EntitySystem.Get<StackSystem>().SetCount(droppedEnt, 1, stack); EntitySystem.Get<StackSystem>().SetCount(droppedEnt, 1, stack);
return true; return true;

View File

@@ -15,6 +15,7 @@ namespace Content.Server.Power.Components
[RegisterComponent] [RegisterComponent]
internal class CablePlacerComponent : Component, IAfterInteract internal class CablePlacerComponent : Component, IAfterInteract
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
/// <inheritdoc /> /// <inheritdoc />
@@ -40,7 +41,7 @@ namespace Content.Server.Power.Components
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
return false; return false;
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(IoCManager.Resolve<IEntityManager>()), out var grid)) if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(_entMan), out var grid))
return false; return false;
var snapPos = grid.TileIndicesFor(eventArgs.ClickLocation); var snapPos = grid.TileIndicesFor(eventArgs.ClickLocation);
@@ -51,17 +52,17 @@ namespace Content.Server.Power.Components
foreach (var anchored in grid.GetAnchoredEntities(snapPos)) foreach (var anchored in grid.GetAnchoredEntities(snapPos))
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<CableComponent>(anchored, out var wire) && wire.CableType == _blockingCableType) if (_entMan.TryGetComponent<CableComponent>(anchored, out var wire) && wire.CableType == _blockingCableType)
{ {
return false; return false;
} }
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(Owner, out var stack) if (_entMan.TryGetComponent<StackComponent?>(Owner, out var stack)
&& !EntitySystem.Get<StackSystem>().Use(Owner, 1, stack)) && !EntitySystem.Get<StackSystem>().Use(Owner, 1, stack))
return false; return false;
IoCManager.Resolve<IEntityManager>().SpawnEntity(_cablePrototypeID, grid.GridTileToLocal(snapPos)); _entMan.SpawnEntity(_cablePrototypeID, grid.GridTileToLocal(snapPos));
return true; return true;
} }
} }

View File

@@ -18,6 +18,7 @@ namespace Content.Server.Power.SMES
[RegisterComponent] [RegisterComponent]
public class SmesComponent : Component public class SmesComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "Smes"; public override string Name => "Smes";
@@ -47,7 +48,7 @@ namespace Content.Server.Power.SMES
_lastChargeLevel = newLevel; _lastChargeLevel = newLevel;
_lastChargeLevelChange = _gameTiming.CurTime; _lastChargeLevelChange = _gameTiming.CurTime;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(SmesVisuals.LastChargeLevel, newLevel); appearance.SetData(SmesVisuals.LastChargeLevel, newLevel);
} }
@@ -59,7 +60,7 @@ namespace Content.Server.Power.SMES
_lastChargeState = newChargeState; _lastChargeState = newChargeState;
_lastChargeStateChange = _gameTiming.CurTime; _lastChargeStateChange = _gameTiming.CurTime;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(SmesVisuals.LastChargeState, newChargeState); appearance.SetData(SmesVisuals.LastChargeState, newChargeState);
} }
@@ -68,7 +69,7 @@ namespace Content.Server.Power.SMES
private int GetNewChargeLevel() private int GetNewChargeLevel()
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? battery)) if (!_entMan.TryGetComponent(Owner, out BatteryComponent? battery))
{ {
return 0; return 0;
} }
@@ -78,7 +79,7 @@ namespace Content.Server.Power.SMES
private ChargeState GetNewChargeState() private ChargeState GetNewChargeState()
{ {
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner); var battery = _entMan.GetComponent<PowerNetworkBatteryComponent>(Owner);
return (battery.CurrentSupply - battery.CurrentReceiving) switch return (battery.CurrentSupply - battery.CurrentReceiving) switch
{ {
> 0 => ChargeState.Discharging, > 0 => ChargeState.Discharging,

View File

@@ -21,6 +21,7 @@ namespace Content.Server.Projectiles.Components
[RegisterComponent] [RegisterComponent]
public class HitscanComponent : Component public class HitscanComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "Hitscan"; public override string Name => "Hitscan";
@@ -56,12 +57,12 @@ namespace Content.Server.Projectiles.Components
var mapManager = IoCManager.Resolve<IMapManager>(); var mapManager = IoCManager.Resolve<IMapManager>();
// We'll get the effects relative to the grid / map of the firer // We'll get the effects relative to the grid / map of the firer
var gridOrMap = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).GridID == GridId.Invalid ? mapManager.GetMapEntityId(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).MapID) : var gridOrMap = _entMan.GetComponent<TransformComponent>(user).GridID == GridId.Invalid ? mapManager.GetMapEntityId(_entMan.GetComponent<TransformComponent>(user).MapID) :
mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).GridID).GridEntityId; mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(user).GridID).GridEntityId;
var parentXform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(gridOrMap); var parentXform = _entMan.GetComponent<TransformComponent>(gridOrMap);
var localCoordinates = new EntityCoordinates(gridOrMap, parentXform.InvWorldMatrix.Transform(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).WorldPosition)); var localCoordinates = new EntityCoordinates(gridOrMap, parentXform.InvWorldMatrix.Transform(_entMan.GetComponent<TransformComponent>(user).WorldPosition));
var localAngle = angle - parentXform.WorldRotation; var localAngle = angle - parentXform.WorldRotation;
var afterEffect = AfterEffects(localCoordinates, localAngle, distance, 1.0f); var afterEffect = AfterEffects(localCoordinates, localAngle, distance, 1.0f);
@@ -96,9 +97,9 @@ namespace Content.Server.Projectiles.Components
Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () =>
{ {
if (!((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)) if (!((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted))
{ {
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
} }
}); });
} }
@@ -161,7 +162,7 @@ namespace Content.Server.Projectiles.Components
EffectSprite = _impactFlash, EffectSprite = _impactFlash,
Born = _startTime, Born = _startTime,
DeathTime = _deathTime, DeathTime = _deathTime,
Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates.Offset(angle.ToVec() * distance), Coordinates = _entMan.GetComponent<TransformComponent>(Owner).Coordinates.Offset(angle.ToVec() * distance),
//Rotated from east facing //Rotated from east facing
Rotation = (float) angle.FlipPositive(), Rotation = (float) angle.FlipPositive(),
Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier), Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier),

View File

@@ -15,6 +15,7 @@ namespace Content.Server.Radiation
[ComponentReference(typeof(SharedRadiationPulseComponent))] [ComponentReference(typeof(SharedRadiationPulseComponent))]
public sealed class RadiationPulseComponent : SharedRadiationPulseComponent public sealed class RadiationPulseComponent : SharedRadiationPulseComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
@@ -107,11 +108,11 @@ namespace Content.Server.Radiation
public void Update(float frameTime) public void Update(float frameTime)
{ {
if (!Decay || (!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (!Decay || (!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
return; return;
if (_duration <= 0f) if (_duration <= 0f)
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner); _entMan.QueueDeleteEntity(Owner);
_duration -= frameTime; _duration -= frameTime;
} }

View File

@@ -12,6 +12,7 @@ namespace Content.Server.Radiation
[UsedImplicitly] [UsedImplicitly]
public sealed class RadiationPulseSystem : EntitySystem public sealed class RadiationPulseSystem : EntitySystem
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IEntityLookup _lookup = default!; [Dependency] private readonly IEntityLookup _lookup = default!;
private const float RadiationCooldown = 0.5f; private const float RadiationCooldown = 0.5f;
@@ -33,16 +34,16 @@ namespace Content.Server.Radiation
comp.Update(RadiationCooldown); comp.Update(RadiationCooldown);
var ent = comp.Owner; var ent = comp.Owner;
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(ent) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ent).EntityLifeStage) >= EntityLifeStage.Deleted) continue; if ((!_entMan.EntityExists(ent) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(ent).EntityLifeStage) >= EntityLifeStage.Deleted) continue;
foreach (var entity in _lookup.GetEntitiesInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent).Coordinates, comp.Range)) foreach (var entity in _lookup.GetEntitiesInRange(_entMan.GetComponent<TransformComponent>(ent).Coordinates, comp.Range))
{ {
// For now at least still need this because it uses a list internally then returns and this may be deleted before we get to it. // For now at least still need this because it uses a list internally then returns and this may be deleted before we get to it.
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) continue; if ((!_entMan.EntityExists(entity) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) continue;
// Note: Radiation is liable for a refactor (stinky Sloth coding a basic version when he did StationEvents) // Note: Radiation is liable for a refactor (stinky Sloth coding a basic version when he did StationEvents)
// so this ToArray doesn't really matter. // so this ToArray doesn't really matter.
foreach (var radiation in IoCManager.Resolve<IEntityManager>().GetComponents<IRadiationAct>(entity).ToArray()) foreach (var radiation in _entMan.GetComponents<IRadiationAct>(entity).ToArray())
{ {
radiation.RadiationAct(RadiationCooldown, comp); radiation.RadiationAct(RadiationCooldown, comp);
} }

View File

@@ -8,6 +8,8 @@ namespace Content.Server.Recycling.Components
[RegisterComponent] [RegisterComponent]
public class RecyclableComponent : Component public class RecyclableComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "Recyclable"; public override string Name => "Recyclable";
/// <summary> /// <summary>
@@ -33,12 +35,12 @@ namespace Content.Server.Recycling.Components
{ {
for (var i = 0; i < Math.Max(_amount * efficiency, 1); i++) for (var i = 0; i < Math.Max(_amount * efficiency, 1); i++)
{ {
IoCManager.Resolve<IEntityManager>().SpawnEntity(_prototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); _entMan.SpawnEntity(_prototype, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
} }
} }
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner); _entMan.QueueDeleteEntity(Owner);
} }
} }
} }

View File

@@ -21,6 +21,8 @@ namespace Content.Server.Recycling.Components
[Friend(typeof(RecyclerSystem))] [Friend(typeof(RecyclerSystem))]
public class RecyclerComponent : Component, ISuicideAct public class RecyclerComponent : Component, ISuicideAct
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "Recycler"; public override string Name => "Recycler";
/// <summary> /// <summary>
@@ -39,7 +41,7 @@ namespace Content.Server.Recycling.Components
private void Clean() private void Clean()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(RecyclerVisuals.Bloody, false); appearance.SetData(RecyclerVisuals.Bloody, false);
} }
@@ -47,7 +49,7 @@ namespace Content.Server.Recycling.Components
SuicideKind ISuicideAct.Suicide(EntityUid victim, IChatManager chat) SuicideKind ISuicideAct.Suicide(EntityUid victim, IChatManager chat)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(victim, out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind) if (_entMan.TryGetComponent(victim, out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind)
{ {
EntitySystem.Get<GameTicker>().OnGhostAttempt(mind, false); EntitySystem.Get<GameTicker>().OnGhostAttempt(mind, false);
mind.OwnedEntity?.PopupMessage(Loc.GetString("recycler-component-suicide-message")); mind.OwnedEntity?.PopupMessage(Loc.GetString("recycler-component-suicide-message"));
@@ -55,7 +57,7 @@ namespace Content.Server.Recycling.Components
victim.PopupMessageOtherClients(Loc.GetString("recycler-component-suicide-message-others", ("victim",victim))); victim.PopupMessageOtherClients(Loc.GetString("recycler-component-suicide-message-others", ("victim",victim)));
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBodyComponent?>(victim, out var body)) if (_entMan.TryGetComponent<SharedBodyComponent?>(victim, out var body))
{ {
body.Gib(true); body.Gib(true);
} }

View File

@@ -22,12 +22,13 @@ namespace Content.Server.Research.Components
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
public class ResearchConsoleComponent : SharedResearchConsoleComponent, IActivate public class ResearchConsoleComponent : SharedResearchConsoleComponent, IActivate
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[DataField("sound")] [DataField("sound")]
private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard"); private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard");
[ViewVariables] private bool Powered => !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private bool Powered => !_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchConsoleUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchConsoleUiKey.Key);
@@ -47,9 +48,9 @@ namespace Content.Server.Research.Components
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message) private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out TechnologyDatabaseComponent? database)) if (!_entMan.TryGetComponent(Owner, out TechnologyDatabaseComponent? database))
return; return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ResearchClientComponent? client)) if (!_entMan.TryGetComponent(Owner, out ResearchClientComponent? client))
return; return;
if (!Powered) if (!Powered)
return; return;
@@ -90,7 +91,7 @@ namespace Content.Server.Research.Components
private ResearchConsoleBoundInterfaceState GetNewUiState() private ResearchConsoleBoundInterfaceState GetNewUiState()
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ResearchClientComponent? client) || if (!_entMan.TryGetComponent(Owner, out ResearchClientComponent? client) ||
client.Server == null) client.Server == null)
return new ResearchConsoleBoundInterfaceState(default, default); return new ResearchConsoleBoundInterfaceState(default, default);
@@ -111,7 +112,7 @@ namespace Content.Server.Research.Components
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
return; return;
if (!Powered) if (!Powered)
{ {

View File

@@ -55,7 +55,7 @@ namespace Content.Server.Sandbox.Commands
return; return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eUid, out NodeContainerComponent? nodeContainerComponent)) if (!entityManager.TryGetComponent(eUid, out NodeContainerComponent? nodeContainerComponent))
{ {
shell.WriteLine(Loc.GetString("shell-entity-is-not-node-container")); shell.WriteLine(Loc.GetString("shell-entity-is-not-node-container"));
return; return;

View File

@@ -17,6 +17,8 @@ namespace Content.Server.Singularity.Components
[ComponentReference(typeof(SharedContainmentFieldGeneratorComponent))] [ComponentReference(typeof(SharedContainmentFieldGeneratorComponent))]
public class ContainmentFieldGeneratorComponent : SharedContainmentFieldGeneratorComponent public class ContainmentFieldGeneratorComponent : SharedContainmentFieldGeneratorComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private int _powerBuffer; private int _powerBuffer;
[ViewVariables] [ViewVariables]
@@ -95,9 +97,9 @@ namespace Content.Server.Singularity.Components
{ {
if (_connection1?.Item1 == direction || _connection2?.Item1 == direction) continue; if (_connection1?.Item1 == direction || _connection2?.Item1 == direction) continue;
var dirVec = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldRotation.RotateVec(direction.ToVec()); var dirVec = _entMan.GetComponent<TransformComponent>(Owner).WorldRotation.RotateVec(direction.ToVec());
var ray = new CollisionRay(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldPosition, dirVec, (int) CollisionGroup.MobMask); var ray = new CollisionRay(_entMan.GetComponent<TransformComponent>(Owner).WorldPosition, dirVec, (int) CollisionGroup.MobMask);
var rawRayCastResults = EntitySystem.Get<SharedPhysicsSystem>().IntersectRay(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapID, ray, 4.5f, Owner, false); var rawRayCastResults = EntitySystem.Get<SharedPhysicsSystem>().IntersectRay(_entMan.GetComponent<TransformComponent>(Owner).MapID, ray, 4.5f, Owner, false);
var rayCastResults = rawRayCastResults as RayCastResults[] ?? rawRayCastResults.ToArray(); var rayCastResults = rawRayCastResults as RayCastResults[] ?? rawRayCastResults.ToArray();
if(!rayCastResults.Any()) continue; if(!rayCastResults.Any()) continue;
@@ -113,11 +115,11 @@ namespace Content.Server.Singularity.Components
} }
if(closestResult == null) continue; if(closestResult == null) continue;
var ent = closestResult.Value.HitEntity; var ent = closestResult.Value.HitEntity;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainmentFieldGeneratorComponent?>(ent, out var fieldGeneratorComponent) || if (!_entMan.TryGetComponent<ContainmentFieldGeneratorComponent?>(ent, out var fieldGeneratorComponent) ||
fieldGeneratorComponent.Owner == Owner || fieldGeneratorComponent.Owner == Owner ||
!fieldGeneratorComponent.HasFreeConnections() || !fieldGeneratorComponent.HasFreeConnections() ||
IsConnectedWith(fieldGeneratorComponent) || IsConnectedWith(fieldGeneratorComponent) ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(ent, out var collidableComponent) || !_entMan.TryGetComponent<PhysicsComponent?>(ent, out var collidableComponent) ||
collidableComponent.BodyType != BodyType.Static) collidableComponent.BodyType != BodyType.Static)
{ {
continue; continue;

View File

@@ -14,6 +14,8 @@ namespace Content.Server.Singularity.Components
[ComponentReference(typeof(SharedSingularityComponent))] [ComponentReference(typeof(SharedSingularityComponent))]
public class ServerSingularityComponent : SharedSingularityComponent public class ServerSingularityComponent : SharedSingularityComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private SharedSingularitySystem _singularitySystem = default!; private SharedSingularitySystem _singularitySystem = default!;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
@@ -27,7 +29,7 @@ namespace Content.Server.Singularity.Components
_energy = value; _energy = value;
if (_energy <= 0) if (_energy <= 0)
{ {
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
return; return;
} }
@@ -92,7 +94,7 @@ namespace Content.Server.Singularity.Components
protected override void Shutdown() protected override void Shutdown()
{ {
base.Shutdown(); base.Shutdown();
SoundSystem.Play(Filter.Pvs(Owner), _singularityCollapsingSound.GetSound(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); SoundSystem.Play(Filter.Pvs(Owner), _singularityCollapsingSound.GetSound(), _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
} }
} }
} }

View File

@@ -7,6 +7,8 @@ namespace Content.Server.Singularity.Components
[RegisterComponent] [RegisterComponent]
public class SingularityGeneratorComponent : Component public class SingularityGeneratorComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "SingularityGenerator"; public override string Name => "SingularityGenerator";
[ViewVariables] private int _power; [ViewVariables] private int _power;
@@ -21,8 +23,7 @@ namespace Content.Server.Singularity.Components
_power = value; _power = value;
if (_power > 15) if (_power > 15)
{ {
var entityManager = IoCManager.Resolve<IEntityManager>(); _entMan.SpawnEntity("Singularity", _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
entityManager.SpawnEntity("Singularity", IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
//dont delete ourselves, just wait to get eaten //dont delete ourselves, just wait to get eaten
} }
} }

View File

@@ -12,6 +12,7 @@ namespace Content.Server.Spawners.Components
[RegisterComponent] [RegisterComponent]
public class ConditionalSpawnerComponent : Component, IMapInit public class ConditionalSpawnerComponent : Component, IMapInit
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
public override string Name => "ConditionalSpawner"; public override string Name => "ConditionalSpawner";
@@ -61,8 +62,8 @@ namespace Content.Server.Spawners.Components
return; return;
} }
if(!((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)) if(_entMan.Deleted(Owner))
IoCManager.Resolve<IEntityManager>().SpawnEntity(_robustRandom.Pick(Prototypes), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); _entMan.SpawnEntity(_robustRandom.Pick(Prototypes), _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
} }
public virtual void MapInit() public virtual void MapInit()

View File

@@ -12,6 +12,7 @@ namespace Content.Server.Spawners.Components
[RegisterComponent] [RegisterComponent]
public class RandomSpawnerComponent : ConditionalSpawnerComponent public class RandomSpawnerComponent : ConditionalSpawnerComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
public override string Name => "RandomSpawner"; public override string Name => "RandomSpawner";
@@ -32,7 +33,7 @@ namespace Content.Server.Spawners.Components
{ {
if (RarePrototypes.Count > 0 && (RareChance == 1.0f || _robustRandom.Prob(RareChance))) if (RarePrototypes.Count > 0 && (RareChance == 1.0f || _robustRandom.Prob(RareChance)))
{ {
IoCManager.Resolve<IEntityManager>().SpawnEntity(_robustRandom.Pick(RarePrototypes), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); _entMan.SpawnEntity(_robustRandom.Pick(RarePrototypes), _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
return; return;
} }
@@ -47,15 +48,15 @@ namespace Content.Server.Spawners.Components
return; return;
} }
if(!((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)) if(!((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted))
{ {
var random = IoCManager.Resolve<IRobustRandom>(); var random = IoCManager.Resolve<IRobustRandom>();
var x_negative = random.Prob(0.5f) ? -1 : 1; var x_negative = random.Prob(0.5f) ? -1 : 1;
var y_negative = random.Prob(0.5f) ? -1 : 1; var y_negative = random.Prob(0.5f) ? -1 : 1;
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_robustRandom.Pick(Prototypes), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); var entity = _entMan.SpawnEntity(_robustRandom.Pick(Prototypes), _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).LocalPosition += new Vector2(random.NextFloat() * Offset * x_negative, random.NextFloat() * Offset * y_negative); _entMan.GetComponent<TransformComponent>(entity).LocalPosition += new Vector2(random.NextFloat() * Offset * x_negative, random.NextFloat() * Offset * y_negative);
} }
} }
@@ -63,7 +64,7 @@ namespace Content.Server.Spawners.Components
public override void MapInit() public override void MapInit()
{ {
Spawn(); Spawn();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
} }
} }
} }

View File

@@ -51,11 +51,13 @@ namespace Content.Server.StationEvents.Events
public override void Shutdown() public override void Shutdown()
{ {
var entMan = IoCManager.Resolve<IEntityManager>();
foreach (var entity in _powered) foreach (var entity in _powered)
{ {
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) continue; if (entMan.Deleted(entity)) continue;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ApcPowerReceiverComponent? powerReceiverComponent)) if (entMan.TryGetComponent(entity, out ApcPowerReceiverComponent? powerReceiverComponent))
{ {
powerReceiverComponent.PowerDisabled = false; powerReceiverComponent.PowerDisabled = false;
} }

View File

@@ -89,15 +89,15 @@ namespace Content.Server.StationEvents.Events
return; return;
var pulse = _entityManager.SpawnEntity("RadiationPulse", coordinates); var pulse = _entityManager.SpawnEntity("RadiationPulse", coordinates);
IoCManager.Resolve<IEntityManager>().GetComponent<RadiationPulseComponent>(pulse).DoPulse(); _entityManager.GetComponent<RadiationPulseComponent>(pulse).DoPulse();
ResetTimeUntilPulse(); ResetTimeUntilPulse();
} }
public static void SpawnPulseAt(EntityCoordinates at) public void SpawnPulseAt(EntityCoordinates at)
{ {
var pulse = IoCManager.Resolve<IEntityManager>() var pulse = IoCManager.Resolve<IEntityManager>()
.SpawnEntity("RadiationPulse", at); .SpawnEntity("RadiationPulse", at);
IoCManager.Resolve<IEntityManager>().GetComponent<RadiationPulseComponent>(pulse).DoPulse(); _entityManager.GetComponent<RadiationPulseComponent>(pulse).DoPulse();
} }
private bool TryFindRandomGrid(IMapGrid mapGrid, out EntityCoordinates coordinates) private bool TryFindRandomGrid(IMapGrid mapGrid, out EntityCoordinates coordinates)

View File

@@ -17,6 +17,7 @@ namespace Content.Server.Storage.Components
[RegisterComponent] [RegisterComponent]
public class CursedEntityStorageComponent : EntityStorageComponent public class CursedEntityStorageComponent : EntityStorageComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
public override string Name => "CursedEntityStorage"; public override string Name => "CursedEntityStorage";
@@ -31,7 +32,7 @@ namespace Content.Server.Storage.Components
// No contents, we do nothing // No contents, we do nothing
if (Contents.ContainedEntities.Count == 0) return; if (Contents.ContainedEntities.Count == 0) return;
var lockers = IoCManager.Resolve<IEntityManager>().EntityQuery<EntityStorageComponent>().Select(c => c.Owner).ToList(); var lockers = _entMan.EntityQuery<EntityStorageComponent>().Select(c => c.Owner).ToList();
if (lockers.Contains(Owner)) if (lockers.Contains(Owner))
lockers.Remove(Owner); lockers.Remove(Owner);
@@ -40,7 +41,7 @@ namespace Content.Server.Storage.Components
if (lockerEnt == null) return; // No valid lockers anywhere. if (lockerEnt == null) return; // No valid lockers anywhere.
var locker = IoCManager.Resolve<IEntityManager>().GetComponent<EntityStorageComponent>(lockerEnt); var locker = _entMan.GetComponent<EntityStorageComponent>(lockerEnt);
if (locker.Open) if (locker.Open)
locker.TryCloseStorage(Owner); locker.TryCloseStorage(Owner);

View File

@@ -33,6 +33,8 @@ namespace Content.Server.Storage.Components
[ComponentReference(typeof(IStorageComponent))] [ComponentReference(typeof(IStorageComponent))]
public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IExAct public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IExAct
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "EntityStorage"; public override string Name => "EntityStorage";
private const float MaxSize = 1.0f; // maximum width or height of an entity allowed inside the storage. private const float MaxSize = 1.0f; // maximum width or height of an entity allowed inside the storage.
@@ -148,7 +150,7 @@ namespace Content.Server.Storage.Components
Contents.ShowContents = _showContents; Contents.ShowContents = _showContents;
Contents.OccludesLight = _occludesLight; Contents.OccludesLight = _occludesLight;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<PlaceableSurfaceComponent?>(Owner, out var surface)) if (_entMan.TryGetComponent<PlaceableSurfaceComponent?>(Owner, out var surface))
{ {
EntitySystem.Get<PlaceableSurfaceSystem>().SetPlaceable(Owner, Open, surface); EntitySystem.Get<PlaceableSurfaceSystem>().SetPlaceable(Owner, Open, surface);
} }
@@ -169,7 +171,7 @@ namespace Content.Server.Storage.Components
return false; return false;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<LockComponent?>(Owner, out var @lock) && @lock.Locked) if (_entMan.TryGetComponent<LockComponent?>(Owner, out var @lock) && @lock.Locked)
{ {
if (!silent) Owner.PopupMessage(user, Loc.GetString("entity-storage-component-locked-message")); if (!silent) Owner.PopupMessage(user, Loc.GetString("entity-storage-component-locked-message"));
return false; return false;
@@ -214,14 +216,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 // 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 // Let's not insert admin ghosts, yeah? This is really a a hack and should be replaced by attempt events
if (IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(entity)) if (_entMan.HasComponent<GhostComponent>(entity))
continue; continue;
// checks // checks
var targetIsItem = IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(entity); var targetIsItem = _entMan.HasComponent<SharedItemComponent>(entity);
var targetIsMob = IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity); var targetIsMob = _entMan.HasComponent<SharedBodyComponent>(entity);
var storageIsItem = IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(Owner); var storageIsItem = _entMan.HasComponent<SharedItemComponent>(Owner);
var allowedToEat = false; var allowedToEat = false;
@@ -266,7 +268,7 @@ namespace Content.Server.Storage.Components
private void UpdateAppearance() private void UpdateAppearance()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(StorageVisuals.CanWeld, _canWeldShut); appearance.SetData(StorageVisuals.CanWeld, _canWeldShut);
appearance.SetData(StorageVisuals.Welded, _isWeldedShut); appearance.SetData(StorageVisuals.Welded, _isWeldedShut);
@@ -275,7 +277,7 @@ namespace Content.Server.Storage.Components
private void ModifyComponents() private void ModifyComponents()
{ {
if (!_isCollidableWhenOpen && IoCManager.Resolve<IEntityManager>().TryGetComponent<FixturesComponent?>(Owner, out var manager)) if (!_isCollidableWhenOpen && _entMan.TryGetComponent<FixturesComponent?>(Owner, out var manager))
{ {
if (Open) if (Open)
{ {
@@ -293,12 +295,12 @@ namespace Content.Server.Storage.Components
} }
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<PlaceableSurfaceComponent?>(Owner, out var surface)) if (_entMan.TryGetComponent<PlaceableSurfaceComponent?>(Owner, out var surface))
{ {
EntitySystem.Get<PlaceableSurfaceSystem>().SetPlaceable(Owner, Open, surface); EntitySystem.Get<PlaceableSurfaceSystem>().SetPlaceable(Owner, Open, surface);
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(StorageVisuals.Open, Open); appearance.SetData(StorageVisuals.Open, Open);
} }
@@ -307,7 +309,7 @@ namespace Content.Server.Storage.Components
protected virtual bool AddToContents(EntityUid entity) protected virtual bool AddToContents(EntityUid entity)
{ {
if (entity == Owner) return false; if (entity == Owner) return false;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IPhysBody? entityPhysicsComponent)) if (_entMan.TryGetComponent(entity, out IPhysBody? entityPhysicsComponent))
{ {
if (MaxSize < entityPhysicsComponent.GetWorldAABB().Size.X if (MaxSize < entityPhysicsComponent.GetWorldAABB().Size.X
|| MaxSize < entityPhysicsComponent.GetWorldAABB().Size.Y) || MaxSize < entityPhysicsComponent.GetWorldAABB().Size.Y)
@@ -321,7 +323,7 @@ namespace Content.Server.Storage.Components
public virtual Vector2 ContentsDumpPosition() public virtual Vector2 ContentsDumpPosition()
{ {
return IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldPosition; return _entMan.GetComponent<TransformComponent>(Owner).WorldPosition;
} }
private void EmptyContents() private void EmptyContents()
@@ -330,8 +332,8 @@ namespace Content.Server.Storage.Components
{ {
if (Contents.Remove(contained)) if (Contents.Remove(contained))
{ {
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(contained).WorldPosition = ContentsDumpPosition(); _entMan.GetComponent<TransformComponent>(contained).WorldPosition = ContentsDumpPosition();
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<IPhysBody?>(contained, out var physics)) if (_entMan.TryGetComponent<IPhysBody?>(contained, out var physics))
{ {
physics.CanCollide = true; physics.CanCollide = true;
} }
@@ -365,7 +367,7 @@ namespace Content.Server.Storage.Components
// Trying to add while open just dumps it on the ground below us. // Trying to add while open just dumps it on the ground below us.
if (Open) if (Open)
{ {
var entMan = IoCManager.Resolve<IEntityManager>(); var entMan = _entMan;
entMan.GetComponent<TransformComponent>(entity).WorldPosition = entMan.GetComponent<TransformComponent>(Owner).WorldPosition; entMan.GetComponent<TransformComponent>(entity).WorldPosition = entMan.GetComponent<TransformComponent>(Owner).WorldPosition;
return true; return true;
} }
@@ -453,7 +455,7 @@ namespace Content.Server.Storage.Components
var containedEntities = Contents.ContainedEntities.ToList(); var containedEntities = Contents.ContainedEntities.ToList();
foreach (var entity in containedEntities) foreach (var entity in containedEntities)
{ {
var exActs = IoCManager.Resolve<IEntityManager>().GetComponents<IExAct>(entity).ToArray(); var exActs = _entMan.GetComponents<IExAct>(entity).ToArray();
foreach (var exAct in exActs) foreach (var exAct in exActs)
{ {
exAct.OnExplosion(eventArgs); exAct.OnExplosion(eventArgs);

View File

@@ -18,7 +18,7 @@ namespace Content.Server.Storage.Components
[RegisterComponent] [RegisterComponent]
public class SecretStashComponent : Component, IDestroyAct public class SecretStashComponent : Component, IDestroyAct
{ {
[Dependency] private readonly IEntityManager _entities = default!; [Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "SecretStash"; public override string Name => "SecretStash";
@@ -30,7 +30,7 @@ namespace Content.Server.Storage.Components
[ViewVariables] private ContainerSlot _itemContainer = default!; [ViewVariables] private ContainerSlot _itemContainer = default!;
public string SecretPartName => _secretPartNameOverride ?? Loc.GetString("comp-secret-stash-secret-part-name", ("name", IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName)); public string SecretPartName => _secretPartNameOverride ?? Loc.GetString("comp-secret-stash-secret-part-name", ("name", _entMan.GetComponent<MetaDataComponent>(Owner).EntityName));
protected override void Initialize() protected override void Initialize()
{ {
@@ -52,7 +52,7 @@ namespace Content.Server.Storage.Components
return false; return false;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(itemToHide, out ItemComponent? item)) if (!_entMan.TryGetComponent(itemToHide, out ItemComponent? item))
return false; return false;
if (item.Size > _maxItemSize) if (item.Size > _maxItemSize)
@@ -62,7 +62,7 @@ namespace Content.Server.Storage.Components
return false; return false;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands)) if (!_entMan.TryGetComponent(user, out HandsComponent? hands))
return false; return false;
if (!hands.Drop(itemToHide, _itemContainer)) if (!hands.Drop(itemToHide, _itemContainer))
@@ -85,15 +85,15 @@ namespace Content.Server.Storage.Components
Owner.PopupMessage(user, Loc.GetString("comp-secret-stash-action-get-item-found-something", ("stash", SecretPartName))); Owner.PopupMessage(user, Loc.GetString("comp-secret-stash-action-get-item-found-something", ("stash", SecretPartName)));
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands)) if (_entMan.TryGetComponent(user, out HandsComponent? hands))
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(contained, out ItemComponent? item)) if (!_entMan.TryGetComponent(contained, out ItemComponent? item))
return false; return false;
hands.PutInHandOrDrop(item); hands.PutInHandOrDrop(item);
} }
else if (_itemContainer.Remove(contained)) else if (_itemContainer.Remove(contained))
{ {
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(contained).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates; _entMan.GetComponent<TransformComponent>(contained).Coordinates = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
} }
return true; return true;
@@ -113,7 +113,7 @@ namespace Content.Server.Storage.Components
// drop item inside // drop item inside
if (_itemContainer.ContainedEntity is {Valid: true} contained) if (_itemContainer.ContainedEntity is {Valid: true} contained)
{ {
_entities.GetComponent<TransformComponent>(contained).Coordinates = _entities.GetComponent<TransformComponent>(Owner).Coordinates; _entMan.GetComponent<TransformComponent>(contained).Coordinates = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
} }
} }
} }

View File

@@ -15,6 +15,8 @@ namespace Content.Server.Storage.Components
[RegisterComponent] [RegisterComponent]
public sealed class StorageFillComponent : Component, IMapInit public sealed class StorageFillComponent : Component, IMapInit
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "StorageFill"; public override string Name => "StorageFill";
[DataField("contents")] private List<EntitySpawnEntry> _contents = new(); [DataField("contents")] private List<EntitySpawnEntry> _contents = new();
@@ -28,7 +30,7 @@ namespace Content.Server.Storage.Components
return; return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out IStorageComponent? storage)) if (!_entMan.TryGetComponent(Owner, out IStorageComponent? storage))
{ {
Logger.Error($"StorageFillComponent couldn't find any StorageComponent ({Owner})"); Logger.Error($"StorageFillComponent couldn't find any StorageComponent ({Owner})");
return; return;
@@ -48,7 +50,7 @@ namespace Content.Server.Storage.Components
continue; continue;
} }
var entMan = IoCManager.Resolve<IEntityManager>(); var entMan = _entMan;
var transform = entMan.GetComponent<TransformComponent>(Owner); var transform = entMan.GetComponent<TransformComponent>(Owner);
for (var i = 0; i < storageItem.Amount; i++) for (var i = 0; i < storageItem.Amount; i++)

View File

@@ -22,6 +22,8 @@ namespace Content.Server.Suspicion
public class SuspicionRoleComponent : SharedSuspicionRoleComponent, IExamine public class SuspicionRoleComponent : SharedSuspicionRoleComponent, IExamine
#pragma warning restore 618 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private Role? _role; private Role? _role;
[ViewVariables] [ViewVariables]
private readonly HashSet<SuspicionRoleComponent> _allies = new(); private readonly HashSet<SuspicionRoleComponent> _allies = new();
@@ -60,7 +62,7 @@ namespace Content.Server.Suspicion
public bool IsDead() public bool IsDead()
{ {
return IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MobStateComponent? state) && return _entMan.TryGetComponent(Owner, out MobStateComponent? state) &&
state.IsDead(); state.IsDead();
} }
@@ -76,7 +78,7 @@ namespace Content.Server.Suspicion
public void SyncRoles() public void SyncRoles()
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MindComponent? mind) || if (!_entMan.TryGetComponent(Owner, out MindComponent? mind) ||
!mind.HasMind) !mind.HasMind)
{ {
return; return;

View File

@@ -20,6 +20,7 @@ namespace Content.Server.Tiles
[RegisterComponent] [RegisterComponent]
public class FloorTileItemComponent : Component, IAfterInteract public class FloorTileItemComponent : Component, IAfterInteract
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
public override string Name => "FloorTile"; public override string Name => "FloorTile";
@@ -58,16 +59,16 @@ namespace Content.Server.Tiles
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
return true; return true;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out StackComponent? stack)) if (!_entMan.TryGetComponent(Owner, out StackComponent? stack))
return true; return true;
var mapManager = IoCManager.Resolve<IMapManager>(); var mapManager = IoCManager.Resolve<IMapManager>();
var location = eventArgs.ClickLocation.AlignWithClosestGridTile(); var location = eventArgs.ClickLocation.AlignWithClosestGridTile();
var locationMap = location.ToMap(IoCManager.Resolve<IEntityManager>()); var locationMap = location.ToMap(_entMan);
if (locationMap.MapId == MapId.Nullspace) if (locationMap.MapId == MapId.Nullspace)
return true; return true;
mapManager.TryGetGrid(location.GetGridId(IoCManager.Resolve<IEntityManager>()), out var mapGrid); mapManager.TryGetGrid(location.GetGridId(_entMan), out var mapGrid);
if (_outputTiles == null) if (_outputTiles == null)
return true; return true;

View File

@@ -34,6 +34,8 @@ namespace Content.Server.Toilet
IInteractHand, IMapInit, IExamine, ISuicideAct IInteractHand, IMapInit, IExamine, ISuicideAct
#pragma warning restore 618 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public sealed override string Name => "Toilet"; public sealed override string Name => "Toilet";
private const float PryLidTime = 1f; private const float PryLidTime = 1f;
@@ -67,7 +69,7 @@ namespace Content.Server.Toilet
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{ {
// are player trying place or lift of cistern lid? // are player trying place or lift of cistern lid?
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Using, out ToolComponent? tool) if (_entMan.TryGetComponent(eventArgs.Using, out ToolComponent? tool)
&& tool.Qualities.Contains(_pryingQuality)) && tool.Qualities.Contains(_pryingQuality))
{ {
// check if someone is already prying this toilet // check if someone is already prying this toilet
@@ -111,7 +113,7 @@ namespace Content.Server.Toilet
// just want to up/down seat? // just want to up/down seat?
// check that nobody seats on seat right now // check that nobody seats on seat right now
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out StrapComponent? strap)) if (_entMan.TryGetComponent(Owner, out StrapComponent? strap))
{ {
if (strap.BuckledEntities.Count != 0) if (strap.BuckledEntities.Count != 0)
return false; return false;
@@ -142,7 +144,7 @@ namespace Content.Server.Toilet
private void UpdateSprite() private void UpdateSprite()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(ToiletVisuals.LidOpen, LidOpen); appearance.SetData(ToiletVisuals.LidOpen, LidOpen);
appearance.SetData(ToiletVisuals.SeatUp, IsSeatUp); appearance.SetData(ToiletVisuals.SeatUp, IsSeatUp);
@@ -152,23 +154,23 @@ namespace Content.Server.Toilet
SuicideKind ISuicideAct.Suicide(EntityUid victim, IChatManager chat) SuicideKind ISuicideAct.Suicide(EntityUid victim, IChatManager chat)
{ {
// check that victim even have head // check that victim even have head
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBodyComponent?>(victim, out var body) && if (_entMan.TryGetComponent<SharedBodyComponent?>(victim, out var body) &&
body.HasPartOfType(BodyPartType.Head)) body.HasPartOfType(BodyPartType.Head))
{ {
var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others", ("victim",Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(victim).EntityName),("owner", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName)); var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others", ("victim",Name: _entMan.GetComponent<MetaDataComponent>(victim).EntityName),("owner", Name: _entMan.GetComponent<MetaDataComponent>(Owner).EntityName));
victim.PopupMessageOtherClients(othersMessage); victim.PopupMessageOtherClients(othersMessage);
var selfMessage = Loc.GetString("toilet-component-suicide-head-message", ("owner", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName)); var selfMessage = Loc.GetString("toilet-component-suicide-head-message", ("owner", Name: _entMan.GetComponent<MetaDataComponent>(Owner).EntityName));
victim.PopupMessage(selfMessage); victim.PopupMessage(selfMessage);
return SuicideKind.Asphyxiation; return SuicideKind.Asphyxiation;
} }
else else
{ {
var othersMessage = Loc.GetString("toilet-component-suicide-message-others",("victim", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(victim).EntityName),("owner", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName)); var othersMessage = Loc.GetString("toilet-component-suicide-message-others",("victim", Name: _entMan.GetComponent<MetaDataComponent>(victim).EntityName),("owner", Name: _entMan.GetComponent<MetaDataComponent>(Owner).EntityName));
victim.PopupMessageOtherClients(othersMessage); victim.PopupMessageOtherClients(othersMessage);
var selfMessage = Loc.GetString("toilet-component-suicide-message", ("owner",Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName)); var selfMessage = Loc.GetString("toilet-component-suicide-message", ("owner",Name: _entMan.GetComponent<MetaDataComponent>(Owner).EntityName));
victim.PopupMessage(selfMessage); victim.PopupMessage(selfMessage);
return SuicideKind.Blunt; return SuicideKind.Blunt;

View File

@@ -14,6 +14,7 @@ namespace Content.Server.Tools.Components
[RegisterComponent] [RegisterComponent]
public class TilePryingComponent : Component, IAfterInteract public class TilePryingComponent : Component, IAfterInteract
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
@@ -33,10 +34,10 @@ namespace Content.Server.Tools.Components
public async void TryPryTile(EntityUid user, EntityCoordinates clickLocation) public async void TryPryTile(EntityUid user, EntityCoordinates clickLocation)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ToolComponent?>(Owner, out var tool) && _toolComponentNeeded) if (!_entMan.TryGetComponent<ToolComponent?>(Owner, out var tool) && _toolComponentNeeded)
return; return;
if (!_mapManager.TryGetGrid(clickLocation.GetGridId(IoCManager.Resolve<IEntityManager>()), out var mapGrid)) if (!_mapManager.TryGetGrid(clickLocation.GetGridId(_entMan), out var mapGrid))
return; return;
var tile = mapGrid.GetTileRef(clickLocation); var tile = mapGrid.GetTileRef(clickLocation);
@@ -54,7 +55,7 @@ namespace Content.Server.Tools.Components
if (_toolComponentNeeded && !await EntitySystem.Get<ToolSystem>().UseTool(Owner, user, null, 0f, 0f, _qualityNeeded, toolComponent:tool)) if (_toolComponentNeeded && !await EntitySystem.Get<ToolSystem>().UseTool(Owner, user, null, 0f, 0f, _qualityNeeded, toolComponent:tool))
return; return;
coordinates.PryTile(IoCManager.Resolve<IEntityManager>(), _mapManager); coordinates.PryTile(_entMan, _mapManager);
} }
} }
} }

View File

@@ -15,19 +15,21 @@ namespace Content.Server.TraitorDeathMatch.Components
[RegisterComponent] [RegisterComponent]
public class TraitorDeathMatchRedemptionComponent : Component, IInteractUsing public class TraitorDeathMatchRedemptionComponent : Component, IInteractUsing
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
/// <inheritdoc /> /// <inheritdoc />
public override string Name => "TraitorDeathMatchRedemption"; public override string Name => "TraitorDeathMatchRedemption";
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<InventoryComponent?>(eventArgs.User, out var userInv)) if (!_entMan.TryGetComponent<InventoryComponent?>(eventArgs.User, out var userInv))
{ {
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-inventory-message")))); ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-inventory-message"))));
return false; return false;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<MindComponent?>(eventArgs.User, out var userMindComponent)) if (!_entMan.TryGetComponent<MindComponent?>(eventArgs.User, out var userMindComponent))
{ {
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-mind-message")))); ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-mind-message"))));
@@ -42,14 +44,14 @@ namespace Content.Server.TraitorDeathMatch.Components
return false; return false;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<UplinkComponent?>(eventArgs.Using, out var victimUplink)) if (!_entMan.TryGetComponent<UplinkComponent?>(eventArgs.Using, out var victimUplink))
{ {
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-message")))); ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-message"))));
return false; return false;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<TraitorDeathMatchReliableOwnerTagComponent?>(eventArgs.Using, out var victimPDAOwner)) if (!_entMan.TryGetComponent<TraitorDeathMatchReliableOwnerTagComponent?>(eventArgs.Using, out var victimPDAOwner))
{ {
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-owner-message")))); ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-owner-message"))));
@@ -66,7 +68,7 @@ namespace Content.Server.TraitorDeathMatch.Components
UplinkComponent? userUplink = null; UplinkComponent? userUplink = null;
if (userInv.GetSlotItem(EquipmentSlotDefines.Slots.IDCARD)?.Owner is {Valid: true} userPDAEntity) if (userInv.GetSlotItem(EquipmentSlotDefines.Slots.IDCARD)?.Owner is {Valid: true} userPDAEntity)
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<UplinkComponent?>(userPDAEntity, out var userUplinkComponent)) if (_entMan.TryGetComponent<UplinkComponent?>(userPDAEntity, out var userUplinkComponent))
userUplink = userUplinkComponent; userUplink = userUplinkComponent;
if (userUplink == null) if (userUplink == null)
@@ -104,12 +106,12 @@ namespace Content.Server.TraitorDeathMatch.Components
} }
// 4 is the per-PDA bonus amount. // 4 is the per-PDA bonus amount.
var accounts = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<UplinkAccountsSystem>(); var accounts = _entMan.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
var transferAmount = victimAccount.Balance + 4; var transferAmount = victimAccount.Balance + 4;
accounts.SetBalance(victimAccount, 0); accounts.SetBalance(victimAccount, 0);
accounts.AddToBalance(userAccount, transferAmount); accounts.AddToBalance(userAccount, transferAmount);
IoCManager.Resolve<IEntityManager>().DeleteEntity(victimUplink.Owner); _entMan.DeleteEntity(victimUplink.Owner);
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-success-message", ("tcAmount", transferAmount))); Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-success-message", ("tcAmount", transferAmount)));
return true; return true;

View File

@@ -29,6 +29,7 @@ namespace Content.Server.VendingMachines
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
public class VendingMachineComponent : SharedVendingMachineComponent, IActivate, IBreakAct, IWires public class VendingMachineComponent : SharedVendingMachineComponent, IActivate, IBreakAct, IWires
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -38,7 +39,7 @@ namespace Content.Server.VendingMachines
private string _packPrototypeId = string.Empty; private string _packPrototypeId = string.Empty;
private string _spriteName = ""; private string _spriteName = "";
private bool Powered => !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool Powered => !_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
private bool _broken; private bool _broken;
[DataField("soundVend")] [DataField("soundVend")]
@@ -54,14 +55,14 @@ namespace Content.Server.VendingMachines
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
if(!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) if(!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
{ {
return; return;
} }
if (!Powered) if (!Powered)
return; return;
var wires = IoCManager.Resolve<IEntityManager>().GetComponent<WiresComponent>(Owner); var wires = _entMan.GetComponent<WiresComponent>(Owner);
if (wires.IsPanelOpen) if (wires.IsPanelOpen)
{ {
wires.OpenInterface(actor.PlayerSession); wires.OpenInterface(actor.PlayerSession);
@@ -79,12 +80,12 @@ namespace Content.Server.VendingMachines
return; return;
} }
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName = packPrototype.Name; _entMan.GetComponent<MetaDataComponent>(Owner).EntityName = packPrototype.Name;
_animationDuration = TimeSpan.FromSeconds(packPrototype.AnimationDuration); _animationDuration = TimeSpan.FromSeconds(packPrototype.AnimationDuration);
_spriteName = packPrototype.SpriteName; _spriteName = packPrototype.SpriteName;
if (!string.IsNullOrEmpty(_spriteName)) if (!string.IsNullOrEmpty(_spriteName))
{ {
var spriteComponent = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(Owner); var spriteComponent = _entMan.GetComponent<SpriteComponent>(Owner);
const string vendingMachineRSIPath = "Structures/Machines/VendingMachines/{0}.rsi"; const string vendingMachineRSIPath = "Structures/Machines/VendingMachines/{0}.rsi";
spriteComponent.BaseRSIPath = string.Format(vendingMachineRSIPath, _spriteName); spriteComponent.BaseRSIPath = string.Format(vendingMachineRSIPath, _spriteName);
} }
@@ -106,7 +107,7 @@ namespace Content.Server.VendingMachines
UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver)) if (_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver))
{ {
TrySetVisualState(receiver.Powered ? VendingMachineVisualState.Normal : VendingMachineVisualState.Off); TrySetVisualState(receiver.Powered ? VendingMachineVisualState.Normal : VendingMachineVisualState.Off);
} }
@@ -182,7 +183,7 @@ namespace Content.Server.VendingMachines
{ {
_ejecting = false; _ejecting = false;
TrySetVisualState(VendingMachineVisualState.Normal); TrySetVisualState(VendingMachineVisualState.Normal);
IoCManager.Resolve<IEntityManager>().SpawnEntity(id, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); _entMan.SpawnEntity(id, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
}); });
SoundSystem.Play(Filter.Pvs(Owner), _soundVend.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); SoundSystem.Play(Filter.Pvs(Owner), _soundVend.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
@@ -190,7 +191,7 @@ namespace Content.Server.VendingMachines
private void TryEject(string id, EntityUid? sender) private void TryEject(string id, EntityUid? sender)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AccessReader?>(Owner, out var accessReader)) if (_entMan.TryGetComponent<AccessReader?>(Owner, out var accessReader))
{ {
var accessSystem = EntitySystem.Get<AccessReaderSystem>(); var accessSystem = EntitySystem.Get<AccessReaderSystem>();
if (sender == null || !accessSystem.IsAllowed(accessReader, sender.Value)) if (sender == null || !accessSystem.IsAllowed(accessReader, sender.Value))
@@ -232,7 +233,7 @@ namespace Content.Server.VendingMachines
finalState = VendingMachineVisualState.Off; finalState = VendingMachineVisualState.Off;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
appearance.SetData(VendingMachineVisuals.VisualState, finalState); appearance.SetData(VendingMachineVisuals.VisualState, finalState);
} }

View File

@@ -25,6 +25,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
public class AmmoComponent : Component, IExamine, ISerializationHooks public class AmmoComponent : Component, IExamine, ISerializationHooks
#pragma warning restore 618 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "Ammo"; public override string Name => "Ammo";
@@ -117,12 +118,12 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
} }
_spent = true; _spent = true;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearanceComponent)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
{ {
appearanceComponent.SetData(AmmoVisuals.Spent, true); appearanceComponent.SetData(AmmoVisuals.Spent, true);
} }
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_projectileId, spawnAt); var entity = _entMan.SpawnEntity(_projectileId, spawnAt);
return entity; return entity;
} }

View File

@@ -20,6 +20,8 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
[RegisterComponent] [RegisterComponent]
public class SpeedLoaderComponent : Component, IAfterInteract, IInteractUsing, IMapInit, IUse public class SpeedLoaderComponent : Component, IAfterInteract, IInteractUsing, IMapInit, IUse
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "SpeedLoader"; public override string Name => "SpeedLoader";
[DataField("caliber")] [DataField("caliber")]
@@ -59,7 +61,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
private void UpdateAppearance() private void UpdateAppearance()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearanceComponent)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
{ {
appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true); appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true);
appearanceComponent?.SetData(AmmoVisuals.AmmoCount, AmmoLeft); appearanceComponent?.SetData(AmmoVisuals.AmmoCount, AmmoLeft);
@@ -69,7 +71,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
public bool TryInsertAmmo(EntityUid user, EntityUid entity) public bool TryInsertAmmo(EntityUid user, EntityUid entity)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out AmmoComponent? ammoComponent)) if (!_entMan.TryGetComponent(entity, out AmmoComponent? ammoComponent))
{ {
return false; return false;
} }
@@ -95,7 +97,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
private bool UseEntity(EntityUid user) private bool UseEntity(EntityUid user)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent)) if (!_entMan.TryGetComponent(user, out HandsComponent? handsComponent))
{ {
return false; return false;
} }
@@ -106,7 +108,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
return false; return false;
} }
var itemComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(ammo); var itemComponent = _entMan.GetComponent<ItemComponent>(ammo);
if (!handsComponent.CanPutInHand(itemComponent)) if (!handsComponent.CanPutInHand(itemComponent))
{ {
ServerRangedBarrelComponent.EjectCasing(ammo); ServerRangedBarrelComponent.EjectCasing(ammo);
@@ -130,7 +132,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
if (_unspawnedCount > 0) if (_unspawnedCount > 0)
{ {
entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); entity = _entMan.SpawnEntity(_fillPrototype, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
_unspawnedCount--; _unspawnedCount--;
} }
@@ -147,7 +149,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
// This area is dirty but not sure of an easier way to do it besides add an interface or somethin // This area is dirty but not sure of an easier way to do it besides add an interface or somethin
var changed = false; var changed = false;
var entities = IoCManager.Resolve<IEntityManager>(); var entities = _entMan;
if (entities.TryGetComponent(eventArgs.Target.Value, out RevolverBarrelComponent? revolverBarrel)) if (entities.TryGetComponent(eventArgs.Target.Value, out RevolverBarrelComponent? revolverBarrel))
{ {
for (var i = 0; i < Capacity; i++) for (var i = 0; i < Capacity; i++)
@@ -169,7 +171,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
break; break;
} }
} }
else if (IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Target.Value, out BoltActionBarrelComponent? boltActionBarrel)) else if (_entMan.TryGetComponent(eventArgs.Target.Value, out BoltActionBarrelComponent? boltActionBarrel))
{ {
for (var i = 0; i < Capacity; i++) for (var i = 0; i < Capacity; i++)
{ {

View File

@@ -27,6 +27,8 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
[NetworkedComponent()] [NetworkedComponent()]
public sealed class PumpBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, IMapInit, ISerializationHooks public sealed class PumpBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, IMapInit, ISerializationHooks
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "PumpBarrel"; public override string Name => "PumpBarrel";
public override int ShotsLeft public override int ShotsLeft
@@ -85,7 +87,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
// (Is one chambered?, is the bullet spend) // (Is one chambered?, is the bullet spend)
var chamber = (chamberedExists, false); var chamber = (chamberedExists, false);
if (chamberedExists && IoCManager.Resolve<IEntityManager>().TryGetComponent<AmmoComponent?>(_chamberContainer.ContainedEntity!.Value, out var ammo)) if (chamberedExists && _entMan.TryGetComponent<AmmoComponent?>(_chamberContainer.ContainedEntity!.Value, out var ammo))
{ {
chamber.Item2 = ammo.Spent; chamber.Item2 = ammo.Spent;
} }
@@ -124,7 +126,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
_unspawnedCount--; _unspawnedCount--;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearanceComponent)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
{ {
_appearanceComponent = appearanceComponent; _appearanceComponent = appearanceComponent;
} }
@@ -159,7 +161,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_chamberContainer.ContainedEntity is not {Valid: true} chamberEntity) if (_chamberContainer.ContainedEntity is not {Valid: true} chamberEntity)
return null; return null;
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AmmoComponent>(chamberEntity)?.TakeBullet(spawnAt); return _entMan.GetComponentOrNull<AmmoComponent>(chamberEntity)?.TakeBullet(spawnAt);
} }
private void Cycle(bool manual = false) private void Cycle(bool manual = false)
@@ -167,7 +169,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_chamberContainer.ContainedEntity is {Valid: true} chamberedEntity) if (_chamberContainer.ContainedEntity is {Valid: true} chamberedEntity)
{ {
_chamberContainer.Remove(chamberedEntity); _chamberContainer.Remove(chamberedEntity);
var ammoComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(chamberedEntity); var ammoComponent = _entMan.GetComponent<AmmoComponent>(chamberedEntity);
if (!ammoComponent.Caseless) if (!ammoComponent.Caseless)
{ {
EjectCasing(chamberedEntity); EjectCasing(chamberedEntity);
@@ -183,7 +185,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_unspawnedCount > 0) if (_unspawnedCount > 0)
{ {
_unspawnedCount--; _unspawnedCount--;
var ammoEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); var ammoEntity = _entMan.SpawnEntity(_fillPrototype, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
_chamberContainer.Insert(ammoEntity); _chamberContainer.Insert(ammoEntity);
} }
@@ -198,7 +200,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
public bool TryInsertBullet(InteractUsingEventArgs eventArgs) public bool TryInsertBullet(InteractUsingEventArgs eventArgs)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Using, out AmmoComponent? ammoComponent)) if (!_entMan.TryGetComponent(eventArgs.Using, out AmmoComponent? ammoComponent))
{ {
return false; return false;
} }

View File

@@ -24,6 +24,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
[NetworkedComponent()] [NetworkedComponent()]
public sealed class RevolverBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, ISerializationHooks public sealed class RevolverBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, ISerializationHooks
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
public override string Name => "RevolverBarrel"; public override string Name => "RevolverBarrel";
@@ -81,7 +82,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
{ {
slotsSpent[i] = null; slotsSpent[i] = null;
var ammoEntity = _ammoSlots[i]; var ammoEntity = _ammoSlots[i];
if (ammoEntity != default && IoCManager.Resolve<IEntityManager>().TryGetComponent(ammoEntity, out AmmoComponent? ammo)) if (ammoEntity != default && _entMan.TryGetComponent(ammoEntity, out AmmoComponent? ammo))
{ {
slotsSpent[i] = ammo.Spent; slotsSpent[i] = ammo.Spent;
} }
@@ -113,7 +114,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
for (var i = 0; i < _unspawnedCount; i++) for (var i = 0; i < _unspawnedCount; i++)
{ {
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); var entity = _entMan.SpawnEntity(_fillPrototype, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
_ammoSlots[idx] = entity; _ammoSlots[idx] = entity;
_ammoContainer.Insert(entity); _ammoContainer.Insert(entity);
idx++; idx++;
@@ -125,7 +126,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
private void UpdateAppearance() private void UpdateAppearance()
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance)) if (!_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {
return; return;
} }
@@ -138,7 +139,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
public bool TryInsertBullet(EntityUid user, EntityUid entity) public bool TryInsertBullet(EntityUid user, EntityUid entity)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out AmmoComponent? ammoComponent)) if (!_entMan.TryGetComponent(entity, out AmmoComponent? ammoComponent))
{ {
return false; return false;
} }
@@ -208,7 +209,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
EntityUid? bullet = null; EntityUid? bullet = null;
if (ammo != default) if (ammo != default)
{ {
var ammoComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(ammo); var ammoComponent = _entMan.GetComponent<AmmoComponent>(ammo);
bullet = ammoComponent.TakeBullet(spawnAt); bullet = ammoComponent.TakeBullet(spawnAt);
if (ammoComponent.Caseless) if (ammoComponent.Caseless)
{ {

View File

@@ -30,6 +30,7 @@ namespace Content.Server.Weapon.Ranged
[RegisterComponent] [RegisterComponent]
public sealed class ServerRangedWeaponComponent : SharedRangedWeaponComponent, IHandSelected public sealed class ServerRangedWeaponComponent : SharedRangedWeaponComponent, IHandSelected
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
@@ -143,12 +144,12 @@ namespace Content.Server.Weapon.Ranged
/// <param name="targetPos">Target position on the map to shoot at.</param> /// <param name="targetPos">Target position on the map to shoot at.</param>
private void TryFire(EntityUid user, Vector2 targetPos) private void TryFire(EntityUid user, Vector2 targetPos)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands) || hands.GetActiveHand?.Owner != Owner) if (!_entMan.TryGetComponent(user, out HandsComponent? hands) || hands.GetActiveHand?.Owner != Owner)
{ {
return; return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out CombatModeComponent? combat) || !combat.IsInCombatMode) if (!_entMan.TryGetComponent(user, out CombatModeComponent? combat) || !combat.IsInCombatMode)
{ {
return; return;
} }
@@ -176,21 +177,21 @@ namespace Content.Server.Weapon.Ranged
// Apply salt to the wound ("Honk!") // Apply salt to the wound ("Honk!")
SoundSystem.Play( SoundSystem.Play(
Filter.Pvs(Owner), _clumsyWeaponHandlingSound.GetSound(), Filter.Pvs(Owner), _clumsyWeaponHandlingSound.GetSound(),
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, AudioParams.Default.WithMaxDistance(5)); _entMan.GetComponent<TransformComponent>(Owner).Coordinates, AudioParams.Default.WithMaxDistance(5));
SoundSystem.Play( SoundSystem.Play(
Filter.Pvs(Owner), _clumsyWeaponShotSound.GetSound(), Filter.Pvs(Owner), _clumsyWeaponShotSound.GetSound(),
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, AudioParams.Default.WithMaxDistance(5)); _entMan.GetComponent<TransformComponent>(Owner).Coordinates, AudioParams.Default.WithMaxDistance(5));
user.PopupMessage(Loc.GetString("server-ranged-weapon-component-try-fire-clumsy")); user.PopupMessage(Loc.GetString("server-ranged-weapon-component-try-fire-clumsy"));
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
return; return;
} }
if (_canHotspot) if (_canHotspot)
{ {
EntitySystem.Get<AtmosphereSystem>().HotspotExpose(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).Coordinates, 700, 50); EntitySystem.Get<AtmosphereSystem>().HotspotExpose(_entMan.GetComponent<TransformComponent>(user).Coordinates, 700, 50);
} }
FireHandler?.Invoke(user, targetPos); FireHandler?.Invoke(user, targetPos);
} }

View File

@@ -15,17 +15,19 @@ namespace Content.Server.Weapon
[ComponentReference(typeof(BaseCharger))] [ComponentReference(typeof(BaseCharger))]
public sealed class WeaponCapacitorChargerComponent : BaseCharger public sealed class WeaponCapacitorChargerComponent : BaseCharger
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "WeaponCapacitorCharger"; public override string Name => "WeaponCapacitorCharger";
public override bool IsEntityCompatible(EntityUid entity) public override bool IsEntityCompatible(EntityUid entity)
{ {
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ServerBatteryBarrelComponent? battery) && battery.PowerCell != null || return _entMan.TryGetComponent(entity, out ServerBatteryBarrelComponent? battery) && battery.PowerCell != null ||
IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out PowerCellSlotComponent? slot) && slot.HasCell; _entMan.TryGetComponent(entity, out PowerCellSlotComponent? slot) && slot.HasCell;
} }
protected override BatteryComponent? GetBatteryFrom(EntityUid entity) protected override BatteryComponent? GetBatteryFrom(EntityUid entity)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out PowerCellSlotComponent? slot)) if (_entMan.TryGetComponent(entity, out PowerCellSlotComponent? slot))
{ {
if (slot.Cell != null) if (slot.Cell != null)
{ {
@@ -33,7 +35,7 @@ namespace Content.Server.Weapon
} }
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ServerBatteryBarrelComponent? battery)) if (_entMan.TryGetComponent(entity, out ServerBatteryBarrelComponent? battery))
{ {
if (battery.PowerCell != null) if (battery.PowerCell != null)
{ {

View File

@@ -27,6 +27,7 @@ namespace Content.Server.Window
public class WindowComponent : SharedWindowComponent, IExamine, IInteractHand public class WindowComponent : SharedWindowComponent, IExamine, IInteractHand
#pragma warning restore 618 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[ViewVariables(VVAccess.ReadWrite)] private TimeSpan _lastKnockTime; [ViewVariables(VVAccess.ReadWrite)] private TimeSpan _lastKnockTime;
@@ -43,8 +44,8 @@ namespace Content.Server.Window
void IExamine.Examine(FormattedMessage message, bool inDetailsRange) void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out DamageableComponent? damageable) || if (!_entMan.TryGetComponent(Owner, out DamageableComponent? damageable) ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out DestructibleComponent? destructible)) !_entMan.TryGetComponent(Owner, out DestructibleComponent? destructible))
{ {
return; return;
} }
@@ -104,7 +105,7 @@ namespace Content.Server.Window
SoundSystem.Play( SoundSystem.Play(
Filter.Pvs(eventArgs.Target), _knockSound.GetSound(), Filter.Pvs(eventArgs.Target), _knockSound.GetSound(),
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(eventArgs.Target).Coordinates, AudioHelpers.WithVariation(0.05f)); _entMan.GetComponent<TransformComponent>(eventArgs.Target).Coordinates, AudioHelpers.WithVariation(0.05f));
eventArgs.Target.PopupMessageEveryone(Loc.GetString("comp-window-knock")); eventArgs.Target.PopupMessageEveryone(Loc.GetString("comp-window-knock"));
_lastKnockTime = _gameTiming.CurTime; _lastKnockTime = _gameTiming.CurTime;

View File

@@ -41,10 +41,11 @@ namespace Content.Shared.Actions.Behaviors.Item
Performer = performer; Performer = performer;
ActionType = actionType; ActionType = actionType;
Item = item; Item = item;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Item, out ItemActions)) var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetComponent(Item, out ItemActions))
{ {
throw new InvalidOperationException($"performer {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(performer).EntityName} tried to perform item action {actionType} " + throw new InvalidOperationException($"performer {entMan.GetComponent<MetaDataComponent>(performer).EntityName} tried to perform item action {actionType} " +
$" for item {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Item).EntityName} but the item had no ItemActionsComponent," + $" for item {entMan.GetComponent<MetaDataComponent>(Item).EntityName} but the item had no ItemActionsComponent," +
" which should never occur"); " which should never occur");
} }
} }

View File

@@ -18,6 +18,8 @@ namespace Content.Shared.Body.Components
[NetworkedComponent()] [NetworkedComponent()]
public abstract class SharedBodyPartComponent : Component, IBodyPartContainer public abstract class SharedBodyPartComponent : Component, IBodyPartContainer
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "BodyPart"; public override string Name => "BodyPart";
private SharedBodyComponent? _body; private SharedBodyComponent? _body;
@@ -109,11 +111,11 @@ namespace Content.Shared.Body.Components
public BodyPartSymmetry Symmetry { get; private set; } = BodyPartSymmetry.None; public BodyPartSymmetry Symmetry { get; private set; } = BodyPartSymmetry.None;
[ViewVariables] [ViewVariables]
public ISurgeryData? SurgeryDataComponent => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ISurgeryData>(Owner); public ISurgeryData? SurgeryDataComponent => _entMan.GetComponentOrNull<ISurgeryData>(Owner);
protected virtual void OnAddMechanism(SharedMechanismComponent mechanism) protected virtual void OnAddMechanism(SharedMechanismComponent mechanism)
{ {
var prototypeId = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mechanism.Owner).EntityPrototype!.ID; var prototypeId = _entMan.GetComponent<MetaDataComponent>(mechanism.Owner).EntityPrototype!.ID;
if (!_mechanismIds.Contains(prototypeId)) if (!_mechanismIds.Contains(prototypeId))
{ {
@@ -128,7 +130,7 @@ namespace Content.Shared.Body.Components
protected virtual void OnRemoveMechanism(SharedMechanismComponent mechanism) protected virtual void OnRemoveMechanism(SharedMechanismComponent mechanism)
{ {
_mechanismIds.Remove(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mechanism.Owner).EntityPrototype!.ID); _mechanismIds.Remove(_entMan.GetComponent<MetaDataComponent>(mechanism.Owner).EntityPrototype!.ID);
mechanism.Part = null; mechanism.Part = null;
SizeUsed -= mechanism.Size; SizeUsed -= mechanism.Size;
@@ -267,7 +269,7 @@ namespace Content.Shared.Body.Components
{ {
if (RemoveMechanism(mechanism)) if (RemoveMechanism(mechanism))
{ {
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mechanism.Owner).Coordinates = coordinates; _entMan.GetComponent<TransformComponent>(mechanism.Owner).Coordinates = coordinates;
return true; return true;
} }
@@ -292,34 +294,34 @@ namespace Content.Shared.Body.Components
return false; return false;
} }
IoCManager.Resolve<IEntityManager>().DeleteEntity(mechanism.Owner); _entMan.DeleteEntity(mechanism.Owner);
return true; return true;
} }
private void AddedToBody(SharedBodyComponent body) private void AddedToBody(SharedBodyComponent body)
{ {
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation = 0; _entMan.GetComponent<TransformComponent>(Owner).LocalRotation = 0;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).AttachParent(body.Owner); _entMan.GetComponent<TransformComponent>(Owner).AttachParent(body.Owner);
OnAddedToBody(body); OnAddedToBody(body);
foreach (var mechanism in _mechanisms) foreach (var mechanism in _mechanisms)
{ {
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.Owner, new AddedToBodyEvent(body)); _entMan.EventBus.RaiseLocalEvent(mechanism.Owner, new AddedToBodyEvent(body));
} }
} }
private void RemovedFromBody(SharedBodyComponent old) private void RemovedFromBody(SharedBodyComponent old)
{ {
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Deleted) if (!_entMan.GetComponent<TransformComponent>(Owner).Deleted)
{ {
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).AttachToGridOrMap(); _entMan.GetComponent<TransformComponent>(Owner).AttachToGridOrMap();
} }
OnRemovedFromBody(old); OnRemovedFromBody(old);
foreach (var mechanism in _mechanisms) foreach (var mechanism in _mechanisms)
{ {
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.Owner, new RemovedFromBodyEvent(old)); _entMan.EventBus.RaiseLocalEvent(mechanism.Owner, new RemovedFromBodyEvent(old));
} }
} }
@@ -358,7 +360,7 @@ namespace Content.Shared.Body.Components
return _mechanisms; return _mechanisms;
} }
entityManager ??= IoCManager.Resolve<IEntityManager>(); entityManager ??= _entMan;
var mechanisms = new List<SharedMechanismComponent>(MechanismIds.Length); var mechanisms = new List<SharedMechanismComponent>(MechanismIds.Length);

View File

@@ -10,6 +10,8 @@ namespace Content.Shared.Body.Components
{ {
public abstract class SharedMechanismComponent : Component, ISerializationHooks public abstract class SharedMechanismComponent : Component, ISerializationHooks
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "Mechanism"; public override string Name => "Mechanism";
protected readonly Dictionary<int, object> OptionsCache = new(); protected readonly Dictionary<int, object> OptionsCache = new();
@@ -37,11 +39,11 @@ namespace Content.Shared.Body.Components
{ {
if (old.Body == null) if (old.Body == null)
{ {
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new RemovedFromPartEvent(old)); _entMan.EventBus.RaiseLocalEvent(Owner, new RemovedFromPartEvent(old));
} }
else else
{ {
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new RemovedFromPartInBodyEvent(old.Body, old)); _entMan.EventBus.RaiseLocalEvent(Owner, new RemovedFromPartInBodyEvent(old.Body, old));
} }
} }
@@ -49,11 +51,11 @@ namespace Content.Shared.Body.Components
{ {
if (value.Body == null) if (value.Body == null)
{ {
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new AddedToPartEvent(value)); _entMan.EventBus.RaiseLocalEvent(Owner, new AddedToPartEvent(value));
} }
else else
{ {
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new AddedToPartInBodyEvent(value.Body, value)); _entMan.EventBus.RaiseLocalEvent(Owner, new AddedToPartInBodyEvent(value.Body, value));
} }
} }
} }

View File

@@ -23,6 +23,8 @@ namespace Content.Shared.Hands.Components
[NetworkedComponent] [NetworkedComponent]
public abstract class SharedHandsComponent : Component public abstract class SharedHandsComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public sealed override string Name => "Hands"; public sealed override string Name => "Hands";
public event Action? OnItemChanged; //TODO: Try to replace C# event public event Action? OnItemChanged; //TODO: Try to replace C# event
@@ -96,12 +98,12 @@ namespace Content.Shared.Hands.Components
UpdateHandVisualizer(); UpdateHandVisualizer();
Dirty(); Dirty();
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this }); _entMan.EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this });
} }
public void UpdateHandVisualizer() public void UpdateHandVisualizer()
{ {
var entMan = IoCManager.Resolve<IEntityManager>(); var entMan = _entMan;
if (!entMan.TryGetComponent(Owner, out AppearanceComponent? appearance)) if (!entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
return; return;
@@ -377,7 +379,7 @@ namespace Content.Shared.Hands.Components
if (!TryGetHand(handName, out var hand)) if (!TryGetHand(handName, out var hand))
return false; return false;
return TryDropHeldEntity(hand, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, checkActionBlocker); return TryDropHeldEntity(hand, _entMan.GetComponent<TransformComponent>(Owner).Coordinates, checkActionBlocker);
} }
/// <summary> /// <summary>
@@ -388,7 +390,7 @@ namespace Content.Shared.Hands.Components
if (!TryGetHandHoldingEntity(entity, out var hand)) if (!TryGetHandHoldingEntity(entity, out var hand))
return false; return false;
return TryDropHeldEntity(hand, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, checkActionBlocker); return TryDropHeldEntity(hand, _entMan.GetComponent<TransformComponent>(Owner).Coordinates, checkActionBlocker);
} }
/// <summary> /// <summary>
@@ -481,7 +483,7 @@ namespace Content.Shared.Hands.Components
EntitySystem.Get<SharedInteractionSystem>().DroppedInteraction(Owner, heldEntity); EntitySystem.Get<SharedInteractionSystem>().DroppedInteraction(Owner, heldEntity);
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(heldEntity).WorldPosition = GetFinalDropCoordinates(targetDropLocation); _entMan.GetComponent<TransformComponent>(heldEntity).WorldPosition = GetFinalDropCoordinates(targetDropLocation);
OnItemChanged?.Invoke(); OnItemChanged?.Invoke();
} }
@@ -491,8 +493,8 @@ namespace Content.Shared.Hands.Components
/// </summary> /// </summary>
private Vector2 GetFinalDropCoordinates(EntityCoordinates targetCoords) private Vector2 GetFinalDropCoordinates(EntityCoordinates targetCoords)
{ {
var origin = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapPosition; var origin = _entMan.GetComponent<TransformComponent>(Owner).MapPosition;
var target = targetCoords.ToMap(IoCManager.Resolve<IEntityManager>()); var target = targetCoords.ToMap(_entMan);
var dropVector = target.Position - origin.Position; var dropVector = target.Position - origin.Position;
var requestedDropDistance = dropVector.Length; var requestedDropDistance = dropVector.Length;
@@ -530,7 +532,7 @@ namespace Content.Shared.Hands.Components
/// </summary> /// </summary>
private void DropHeldEntityToFloor(Hand hand) private void DropHeldEntityToFloor(Hand hand)
{ {
DropHeldEntity(hand, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates); DropHeldEntity(hand, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
} }
private bool CanPutHeldEntityIntoContainer(Hand hand, IContainer targetContainer, bool checkActionBlocker) private bool CanPutHeldEntityIntoContainer(Hand hand, IContainer targetContainer, bool checkActionBlocker)
@@ -654,7 +656,7 @@ namespace Content.Shared.Hands.Components
if (hand.Name == ActiveHand) if (hand.Name == ActiveHand)
SelectActiveHeldEntity(); SelectActiveHeldEntity();
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).LocalPosition = Vector2.Zero; _entMan.GetComponent<TransformComponent>(entity).LocalPosition = Vector2.Zero;
OnItemChanged?.Invoke(); OnItemChanged?.Invoke();
@@ -772,7 +774,7 @@ namespace Content.Shared.Hands.Components
private void HandCountChanged() private void HandCountChanged()
{ {
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new HandCountChangedEvent(Owner)); _entMan.EventBus.RaiseEvent(EventSource.Local, new HandCountChangedEvent(Owner));
} }
/// <summary> /// <summary>
@@ -791,7 +793,7 @@ namespace Content.Shared.Hands.Components
var entity = item.Owner; var entity = item.Owner;
if (!TryPutInActiveHandOrAny(entity, checkActionBlocker)) if (!TryPutInActiveHandOrAny(entity, checkActionBlocker))
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates; _entMan.GetComponent<TransformComponent>(entity).Coordinates = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
} }
/// <summary> /// <summary>

View File

@@ -203,8 +203,9 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
{ {
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>()); var entMan = IoCManager.Resolve<IEntityManager>();
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other).MapPosition; var originPosition = origin.ToMap(entMan);
var otherPosition = entMan.GetComponent<TransformComponent>(other).MapPosition;
return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range, return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range,
predicate, ignoreInsideBlocker); predicate, ignoreInsideBlocker);
@@ -217,8 +218,9 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
{ {
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>()); var entMan = IoCManager.Resolve<IEntityManager>();
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other.Owner).MapPosition; var originPosition = origin.ToMap(entMan);
var otherPosition = entMan.GetComponent<TransformComponent>(other.Owner).MapPosition;
return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range, return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range,
predicate, ignoreInsideBlocker); predicate, ignoreInsideBlocker);
@@ -231,8 +233,9 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
{ {
var originPosition = origin.ToMap(IoCManager.Resolve<IEntityManager>()); var entMan = IoCManager.Resolve<IEntityManager>();
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other.Owner).MapPosition; var originPosition = origin.ToMap(entMan);
var otherPosition = entMan.GetComponent<TransformComponent>(other.Owner).MapPosition;
return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range, return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range,
predicate, ignoreInsideBlocker); predicate, ignoreInsideBlocker);
@@ -246,7 +249,7 @@ namespace Content.Shared.Interaction.Helpers
bool ignoreInsideBlocker = true, bool ignoreInsideBlocker = true,
IEntityManager? entityManager = null) IEntityManager? entityManager = null)
{ {
entityManager ??= IoCManager.Resolve<IEntityManager>(); IoCManager.Resolve(ref entityManager);
var originPosition = origin.ToMap(entityManager); var originPosition = origin.ToMap(entityManager);
var otherPosition = other.ToMap(entityManager); var otherPosition = other.ToMap(entityManager);
@@ -263,7 +266,7 @@ namespace Content.Shared.Interaction.Helpers
bool ignoreInsideBlocker = true, bool ignoreInsideBlocker = true,
IEntityManager? entityManager = null) IEntityManager? entityManager = null)
{ {
entityManager ??= IoCManager.Resolve<IEntityManager>(); IoCManager.Resolve(ref entityManager);
var originPosition = origin.ToMap(entityManager); var originPosition = origin.ToMap(entityManager);
@@ -280,7 +283,8 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
{ {
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other).MapPosition; var entMan = IoCManager.Resolve<IEntityManager>();
var otherPosition = entMan.GetComponent<TransformComponent>(other).MapPosition;
return ExamineSystemShared.InRangeUnOccluded(origin, otherPosition, range, predicate, return ExamineSystemShared.InRangeUnOccluded(origin, otherPosition, range, predicate,
ignoreInsideBlocker); ignoreInsideBlocker);
@@ -293,7 +297,8 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
{ {
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other.Owner).MapPosition; var entMan = IoCManager.Resolve<IEntityManager>();
var otherPosition = entMan.GetComponent<TransformComponent>(other.Owner).MapPosition;
return ExamineSystemShared.InRangeUnOccluded(origin, otherPosition, range, predicate, return ExamineSystemShared.InRangeUnOccluded(origin, otherPosition, range, predicate,
ignoreInsideBlocker); ignoreInsideBlocker);
@@ -306,7 +311,8 @@ namespace Content.Shared.Interaction.Helpers
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
{ {
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other.Owner).MapPosition; var entMan = IoCManager.Resolve<IEntityManager>();
var otherPosition = entMan.GetComponent<TransformComponent>(other.Owner).MapPosition;
return ExamineSystemShared.InRangeUnOccluded(origin, otherPosition, range, predicate, return ExamineSystemShared.InRangeUnOccluded(origin, otherPosition, range, predicate,
ignoreInsideBlocker); ignoreInsideBlocker);
@@ -320,7 +326,7 @@ namespace Content.Shared.Interaction.Helpers
bool ignoreInsideBlocker = true, bool ignoreInsideBlocker = true,
IEntityManager? entityManager = null) IEntityManager? entityManager = null)
{ {
entityManager ??= IoCManager.Resolve<IEntityManager>(); IoCManager.Resolve(ref entityManager);
var otherPosition = other.ToMap(entityManager); var otherPosition = other.ToMap(entityManager);

View File

@@ -22,6 +22,8 @@ namespace Content.Shared.Item
[NetworkedComponent()] [NetworkedComponent()]
public abstract class SharedItemComponent : Component, IEquipped, IUnequipped, IInteractHand public abstract class SharedItemComponent : Component, IEquipped, IUnequipped, IInteractHand
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "Item"; public override string Name => "Item";
/// <summary> /// <summary>
@@ -115,10 +117,10 @@ namespace Content.Shared.Item
if (!EntitySystem.Get<ActionBlockerSystem>().CanPickup(user)) if (!EntitySystem.Get<ActionBlockerSystem>().CanPickup(user))
return false; return false;
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).MapID != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapID) if (_entMan.GetComponent<TransformComponent>(user).MapID != _entMan.GetComponent<TransformComponent>(Owner).MapID)
return false; return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out IPhysBody? physics) || physics.BodyType == BodyType.Static) if (!_entMan.TryGetComponent(Owner, out IPhysBody? physics) || physics.BodyType == BodyType.Static)
return false; return false;
return user.InRangeUnobstructed(Owner, ignoreInsideBlocker: true, popup: popup); return user.InRangeUnobstructed(Owner, ignoreInsideBlocker: true, popup: popup);
@@ -141,7 +143,7 @@ namespace Content.Shared.Item
if (!CanPickup(user)) if (!CanPickup(user))
return false; return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out SharedHandsComponent? hands)) if (!_entMan.TryGetComponent(user, out SharedHandsComponent? hands))
return false; return false;
var activeHand = hands.ActiveHand; var activeHand = hands.ActiveHand;

View File

@@ -12,14 +12,15 @@ namespace Content.Shared.Lathe
[NetworkedComponent()] [NetworkedComponent()]
public class SharedLatheComponent : Component public class SharedLatheComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!; [Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
public override string Name => "Lathe"; public override string Name => "Lathe";
public bool CanProduce(LatheRecipePrototype recipe, int quantity = 1) public bool CanProduce(LatheRecipePrototype recipe, int quantity = 1)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SharedMaterialStorageComponent? storage) if (!_entMan.TryGetComponent(Owner, out SharedMaterialStorageComponent? storage)
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SharedLatheDatabaseComponent? database)) return false; || !_entMan.TryGetComponent(Owner, out SharedLatheDatabaseComponent? database)) return false;
if (!database.Contains(recipe)) return false; if (!database.Contains(recipe)) return false;

View File

@@ -26,6 +26,8 @@ namespace Content.Shared.MobState.Components
[NetworkedComponent] [NetworkedComponent]
public class MobStateComponent : Component public class MobStateComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "MobState"; public override string Name => "MobState";
/// <summary> /// <summary>
@@ -60,13 +62,13 @@ namespace Content.Shared.MobState.Components
else else
{ {
// Initialize with some amount of damage, defaulting to 0. // Initialize with some amount of damage, defaulting to 0.
UpdateState(IoCManager.Resolve<IEntityManager>().GetComponentOrNull<DamageableComponent>(Owner)?.TotalDamage ?? FixedPoint2.Zero); UpdateState(_entMan.GetComponentOrNull<DamageableComponent>(Owner)?.TotalDamage ?? FixedPoint2.Zero);
} }
} }
protected override void OnRemove() protected override void OnRemove()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SharedAlertsComponent? status)) if (_entMan.TryGetComponent(Owner, out SharedAlertsComponent? status))
{ {
status.ClearAlert(AlertType.HumanHealth); status.ClearAlert(AlertType.HumanHealth);
} }
@@ -289,7 +291,7 @@ namespace Content.Shared.MobState.Components
/// </summary> /// </summary>
private void SetMobState(IMobState? old, (IMobState state, FixedPoint2 threshold)? current) private void SetMobState(IMobState? old, (IMobState state, FixedPoint2 threshold)? current)
{ {
var entMan = IoCManager.Resolve<IEntityManager>(); var entMan = _entMan;
if (!current.HasValue) if (!current.HasValue)
{ {

View File

@@ -67,7 +67,7 @@ namespace Content.Shared.Movement
{ {
var (walkDir, sprintDir) = mover.VelocityDir; var (walkDir, sprintDir) = mover.VelocityDir;
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mover.Owner); var transform = EntityManager.GetComponent<TransformComponent>(mover.Owner);
var parentRotation = transform.Parent!.WorldRotation; var parentRotation = transform.Parent!.WorldRotation;
// Regular movement. // Regular movement.
@@ -105,7 +105,7 @@ namespace Content.Shared.Movement
} }
UsedMobMovement[mover.Owner] = true; UsedMobMovement[mover.Owner] = true;
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mover.Owner); var transform = EntityManager.GetComponent<TransformComponent>(mover.Owner);
var weightless = mover.Owner.IsWeightless(physicsComponent, mapManager: _mapManager, entityManager: _entityManager); var weightless = mover.Owner.IsWeightless(physicsComponent, mapManager: _mapManager, entityManager: _entityManager);
var (walkDir, sprintDir) = mover.VelocityDir; var (walkDir, sprintDir) = mover.VelocityDir;
@@ -164,9 +164,9 @@ namespace Content.Shared.Movement
protected bool UseMobMovement(PhysicsComponent body) protected bool UseMobMovement(PhysicsComponent body)
{ {
return body.BodyStatus == BodyStatus.OnGround && return body.BodyStatus == BodyStatus.OnGround &&
IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(body.Owner) && EntityManager.HasComponent<MobStateComponent>(body.Owner) &&
// If we're being pulled then don't mess with our velocity. // If we're being pulled then don't mess with our velocity.
(!IoCManager.Resolve<IEntityManager>().TryGetComponent(body.Owner, out SharedPullableComponent? pullable) || !pullable.BeingPulled) && (!EntityManager.TryGetComponent(body.Owner, out SharedPullableComponent? pullable) || !pullable.BeingPulled) &&
_blocker.CanMove((body).Owner); _blocker.CanMove((body).Owner);
} }
@@ -186,7 +186,7 @@ namespace Content.Shared.Movement
!otherCollider.CanCollide || !otherCollider.CanCollide ||
((collider.CollisionMask & otherCollider.CollisionLayer) == 0 && ((collider.CollisionMask & otherCollider.CollisionLayer) == 0 &&
(otherCollider.CollisionMask & collider.CollisionLayer) == 0) || (otherCollider.CollisionMask & collider.CollisionLayer) == 0) ||
(IoCManager.Resolve<IEntityManager>().TryGetComponent(otherCollider.Owner, out SharedPullableComponent? pullable) && pullable.BeingPulled)) (EntityManager.TryGetComponent(otherCollider.Owner, out SharedPullableComponent? pullable) && pullable.BeingPulled))
{ {
continue; continue;
} }

View File

@@ -16,6 +16,8 @@ namespace Content.Shared.Storage
[NetworkedComponent()] [NetworkedComponent()]
public abstract class SharedStorageComponent : Component, IDraggable public abstract class SharedStorageComponent : Component, IDraggable
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "Storage"; public override string Name => "Storage";
public abstract IReadOnlyList<EntityUid>? StoredEntities { get; } public abstract IReadOnlyList<EntityUid>? StoredEntities { get; }
@@ -29,7 +31,7 @@ namespace Content.Shared.Storage
bool IDraggable.CanDrop(CanDropEvent args) bool IDraggable.CanDrop(CanDropEvent args)
{ {
return IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Target, out PlaceableSurfaceComponent? placeable) && return _entMan.TryGetComponent(args.Target, out PlaceableSurfaceComponent? placeable) &&
placeable.IsPlaceable; placeable.IsPlaceable;
} }
@@ -52,7 +54,7 @@ namespace Content.Shared.Storage
{ {
if (Remove(storedEntity)) if (Remove(storedEntity))
{ {
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(storedEntity).WorldPosition = eventArgs.DropLocation.Position; _entMan.GetComponent<TransformComponent>(storedEntity).WorldPosition = eventArgs.DropLocation.Position;
} }
} }