GUNS PELASE WORK.

This commit is contained in:
Pieter-Jan Briers
2020-06-24 20:00:31 +02:00
parent 9b6455519b
commit 74a63c9555
7 changed files with 54 additions and 48 deletions

View File

@@ -104,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
} }
} }
public IEntity TakeBullet() public IEntity TakeBullet(GridCoordinates spawnAt)
{ {
if (_ammoIsProjectile) if (_ammoIsProjectile)
{ {
@@ -122,7 +122,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
appearanceComponent.SetData(AmmoVisuals.Spent, true); appearanceComponent.SetData(AmmoVisuals.Spent, true);
} }
var entity = Owner.EntityManager.SpawnEntity(_projectileId, Owner.Transform.GridPosition); var entity = Owner.EntityManager.SpawnEntity(_projectileId, spawnAt);
DebugTools.AssertNotNull(entity); DebugTools.AssertNotNull(entity);
return entity; return entity;
} }

View File

@@ -16,6 +16,7 @@ using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
@@ -161,14 +162,14 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return _chamberContainer.ContainedEntity; return _chamberContainer.ContainedEntity;
} }
public override IEntity TakeProjectile() public override IEntity TakeProjectile(GridCoordinates spawnAt)
{ {
var chamberEntity = _chamberContainer.ContainedEntity; var chamberEntity = _chamberContainer.ContainedEntity;
if (_autoCycle) if (_autoCycle)
{ {
Cycle(); Cycle();
} }
return chamberEntity?.GetComponent<AmmoComponent>().TakeBullet(); return chamberEntity?.GetComponent<AmmoComponent>().TakeBullet(spawnAt);
} }
protected override bool WeaponCanFire() protected override bool WeaponCanFire()

View File

@@ -14,6 +14,7 @@ using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
@@ -122,14 +123,14 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return _chamberContainer.ContainedEntity; return _chamberContainer.ContainedEntity;
} }
public override IEntity TakeProjectile() public override IEntity TakeProjectile(GridCoordinates spawnAt)
{ {
var chamberEntity = _chamberContainer.ContainedEntity; var chamberEntity = _chamberContainer.ContainedEntity;
if (!_manualCycle) if (!_manualCycle)
{ {
Cycle(); Cycle();
} }
return chamberEntity?.GetComponent<AmmoComponent>().TakeBullet(); return chamberEntity?.GetComponent<AmmoComponent>().TakeBullet(spawnAt);
} }
private void Cycle(bool manual = false) private void Cycle(bool manual = false)

View File

@@ -15,6 +15,7 @@ using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
@@ -169,16 +170,17 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
/// Takes a projectile out if possible /// Takes a projectile out if possible
/// IEnumerable just to make supporting shotguns saner /// IEnumerable just to make supporting shotguns saner
/// </summary> /// </summary>
/// <param name="spawnAt"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public override IEntity TakeProjectile() public override IEntity TakeProjectile(GridCoordinates spawnAt)
{ {
var ammo = _ammoSlots[_currentSlot]; var ammo = _ammoSlots[_currentSlot];
IEntity bullet = null; IEntity bullet = null;
if (ammo != null) if (ammo != null)
{ {
var ammoComponent = ammo.GetComponent<AmmoComponent>(); var ammoComponent = ammo.GetComponent<AmmoComponent>();
bullet = ammoComponent.TakeBullet(); bullet = ammoComponent.TakeBullet(spawnAt);
if (ammoComponent.Caseless) if (ammoComponent.Caseless)
{ {
_ammoSlots[_currentSlot] = null; _ammoSlots[_currentSlot] = null;

View File

@@ -14,6 +14,7 @@ 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.IoC;
using Robust.Shared.Map;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using Logger = Robust.Shared.Log.Logger; using Logger = Robust.Shared.Log.Logger;
@@ -134,7 +135,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return ammo; return ammo;
} }
public override IEntity TakeProjectile() public override IEntity TakeProjectile(GridCoordinates spawnAt)
{ {
var powerCellEntity = _powerCellContainer.ContainedEntity; var powerCellEntity = _powerCellContainer.ContainedEntity;

View File

@@ -15,6 +15,7 @@ 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.Localization; using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -180,7 +181,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return BoltOpen ? null : _chamberContainer.ContainedEntity; return BoltOpen ? null : _chamberContainer.ContainedEntity;
} }
public override IEntity TakeProjectile() public override IEntity TakeProjectile(GridCoordinates spawnAt)
{ {
if (BoltOpen) if (BoltOpen)
{ {
@@ -189,7 +190,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
var entity = _chamberContainer.ContainedEntity; var entity = _chamberContainer.ContainedEntity;
Cycle(); Cycle();
return entity?.GetComponent<AmmoComponent>().TakeBullet(); return entity?.GetComponent<AmmoComponent>().TakeBullet(spawnAt);
} }
private void Cycle(bool manual = false) private void Cycle(bool manual = false)

View File

@@ -56,7 +56,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
private TimeSpan _lastFire; private TimeSpan _lastFire;
public abstract IEntity PeekAmmo(); public abstract IEntity PeekAmmo();
public abstract IEntity TakeProjectile(); public abstract IEntity TakeProjectile(GridCoordinates spawnAt);
// Recoil / spray control // Recoil / spray control
private Angle _minAngle; private Angle _minAngle;
@@ -193,7 +193,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
} }
var ammo = PeekAmmo(); var ammo = PeekAmmo();
var projectile = TakeProjectile(); var projectile = TakeProjectile(shooter.Transform.GridPosition);
if (projectile == null) if (projectile == null)
{ {
soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.GridPosition); soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.GridPosition);