Add more dakka (#307)

* Add more dakka

Some slight codebase changes to facilitate more robust behaviour.

* Update Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs

Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* Remix last stereo to mono

hpistol + ltrifle
This commit is contained in:
metalgearsloth
2019-08-22 19:08:32 +10:00
committed by Pieter-Jan Briers
parent 44fdf4022e
commit 9431011ba5
816 changed files with 6969 additions and 139 deletions

View File

@@ -136,6 +136,33 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
public enum BallisticMagazineType
{
Unspecified = 0,
A12mm,
// .32
A32,
// .357
A357,
// .44
A44,
// .45mm
A45mm,
// .50 cal
A50,
// 5.56mm
A556mm,
// 6.5mm
A65mm,
// 7.62mm
A762mm,
Maxim,
// 9mm
A9mm,
A9mmSMG,
A9mmTopMounted,
// 10mm
A10mm,
A10mmSMG,
// 20mm
A20mm,
// 24mm
A24mm,
}
}

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects;
@@ -12,6 +14,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
@@ -30,10 +33,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
[ViewVariables]
private ContainerSlot _magazineSlot;
private BallisticMagazineType _magazineType;
private List<BallisticMagazineType> _magazineTypes;
[ViewVariables]
public BallisticMagazineType MagazineType => _magazineType;
public List<BallisticMagazineType> MagazineTypes => _magazineTypes;
[ViewVariables]
private IEntity Magazine => _magazineSlot.ContainedEntity;
@@ -65,7 +68,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
{
base.ExposeData(serializer);
serializer.DataField(ref _magazineType, "magazine", BallisticMagazineType.Unspecified);
serializer.DataField(ref _magazineTypes, "magazines",
new List<BallisticMagazineType>{BallisticMagazineType.Unspecified});
serializer.DataField(ref _defaultMagazine, "default_magazine", null);
serializer.DataField(ref _autoEjectMagazine, "auto_eject_magazine", false);
serializer.DataField(ref _autoEjectSound, "sound_auto_eject", null);
@@ -102,7 +106,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
throw new ArgumentException("Not a magazine", nameof(magazine));
}
if (component.MagazineType != MagazineType)
if (!MagazineTypes.Contains(component.MagazineType))
{
throw new ArgumentException("Wrong magazine type", nameof(magazine));
}
@@ -170,7 +174,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
var entity = RemoveFromChamber(chamber);
entity.Transform.GridPosition = Owner.Transform.GridPosition;
entity.Transform.LocalRotation = _bulletDropRandom.Pick(_randomBulletDirs).ToAngle();
var effect = $"/Audio/items/weapons/casingfall{_bulletDropRandom.Next(1, 4)}.ogg";
var effect = $"/Audio/Guns/Casings/casingfall{_bulletDropRandom.Next(1, 4)}.ogg";
Owner.GetComponent<SoundComponent>().Play(effect, AudioParams.Default.WithVolume(-3));
if (Magazine != null)
@@ -223,7 +227,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
return false;
}
if (component.MagazineType != MagazineType || component.Caliber != Caliber)
if (!MagazineTypes.Contains(component.MagazineType) || component.Caliber != Caliber)
{
Owner.PopupMessage(eventArgs.User, "Magazine doesn't fit.");
return false;

View File

@@ -21,9 +21,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
{
public abstract class ProjectileWeaponComponent : Component
{
private float _velocity = 20f;
private float _spreadStdDev = 3;
private bool _spread = true;
private string _soundGunshot;
#pragma warning disable 649
[Dependency] private IRobustRandom _spreadRandom;
@@ -57,6 +57,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
serializer.DataField(ref _spread, "spread", true);
serializer.DataField(ref _spreadStdDev, "spreadstddev", 3);
serializer.DataField(ref _soundGunshot, "sound_gunshot", "/Audio/Guns/Gunshots/smg.ogg");
}
private void Fire(IEntity user, GridCoordinates clickLocation)
@@ -85,15 +86,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
//Give it the velocity we fire from this weapon, and make sure it doesn't shoot our character
projectile.GetComponent<ProjectileComponent>().IgnoreEntity(user);
var velocity = projectile.GetComponent<ProjectileComponent>().Velocity;
//Give it the velocity this weapon gives to things it fires from itself
projectile.GetComponent<PhysicsComponent>().LinearVelocity = angle.ToVec() * _velocity;
projectile.GetComponent<PhysicsComponent>().LinearVelocity = angle.ToVec() * velocity;
//Rotate the bullets sprite to the correct direction, from north facing I guess
projectile.Transform.LocalRotation = angle.Theta;
// Sound!
Owner.GetComponent<SoundComponent>().Play("/Audio/gunshot_c20.ogg");
Owner.GetComponent<SoundComponent>().Play(_soundGunshot);
}
/// <summary>
@@ -105,6 +107,29 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
public enum BallisticCaliber
{
Unspecified = 0,
A12mm,
// .32
A32,
// .357
A357,
// .44
A44,
// .45mm
A45mm,
// .50 cal
A50,
// 5.56mm
A556mm,
// 6.5mm
A65mm,
// 7.62mm
A762mm,
// 9mm
A9mm,
// 10mm
A10mm,
// 20mm
A20mm,
// 24mm
A24mm,
}
}