Even more resolve removals.
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
public class AmmoComponent : Component, IExamine, ISerializationHooks
|
||||
#pragma warning restore 618
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override string Name => "Ammo";
|
||||
@@ -117,12 +118,12 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
}
|
||||
|
||||
_spent = true;
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
||||
{
|
||||
appearanceComponent.SetData(AmmoVisuals.Spent, true);
|
||||
}
|
||||
|
||||
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(_projectileId, spawnAt);
|
||||
var entity = _entMan.SpawnEntity(_projectileId, spawnAt);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
[RegisterComponent]
|
||||
public class SpeedLoaderComponent : Component, IAfterInteract, IInteractUsing, IMapInit, IUse
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "SpeedLoader";
|
||||
|
||||
[DataField("caliber")]
|
||||
@@ -59,7 +61,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
|
||||
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(AmmoVisuals.AmmoCount, AmmoLeft);
|
||||
@@ -69,7 +71,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -95,7 +97,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
|
||||
private bool UseEntity(EntityUid user)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent))
|
||||
if (!_entMan.TryGetComponent(user, out HandsComponent? handsComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -106,7 +108,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
var itemComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(ammo);
|
||||
var itemComponent = _entMan.GetComponent<ItemComponent>(ammo);
|
||||
if (!handsComponent.CanPutInHand(itemComponent))
|
||||
{
|
||||
ServerRangedBarrelComponent.EjectCasing(ammo);
|
||||
@@ -130,7 +132,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
|
||||
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--;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
var changed = false;
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
var entities = _entMan;
|
||||
if (entities.TryGetComponent(eventArgs.Target.Value, out RevolverBarrelComponent? revolverBarrel))
|
||||
{
|
||||
for (var i = 0; i < Capacity; i++)
|
||||
@@ -169,7 +171,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
||||
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++)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
[NetworkedComponent()]
|
||||
public sealed class PumpBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, IMapInit, ISerializationHooks
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "PumpBarrel";
|
||||
|
||||
public override int ShotsLeft
|
||||
@@ -85,7 +87,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
// (Is one chambered?, is the bullet spend)
|
||||
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;
|
||||
}
|
||||
@@ -124,7 +126,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
_unspawnedCount--;
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
||||
{
|
||||
_appearanceComponent = appearanceComponent;
|
||||
}
|
||||
@@ -159,7 +161,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
if (_chamberContainer.ContainedEntity is not {Valid: true} chamberEntity)
|
||||
return null;
|
||||
|
||||
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AmmoComponent>(chamberEntity)?.TakeBullet(spawnAt);
|
||||
return _entMan.GetComponentOrNull<AmmoComponent>(chamberEntity)?.TakeBullet(spawnAt);
|
||||
}
|
||||
|
||||
private void Cycle(bool manual = false)
|
||||
@@ -167,7 +169,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
if (_chamberContainer.ContainedEntity is {Valid: true} chamberedEntity)
|
||||
{
|
||||
_chamberContainer.Remove(chamberedEntity);
|
||||
var ammoComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(chamberedEntity);
|
||||
var ammoComponent = _entMan.GetComponent<AmmoComponent>(chamberedEntity);
|
||||
if (!ammoComponent.Caseless)
|
||||
{
|
||||
EjectCasing(chamberedEntity);
|
||||
@@ -183,7 +185,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
if (_unspawnedCount > 0)
|
||||
{
|
||||
_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);
|
||||
}
|
||||
|
||||
@@ -198,7 +200,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
[NetworkedComponent()]
|
||||
public sealed class RevolverBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, ISerializationHooks
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
public override string Name => "RevolverBarrel";
|
||||
@@ -81,7 +82,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
{
|
||||
slotsSpent[i] = null;
|
||||
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;
|
||||
}
|
||||
@@ -113,7 +114,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
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;
|
||||
_ammoContainer.Insert(entity);
|
||||
idx++;
|
||||
@@ -125,7 +126,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
if (!_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +139,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -208,7 +209,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
EntityUid? bullet = null;
|
||||
if (ammo != default)
|
||||
{
|
||||
var ammoComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(ammo);
|
||||
var ammoComponent = _entMan.GetComponent<AmmoComponent>(ammo);
|
||||
bullet = ammoComponent.TakeBullet(spawnAt);
|
||||
if (ammoComponent.Caseless)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace Content.Server.Weapon.Ranged
|
||||
[RegisterComponent]
|
||||
public sealed class ServerRangedWeaponComponent : SharedRangedWeaponComponent, IHandSelected
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = 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>
|
||||
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;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out CombatModeComponent? combat) || !combat.IsInCombatMode)
|
||||
if (!_entMan.TryGetComponent(user, out CombatModeComponent? combat) || !combat.IsInCombatMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -176,21 +177,21 @@ namespace Content.Server.Weapon.Ranged
|
||||
// Apply salt to the wound ("Honk!")
|
||||
SoundSystem.Play(
|
||||
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(
|
||||
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"));
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner);
|
||||
_entMan.DeleteEntity(Owner);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -15,17 +15,19 @@ namespace Content.Server.Weapon
|
||||
[ComponentReference(typeof(BaseCharger))]
|
||||
public sealed class WeaponCapacitorChargerComponent : BaseCharger
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "WeaponCapacitorCharger";
|
||||
|
||||
public override bool IsEntityCompatible(EntityUid entity)
|
||||
{
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ServerBatteryBarrelComponent? battery) && battery.PowerCell != null ||
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out PowerCellSlotComponent? slot) && slot.HasCell;
|
||||
return _entMan.TryGetComponent(entity, out ServerBatteryBarrelComponent? battery) && battery.PowerCell != null ||
|
||||
_entMan.TryGetComponent(entity, out PowerCellSlotComponent? slot) && slot.HasCell;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user