diff --git a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs
index 8ea9badc00..9406cf9e4a 100644
--- a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs
+++ b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs
@@ -1,7 +1,6 @@
-using System;
+using System;
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Interactable.Tools;
-using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Construction;
@@ -18,7 +17,7 @@ using static Content.Shared.Construction.ConstructionStepTool;
namespace Content.Server.GameObjects.Components.Construction
{
- public class ConstructionComponent : Component, IAttackby
+ public class ConstructionComponent : Component, IAttackBy
{
public override string Name => "Construction";
@@ -41,11 +40,11 @@ namespace Content.Server.GameObjects.Components.Construction
random = new Random();
}
- public bool Attackby(IEntity user, IEntity attackwith)
+ public bool AttackBy(AttackByEventArgs eventArgs)
{
var stage = Prototype.Stages[Stage];
- if (TryProcessStep(stage.Forward, attackwith))
+ if (TryProcessStep(stage.Forward, eventArgs.AttackWith))
{
Stage++;
if (Stage == Prototype.Stages.Count - 1)
@@ -65,7 +64,7 @@ namespace Content.Server.GameObjects.Components.Construction
}
}
- else if (TryProcessStep(stage.Backward, attackwith))
+ else if (TryProcessStep(stage.Backward, eventArgs.AttackWith))
{
Stage--;
if (Stage == 0)
diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs
index f2a1fbb821..cdc9fb254c 100644
--- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs
+++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs
@@ -14,7 +14,7 @@ namespace Content.Server.GameObjects.Components.Interactable
///
/// Component that represents a handheld lightsource which can be toggled on and off.
///
- internal class HandheldLightComponent : Component, IUse, IExamine, IAttackby
+ internal class HandheldLightComponent : Component, IUse, IExamine, IAttackBy
{
public const float Wattage = 10;
[ViewVariables] private ContainerSlot _cellContainer;
@@ -41,15 +41,15 @@ namespace Content.Server.GameObjects.Components.Interactable
[ViewVariables]
public bool Activated { get; private set; }
- bool IAttackby.Attackby(IEntity user, IEntity attackwith)
+ bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
{
- if (!attackwith.HasComponent()) return false;
+ if (!eventArgs.AttackWith.HasComponent()) return false;
if (Cell != null) return false;
- user.GetComponent().Drop(attackwith, _cellContainer);
+ eventArgs.User.GetComponent().Drop(eventArgs.AttackWith, _cellContainer);
- return _cellContainer.Insert(attackwith);
+ return _cellContainer.Insert(eventArgs.AttackWith);
}
string IExamine.Examine()
diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs
index bc31cad845..5ebb35d31c 100644
--- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs
+++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs
@@ -23,7 +23,7 @@ namespace Content.Server.GameObjects
///
/// Storage component for containing entities within this one, matches a UI on the client which shows stored entities
///
- public class ServerStorageComponent : SharedStorageComponent, IAttackby, IUse, IActivate
+ public class ServerStorageComponent : SharedStorageComponent, IAttackBy, IUse, IActivate
{
private Container storage;
@@ -131,25 +131,25 @@ namespace Content.Server.GameObjects
///
///
///
- bool IAttackby.Attackby(IEntity user, IEntity attackwith)
+ bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
{
_ensureInitialCalculated();
- Logger.DebugS("Storage", "Storage (UID {0}) attacked by user (UID {1}) with entity (UID {2}).", Owner.Uid, user.Uid, attackwith.Uid);
+ Logger.DebugS("Storage", "Storage (UID {0}) attacked by user (UID {1}) with entity (UID {2}).", Owner.Uid, eventArgs.User.Uid, eventArgs.AttackWith.Uid);
- if (!user.TryGetComponent(out HandsComponent hands))
+ if (!eventArgs.User.TryGetComponent(out HandsComponent hands))
return false;
//Check that we can drop the item from our hands first otherwise we obviously cant put it inside
if (CanInsert(hands.GetActiveHand.Owner) && hands.Drop(hands.ActiveIndex))
{
- if (Insert(attackwith))
+ if (Insert(eventArgs.AttackWith))
{
return true;
}
}
else
{
- Owner.PopupMessage(user, "Can't insert.");
+ Owner.PopupMessage(eventArgs.User, "Can't insert.");
}
return false;
}
@@ -324,5 +324,10 @@ namespace Content.Server.GameObjects
_storageInitialCalculated = true;
}
+
+ public bool Attackby(AttackByEventArgs eventArgs)
+ {
+ throw new System.NotImplementedException();
+ }
}
}
diff --git a/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs b/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs
index ddfdb1919b..f214f519a1 100644
--- a/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs
+++ b/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs
@@ -8,13 +8,14 @@ using SS14.Shared.Interfaces.GameObjects;
using Content.Server.GameObjects.Components.Interactable.Tools;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.ViewVariables;
+using System;
namespace Content.Server.GameObjects.Components.Power
{
///
/// Component to transfer power to nearby components, can create powernets and connect to nodes
///
- public class PowerTransferComponent : Component, IAttackby
+ public class PowerTransferComponent : Component, IAttackBy
{
public override string Name => "PowerTransfer";
@@ -133,9 +134,9 @@ namespace Content.Server.GameObjects.Components.Power
return Parent != null && Parent.Dirty == false && !Regenerating;
}
- public bool Attackby(IEntity user, IEntity attackwith)
+ public bool AttackBy(AttackByEventArgs eventArgs)
{
- if (attackwith.TryGetComponent(out WirecutterComponent wirecutter))
+ if (eventArgs.AttackWith.TryGetComponent(out WirecutterComponent wirecutter))
{
Owner.Delete();
return true;
diff --git a/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs b/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs
index 74e168398a..48c38d62cb 100644
--- a/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs
+++ b/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
@@ -23,7 +23,7 @@ namespace Content.Server.GameObjects.Components.Power
///
/// Component that represents a wall light. It has a light bulb that can be replaced when broken.
///
- public class PoweredLightComponent : Component, IAttackHand, IAttackby
+ public class PoweredLightComponent : Component, IAttackHand, IAttackBy
{
public override string Name => "PoweredLight";
@@ -50,9 +50,9 @@ namespace Content.Server.GameObjects.Components.Power
}
}
- bool IAttackby.Attackby(IEntity user, IEntity attackwith)
+ bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
{
- return InsertBulb(attackwith);
+ return InsertBulb(eventArgs.AttackWith);
}
bool IAttackHand.Attackhand(IEntity user)
diff --git a/Content.Server/GameObjects/Components/Stack/StackComponent.cs b/Content.Server/GameObjects/Components/Stack/StackComponent.cs
index da4d4fd959..8cb276d9f9 100644
--- a/Content.Server/GameObjects/Components/Stack/StackComponent.cs
+++ b/Content.Server/GameObjects/Components/Stack/StackComponent.cs
@@ -1,7 +1,6 @@
-using System;
+using System;
using Content.Server.GameObjects.EntitySystems;
using SS14.Shared.GameObjects;
-using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.Reflection;
using SS14.Shared.IoC;
using SS14.Shared.Serialization;
@@ -10,7 +9,7 @@ using SS14.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Stack
{
// TODO: Naming and presentation and such could use some improvement.
- public class StackComponent : Component, IAttackby, IExamine
+ public class StackComponent : Component, IAttackBy, IExamine
{
private const string SerializationCache = "stack";
private int _count = 50;
@@ -97,9 +96,9 @@ namespace Content.Server.GameObjects.Components.Stack
StackType = stackType;
}
- public bool Attackby(IEntity user, IEntity attackwith)
+ public bool AttackBy(AttackByEventArgs eventArgs)
{
- if (attackwith.TryGetComponent(out var stack))
+ if (eventArgs.AttackWith.TryGetComponent(out var stack))
{
if (!stack.StackType.Equals(StackType))
{
diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs
index e4a4b3398f..5919109924 100644
--- a/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs
+++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs
@@ -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);
diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs
index e319ae3d75..94bca2c65a 100644
--- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs
+++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs
@@ -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()
diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs
index e369fa4145..4b13e8aee1 100644
--- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs
+++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs
@@ -1,6 +1,5 @@
using System;
using Content.Server.Interfaces.GameObjects;
-using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.Systems;
using SS14.Shared.Interfaces.GameObjects;
@@ -10,7 +9,6 @@ using Content.Shared.Input;
using SS14.Shared.Input;
using SS14.Shared.Log;
using SS14.Shared.Map;
-using SS14.Server.GameObjects;
using SS14.Server.GameObjects.EntitySystems;
using SS14.Server.Interfaces.Player;
using SS14.Shared.Interfaces.GameObjects.Components;
@@ -21,7 +19,7 @@ namespace Content.Server.GameObjects.EntitySystems
///
/// This interface gives components behavior when being clicked on or "attacked" by a user with an object in their hand
///
- public interface IAttackby
+ public interface IAttackBy
{
///
/// Called when using one object on another
@@ -29,7 +27,13 @@ namespace Content.Server.GameObjects.EntitySystems
///
///
///
- bool Attackby(IEntity user, IEntity attackwith);
+ bool AttackBy(AttackByEventArgs eventArgs);
+ }
+
+ public class AttackByEventArgs : EventArgs
+ {
+ public IEntity User { get; set; }
+ public IEntity AttackWith { get; set; }
}
///
@@ -263,11 +267,11 @@ namespace Content.Server.GameObjects.EntitySystems
///
public static void Interaction(IEntity user, IEntity weapon, IEntity attacked, GridCoordinates clicklocation)
{
- List interactables = attacked.GetAllComponents().ToList();
+ List interactables = attacked.GetAllComponents().ToList();
for (var i = 0; i < interactables.Count; i++)
{
- if (interactables[i].Attackby(user, weapon)) //If an attackby returns a status completion we finish our attack
+ if (interactables[i].AttackBy(new AttackByEventArgs { User = user, AttackWith = weapon })) //If an attackby returns a status completion we finish our attack
{
return;
}