Add default ammo for guns (#1207)
* Add default ammo types * Add revolver and bolt action default pro support Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -110,7 +110,13 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
{
|
||||
if (_fillPrototype != null)
|
||||
{
|
||||
_unspawnedCount += Capacity - 1;
|
||||
_unspawnedCount += Capacity;
|
||||
if (_unspawnedCount > 0)
|
||||
{
|
||||
_unspawnedCount--;
|
||||
var chamberEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition);
|
||||
_chamberContainer.Insert(chamberEntity);
|
||||
}
|
||||
}
|
||||
UpdateAppearance();
|
||||
}
|
||||
@@ -139,6 +145,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
}
|
||||
|
||||
_appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true);
|
||||
Dirty();
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
public override int ShotsLeft => _ammoContainer.ContainedEntities.Count;
|
||||
|
||||
private AppearanceComponent _appearanceComponent;
|
||||
private string _fillPrototype;
|
||||
private int _unspawnedCount;
|
||||
|
||||
// Sounds
|
||||
private string _soundEject;
|
||||
@@ -50,7 +52,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
}
|
||||
|
||||
// TODO: Writing?
|
||||
|
||||
serializer.DataField(ref _fillPrototype, "fillPrototype", null);
|
||||
|
||||
// Sounds
|
||||
serializer.DataField(ref _soundEject, "soundEject", "/Audio/Guns/MagOut/revolver_magout.ogg");
|
||||
@@ -61,7 +63,26 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_ammoContainer = ContainerManagerComponent.Ensure<Container>($"{Name}-ammoContainer", Owner);
|
||||
_unspawnedCount = Capacity;
|
||||
int idx = 0;
|
||||
_ammoContainer = ContainerManagerComponent.Ensure<Container>($"{Name}-ammoContainer", Owner, out var existing);
|
||||
if (existing)
|
||||
{
|
||||
foreach (var entity in _ammoContainer.ContainedEntities)
|
||||
{
|
||||
_unspawnedCount--;
|
||||
_ammoSlots[idx] = entity;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < _unspawnedCount; i++)
|
||||
{
|
||||
var entity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition);
|
||||
_ammoSlots[idx] = entity;
|
||||
_ammoContainer.Insert(entity);
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out AppearanceComponent appearanceComponent))
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@ using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -72,6 +71,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
}
|
||||
}
|
||||
|
||||
private string _magFillPrototype;
|
||||
|
||||
public bool BoltOpen { get; private set; } = true;
|
||||
private bool _autoEjectMag;
|
||||
// If the bolt needs to be open before we can insert / remove the mag (i.e. for LMGs)
|
||||
@@ -100,6 +101,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
}
|
||||
}
|
||||
serializer.DataField(ref _caliber, "caliber", BallisticCaliber.Unspecified);
|
||||
serializer.DataField(ref _magFillPrototype, "magFillPrototype", null);
|
||||
serializer.DataField(ref _autoEjectMag, "autoEjectMag", false);
|
||||
serializer.DataField(ref _magNeedsOpenBolt, "magNeedsOpenBolt", false);
|
||||
serializer.DataField(ref _soundBoltOpen, "soundBoltOpen", null);
|
||||
@@ -136,7 +138,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
}
|
||||
|
||||
_chamberContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-chamber", Owner);
|
||||
_magazineContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-magazine", Owner);
|
||||
_magazineContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-magazine", Owner, out var existing);
|
||||
|
||||
if (!existing && _magFillPrototype != null)
|
||||
{
|
||||
var magEntity = Owner.EntityManager.SpawnEntity(_magFillPrototype, Owner.Transform.GridPosition);
|
||||
_magazineContainer.Insert(magEntity);
|
||||
}
|
||||
|
||||
Dirty();
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
public void ToggleBolt()
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
sprite: Objects/Guns/LMGs/l6.rsi
|
||||
- type: RangedWeapon
|
||||
- type: MagazineBarrel
|
||||
magFillPrototype: MagazineLRifleBox
|
||||
fireRate: 5
|
||||
minAngle: 0
|
||||
maxAngle: 45
|
||||
@@ -91,6 +92,7 @@
|
||||
sprite: Objects/Guns/LMGs/pk.rsi
|
||||
- type: RangedWeapon
|
||||
- type: MagazineBarrel
|
||||
magFillPrototype: MagazineLRiflePkBox
|
||||
fireRate: 5
|
||||
minAngle: 0
|
||||
maxAngle: 45
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: GrenadeFrag
|
||||
fireRate: 1
|
||||
capacity: 3
|
||||
soundEmpty: /Audio/Guns/Empty/empty.ogg
|
||||
@@ -70,6 +71,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: RocketAmmo
|
||||
fireRate: 0.5
|
||||
capacity: 1
|
||||
soundEmpty: /Audio/Guns/Empty/empty.ogg
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
maxAngle: 60
|
||||
angleIncrease: 10
|
||||
angleDecay: 60
|
||||
magFillPrototype: MagazinePistol
|
||||
soundGunshot: /Audio/Guns/Gunshots/pistol.ogg
|
||||
soundEmpty: /Audio/Guns/Empty/empty.ogg
|
||||
soundRack: /Audio/Guns/Cock/pistol_cock.ogg
|
||||
@@ -193,6 +194,7 @@
|
||||
caliber: Magnum
|
||||
magazineTypes:
|
||||
- Pistol
|
||||
magFillPrototype: MagazineMagnum
|
||||
autoEjectMag: true
|
||||
fireRate: 5
|
||||
minAngle: 0
|
||||
@@ -236,6 +238,7 @@
|
||||
caliber: ClRifle
|
||||
magazineTypes:
|
||||
- Pistol
|
||||
magFillPrototype: MagazineClRiflePistol
|
||||
autoEjectMag: true
|
||||
canMuzzleFlash: false # Dat in-built suppressor
|
||||
minAngle: 0
|
||||
@@ -330,6 +333,7 @@
|
||||
magazineTypes:
|
||||
- HCPistol
|
||||
- Smg
|
||||
magFillPrototype: MagazinePistolSmg
|
||||
autoEjectMag: true
|
||||
fireRate: 6
|
||||
minAngle: 0
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: CartridgeMagnum
|
||||
caliber: Magnum
|
||||
capacity: 5
|
||||
autoCycle: true
|
||||
@@ -69,6 +70,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: CartridgeMagnum
|
||||
caliber: Magnum
|
||||
capacity: 7
|
||||
soundEmpty: /Audio/Guns/Empty/empty.ogg
|
||||
@@ -94,6 +96,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: CartridgeMagnum
|
||||
caliber: Magnum
|
||||
capacity: 7
|
||||
soundEmpty: /Audio/Guns/Empty/empty.ogg
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
currentSelector: Automatic
|
||||
allSelectors:
|
||||
- Automatic
|
||||
magFillPrototype: MagazineLRifle
|
||||
fireRate: 5
|
||||
minAngle: 0
|
||||
maxAngle: 45
|
||||
@@ -132,6 +133,7 @@
|
||||
caliber: SRifle
|
||||
magazineTypes:
|
||||
- Rifle
|
||||
magFillPrototype: MagazineSRifle
|
||||
fireRate: 5
|
||||
minAngle: 0
|
||||
maxAngle: 45
|
||||
@@ -172,6 +174,7 @@
|
||||
caliber: ClRifle
|
||||
magazineTypes:
|
||||
- Rifle
|
||||
magFillPrototype: MagazineClRifle10x24
|
||||
fireRate: 8
|
||||
minAngle: 10
|
||||
maxAngle: 60
|
||||
@@ -255,6 +258,7 @@
|
||||
caliber: SRifle
|
||||
magazineTypes:
|
||||
- Rifle
|
||||
magFillPrototype: MagazineSRifle
|
||||
fireRate: 5
|
||||
minAngle: 0
|
||||
maxAngle: 45
|
||||
@@ -293,6 +297,7 @@
|
||||
caliber: SRifle
|
||||
magazineTypes:
|
||||
- Rifle
|
||||
magFillPrototype: MagazineSRifle
|
||||
autoEjectMag: true
|
||||
fireRate: 5
|
||||
minAngle: 0
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
maxAngle: 60
|
||||
angleIncrease: 10
|
||||
angleDecay: 60
|
||||
magFillPrototype: MagazinePistolSmg
|
||||
soundGunshot: /Audio/Guns/Gunshots/smg.ogg
|
||||
soundEmpty: /Audio/Guns/Empty/empty.ogg
|
||||
soundRack: /Audio/Guns/Cock/smg_cock.ogg
|
||||
@@ -146,6 +147,7 @@
|
||||
caliber: Magnum
|
||||
magazineTypes:
|
||||
- Smg
|
||||
magFillPrototype: MagazineMagnumSmg
|
||||
minAngle: 5
|
||||
maxAngle: 60
|
||||
angleIncrease: 12
|
||||
@@ -229,6 +231,7 @@
|
||||
caliber: Pistol
|
||||
magazineTypes:
|
||||
- SmgTopMounted
|
||||
magFillPrototype: MagazinePistolSmgTopMounted
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: MagVisualizer2D
|
||||
@@ -265,6 +268,7 @@
|
||||
caliber: Magnum
|
||||
magazineTypes:
|
||||
- Smg
|
||||
magFillPrototype: MagazineMagnumSmg
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: BarrelBoltVisualizer2D
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: ShellShotgun
|
||||
caliber: Shotgun
|
||||
capacity: 7
|
||||
fireRate: 2.0
|
||||
@@ -57,6 +58,7 @@
|
||||
caliber: Shotgun
|
||||
magazineTypes:
|
||||
- Rifle
|
||||
magFillPrototype: MagazineShotgun
|
||||
soundGunshot: /Audio/Guns/Gunshots/shotgun.ogg
|
||||
soundEmpty: /Audio/Guns/Empty/empty.ogg
|
||||
soundRack: /Audio/Guns/Cock/smg_cock.ogg
|
||||
@@ -98,6 +100,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: ShellShotgun
|
||||
capacity: 2
|
||||
fireRate: 8.0
|
||||
minAngle: 10
|
||||
@@ -221,6 +224,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: ShellShotgun
|
||||
capacity: 2
|
||||
fireRate: 8.0
|
||||
minAngle: 10
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
currentSelector: Single
|
||||
allSelectors:
|
||||
- Single
|
||||
fillPrototype: CartridgeLRifle
|
||||
caliber: LRifle
|
||||
capacity: 10
|
||||
fireRate: 1.0
|
||||
@@ -79,6 +80,7 @@
|
||||
- type: BoltActionBarrel
|
||||
caliber: AntiMaterial
|
||||
capacity: 1
|
||||
fillPrototype: CartridgeAntiMaterial
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: BarrelBoltVisualizer2D
|
||||
|
||||
Reference in New Issue
Block a user