AttackBy with an EventArg object for a parameter
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects;
|
||||
using SS14.Server.GameObjects.EntitySystems;
|
||||
using SS14.Shared.Audio;
|
||||
using SS14.Shared.GameObjects.EntitySystemMessages;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.Physics;
|
||||
using SS14.Shared.Interfaces.Timing;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -12,15 +11,15 @@ using SS14.Shared.Maths;
|
||||
using SS14.Shared.Physics;
|
||||
using SS14.Shared.Serialization;
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.Sound;
|
||||
using SS14.Shared.GameObjects;
|
||||
using Content.Server.GameObjects.Components.Sound;
|
||||
using SS14.Shared.GameObjects;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Shared.Interfaces;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
|
||||
{
|
||||
public class HitscanWeaponComponent : Component, IAttackby
|
||||
public class HitscanWeaponComponent : Component, IAttackBy
|
||||
{
|
||||
private const float MaxLength = 20;
|
||||
public override string Name => "HitscanWeapon";
|
||||
@@ -60,15 +59,15 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
|
||||
rangedWeapon.FireHandler = Fire;
|
||||
}
|
||||
|
||||
public bool Attackby(IEntity user, IEntity attackwith)
|
||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||
{
|
||||
if (!attackwith.TryGetComponent(out PowerStorageComponent component))
|
||||
if (!eventArgs.AttackWith.TryGetComponent(out PowerStorageComponent component))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (capacitorComponent.Full)
|
||||
{
|
||||
Owner.PopupMessage(user, "Capacitor at max charge");
|
||||
Owner.PopupMessage(eventArgs.User, "Capacitor at max charge");
|
||||
return false;
|
||||
}
|
||||
capacitorComponent.FillFrom(component);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.Sound;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects;
|
||||
@@ -6,17 +6,15 @@ using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
||||
using Content.Shared.Interfaces;
|
||||
using SS14.Server.GameObjects;
|
||||
using SS14.Server.GameObjects.Components.Container;
|
||||
using SS14.Server.GameObjects.EntitySystems;
|
||||
using SS14.Shared.Audio;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Maths;
|
||||
using SS14.Shared.Serialization;
|
||||
using SS14.Shared.Utility;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
|
||||
{
|
||||
public class BallisticMagazineWeaponComponent : BallisticWeaponComponent, IUse, IAttackby
|
||||
public class BallisticMagazineWeaponComponent : BallisticWeaponComponent, IUse, IAttackBy
|
||||
{
|
||||
public override string Name => "BallisticMagazineWeapon";
|
||||
|
||||
@@ -202,26 +200,26 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Attackby(IEntity user, IEntity attackwith)
|
||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||
{
|
||||
if (!attackwith.TryGetComponent(out BallisticMagazineComponent component))
|
||||
if (!eventArgs.AttackWith.TryGetComponent(out BallisticMagazineComponent component))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Magazine != null)
|
||||
{
|
||||
Owner.PopupMessage(user, "Already got a magazine.");
|
||||
Owner.PopupMessage(eventArgs.User, "Already got a magazine.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (component.MagazineType != MagazineType || component.Caliber != Caliber)
|
||||
{
|
||||
Owner.PopupMessage(user, "Magazine doesn't fit.");
|
||||
Owner.PopupMessage(eventArgs.User, "Magazine doesn't fit.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return InsertMagazine(attackwith);
|
||||
return InsertMagazine(eventArgs.AttackWith);
|
||||
}
|
||||
|
||||
private void _magazineAmmoCountChanged()
|
||||
|
||||
Reference in New Issue
Block a user