Add IItemStatus to some weapon types (#1879)

* Bolt Action

* Shotguns

* Revolver + Outline

* In Magazines: show bullets as numbers plus the usual bullet stuff

* Empty bullets have another texture
This commit is contained in:
Exp
2020-08-24 13:13:26 +02:00
committed by GitHub
parent 969eeb5528
commit 56ebde7f45
14 changed files with 810 additions and 69 deletions

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces;
@@ -27,6 +28,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
public sealed class PumpBarrelComponent : ServerRangedBarrelComponent, IMapInit, IExamine
{
public override string Name => "PumpBarrel";
public override uint? NetID => ContentNetIDs.PUMP_BARREL;
public override int ShotsLeft
{
@@ -81,6 +83,23 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
UpdateAppearance();
}
public override ComponentState GetComponentState()
{
(int, int)? count = (ShotsLeft, Capacity);
var chamberedExists = _chamberContainer.ContainedEntity != null;
// (Is one chambered?, is the bullet spend)
var chamber = (chamberedExists, false);
if (chamberedExists && _chamberContainer.ContainedEntity.TryGetComponent<AmmoComponent>(out var ammo))
{
chamber.Item2 = ammo.Spent;
}
return new PumpBarrelComponentState(
chamber,
FireRateSelector,
count,
SoundGunshot);
}
public override void Initialize()
{
base.Initialize();
@@ -110,6 +129,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
}
_appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true);
Dirty();
UpdateAppearance();
}
@@ -131,6 +151,11 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
{
Cycle();
}
else
{
Dirty();
}
return chamberEntity?.GetComponent<AmmoComponent>().TakeBullet(spawnAtGrid, spawnAtMap);
}
@@ -168,7 +193,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
}
}
// Dirty();
Dirty();
UpdateAppearance();
}
@@ -189,7 +214,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
{
_ammoContainer.Insert(eventArgs.Using);
_spawnedAmmo.Push(eventArgs.Using);
// Dirty();
Dirty();
UpdateAppearance();
if (_soundInsert != null)
{