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