Inline GetComponentOrNull
This commit is contained in:
@@ -192,7 +192,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
if (chamberEntity == null)
|
||||
return null;
|
||||
|
||||
return chamberEntity.GetComponentOrNull<AmmoComponent>()?.TakeBullet(spawnAt);
|
||||
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AmmoComponent>(chamberEntity.Uid)?.TakeBullet(spawnAt);
|
||||
}
|
||||
|
||||
protected override bool WeaponCanFire()
|
||||
|
||||
@@ -149,6 +149,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
public override IEntity? TakeProjectile(EntityCoordinates spawnAt)
|
||||
{
|
||||
var chamberEntity = _chamberContainer.ContainedEntity;
|
||||
|
||||
if (!_manualCycle)
|
||||
{
|
||||
Cycle();
|
||||
@@ -158,7 +159,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
Dirty();
|
||||
}
|
||||
|
||||
return chamberEntity?.GetComponentOrNull<AmmoComponent>()?.TakeBullet(spawnAt);
|
||||
if (chamberEntity == null)
|
||||
return null;
|
||||
|
||||
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AmmoComponent>(chamberEntity.Uid)?.TakeBullet(spawnAt);
|
||||
}
|
||||
|
||||
private void Cycle(bool manual = false)
|
||||
|
||||
@@ -36,7 +36,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
[ViewVariables] private string? _ammoPrototype;
|
||||
|
||||
[ViewVariables] public IEntity? PowerCellEntity => _powerCellContainer.ContainedEntity;
|
||||
public BatteryComponent? PowerCell => _powerCellContainer.ContainedEntity?.GetComponentOrNull<BatteryComponent>();
|
||||
public BatteryComponent? PowerCell
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_powerCellContainer.ContainedEntity == null)
|
||||
return null;
|
||||
|
||||
return _powerCellContainer.ContainedEntity.GetComponentOrNull<BatteryComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
private ContainerSlot _powerCellContainer = default!;
|
||||
private ContainerSlot _ammoContainer = default!;
|
||||
[DataField("powerCellPrototype")]
|
||||
|
||||
Reference in New Issue
Block a user