From 6f298cab62edcacf157f00bcd186cdf8c6ea7e53 Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 18:12:01 +0200 Subject: [PATCH 1/9] Update .gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 08e5dd6d0a..1a78220d3a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "RobustToolbox"] path = RobustToolbox - url = https://github.com/space-wizards/RobustToolbox.git + url = https://github.com/PrPleGoo/RobustToolbox.git branch = master \ No newline at end of file From ee7a29326db3ea2b4a17fa2bcd1d9b5a6f45929a Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:22:38 +0200 Subject: [PATCH 2/9] AttackBy with an EventArg object for a parameter --- .../Construction/ConstructionComponent.cs | 11 +++++------ .../Interactable/HandheldLightComponent.cs | 10 +++++----- .../Items/Storage/ServerStorageComponent.cs | 17 +++++++++++------ .../Components/Power/PowerTransferComponent.cs | 7 ++++--- .../Components/Power/PoweredLightComponent.cs | 8 ++++---- .../Components/Stack/StackComponent.cs | 9 ++++----- .../Ranged/Hitscan/HitscanWeaponComponent.cs | 15 +++++++-------- .../BallisticMagazineWeaponComponent.cs | 16 +++++++--------- .../EntitySystems/Click/InteractionSystem.cs | 16 ++++++++++------ 9 files changed, 57 insertions(+), 52 deletions(-) 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; } From 495315565a8df9f3df2f4f03833b4510164d2219 Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:27:39 +0200 Subject: [PATCH 3/9] AttackHand with an EventArg object for a parameter --- .../Components/Doors/ServerDoorComponent.cs | 2 +- .../Components/Items/Storage/ItemComponent.cs | 7 ++++--- .../GameObjects/Components/Power/ApcComponent.cs | 4 ++-- .../Components/Power/PoweredLightComponent.cs | 8 ++++---- .../EntitySystems/Click/InteractionSystem.cs | 12 ++++++++---- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index d8c52b018c..de39cee46d 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -41,7 +41,7 @@ namespace Content.Server.GameObjects base.OnRemove(); } - public bool Attackhand(IEntity user) + public bool AttackHand(AttackHandEventArgs eventArgs) { if (_state == DoorState.Open) { diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index f9e3bf69c6..153c730948 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -2,10 +2,11 @@ using SS14.Server.Interfaces.GameObjects; using Content.Shared.GameObjects; using SS14.Shared.Interfaces.GameObjects; +using Content.Server.GameObjects.EntitySystems; namespace Content.Server.GameObjects { - public class ItemComponent : StoreableComponent, EntitySystems.IAttackHand + public class ItemComponent : StoreableComponent, IAttackHand { public override string Name => "Item"; @@ -26,9 +27,9 @@ namespace Content.Server.GameObjects } } - public bool Attackhand(IEntity user) + public bool AttackHand(AttackHandEventArgs eventArgs) { - var hands = user.GetComponent(); + var hands = eventArgs.User.GetComponent(); hands.PutInHand(this, hands.ActiveIndex, fallback: false); return true; } diff --git a/Content.Server/GameObjects/Components/Power/ApcComponent.cs b/Content.Server/GameObjects/Components/Power/ApcComponent.cs index e8d32c9279..b63cd37330 100644 --- a/Content.Server/GameObjects/Components/Power/ApcComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcComponent.cs @@ -106,9 +106,9 @@ namespace Content.Server.GameObjects.Components.Power return net.Lack > 0 ? ApcExternalPowerState.Low : ApcExternalPowerState.Good; } - bool IAttackHand.Attackhand(IEntity user) + bool IAttackHand.AttackHand(AttackHandEventArgs eventArgs) { - if (!user.TryGetComponent(out IActorComponent actor)) + if (!eventArgs.User.TryGetComponent(out IActorComponent actor)) { return false; } diff --git a/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs b/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs index 48c38d62cb..91b9065086 100644 --- a/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs +++ b/Content.Server/GameObjects/Components/Power/PoweredLightComponent.cs @@ -55,16 +55,16 @@ namespace Content.Server.GameObjects.Components.Power return InsertBulb(eventArgs.AttackWith); } - bool IAttackHand.Attackhand(IEntity user) + bool IAttackHand.AttackHand(AttackHandEventArgs eventArgs) { - if (user.GetComponent().GetSlotItem(EquipmentSlotDefines.Slots.GLOVES) != null) + if (eventArgs.User.GetComponent().GetSlotItem(EquipmentSlotDefines.Slots.GLOVES) != null) { - EjectBulb(user); + EjectBulb(eventArgs.User); UpdateLight(); return true; } - if (!user.TryGetComponent(out DamageableComponent damageableComponent)) return false; + if (!eventArgs.User.TryGetComponent(out DamageableComponent damageableComponent)) return false; damageableComponent.TakeDamage(DamageType.Heat, 20); return true; } diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 4b13e8aee1..a67252fd12 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -30,9 +30,8 @@ namespace Content.Server.GameObjects.EntitySystems bool AttackBy(AttackByEventArgs eventArgs); } - public class AttackByEventArgs : EventArgs + public class AttackByEventArgs : AttackHandEventArgs { - public IEntity User { get; set; } public IEntity AttackWith { get; set; } } @@ -46,7 +45,12 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// - bool Attackhand(IEntity user); + bool AttackHand(AttackHandEventArgs eventArgs); + } + + public class AttackHandEventArgs : EventArgs + { + public IEntity User { get; set; } } /// @@ -301,7 +305,7 @@ namespace Content.Server.GameObjects.EntitySystems for (var i = 0; i < interactables.Count; i++) { - if (interactables[i].Attackhand(user)) //If an attackby returns a status completion we finish our attack + if (interactables[i].AttackHand(new AttackHandEventArgs { User = user})) //If an attackby returns a status completion we finish our attack { return; } From ddde077d164ada5cbcc6d8684781d319bfc17077 Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:29:16 +0200 Subject: [PATCH 4/9] AttackByEventArgs inherits from EventArgs again --- .../GameObjects/EntitySystems/Click/InteractionSystem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index a67252fd12..45cd5b5ec9 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -30,8 +30,9 @@ namespace Content.Server.GameObjects.EntitySystems bool AttackBy(AttackByEventArgs eventArgs); } - public class AttackByEventArgs : AttackHandEventArgs + public class AttackByEventArgs : EventArgs { + public IEntity User { get; set; } public IEntity AttackWith { get; set; } } From 9b2be2ba50ac1dda8fe8b7a848bd7f62101120d2 Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:32:18 +0200 Subject: [PATCH 5/9] RangedAttackBy with an EventArg object for a parameter --- .../EntitySystems/Click/InteractionSystem.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 45cd5b5ec9..102c6c539e 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -57,7 +57,7 @@ namespace Content.Server.GameObjects.EntitySystems /// /// This interface gives components behavior when being clicked by objects outside the range of direct use /// - public interface IRangedAttackby + public interface IRangedAttackBy { /// /// Called when we try to interact with an entity out of range @@ -66,7 +66,14 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// - bool RangedAttackby(IEntity user, IEntity attackwith, GridCoordinates clicklocation); + bool RangedAttackBy(RangedAttackByEventArgs eventArgs); + } + + public class RangedAttackByEventArgs : EventArgs + { + public IEntity User { get; set; } + public IEntity Weapon { get; set; } + public GridCoordinates ClickLocation { get; set; } } /// @@ -358,12 +365,12 @@ namespace Content.Server.GameObjects.EntitySystems /// public static void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, GridCoordinates clicklocation) { - List rangedusables = attacked.GetAllComponents().ToList(); + List rangedusables = attacked.GetAllComponents().ToList(); //See if we have a ranged attack interaction for (var i = 0; i < rangedusables.Count; i++) { - if (rangedusables[i].RangedAttackby(user, weapon, clicklocation)) //If an attackby returns a status completion we finish our attack + if (rangedusables[i].RangedAttackBy(new RangedAttackByEventArgs { User = user, Weapon = weapon, ClickLocation = clicklocation })) //If an attackby returns a status completion we finish our attack { return; } From 7d85141c9bd20bd5855c0d1aa82db28da6eee4a5 Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:40:46 +0200 Subject: [PATCH 6/9] AfterAttack with an EventArg object for a parameter --- .../Components/Healing/HealingComponent.cs | 6 +++--- .../Interactable/Tools/CrowbarComponent.cs | 6 +++--- .../Components/Power/PowerDebugTool.cs | 18 +++++++++--------- .../Weapon/Melee/MeleeWeaponComponent.cs | 10 +++++----- .../EntitySystems/Click/InteractionSystem.cs | 15 +++++++++++---- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Content.Server/GameObjects/Components/Healing/HealingComponent.cs b/Content.Server/GameObjects/Components/Healing/HealingComponent.cs index d20f9d18ee..76dc535382 100644 --- a/Content.Server/GameObjects/Components/Healing/HealingComponent.cs +++ b/Content.Server/GameObjects/Components/Healing/HealingComponent.cs @@ -31,14 +31,14 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee serializer.DataField(ref Damage, "damage", DamageType.Brute); } - void IAfterAttack.Afterattack(IEntity user, GridCoordinates clicklocation, IEntity attacked) + void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs) { - if (attacked == null) + if (eventArgs.Attacked == null) { return; } - if (!attacked.TryGetComponent(out DamageableComponent damagecomponent)) return; + if (!eventArgs.Attacked.TryGetComponent(out DamageableComponent damagecomponent)) return; if (Owner.TryGetComponent(out StackComponent stackComponent)) { if (!stackComponent.Use(1)) diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs index 870b77e26d..b0ff5f380f 100644 --- a/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs @@ -25,14 +25,14 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools IoCManager.InjectDependencies(this); } - public void Afterattack(IEntity user, GridCoordinates clicklocation, IEntity attacked) + public void AfterAttack(AfterAttackEventArgs eventArgs) { - var tile = clicklocation.Grid.GetTile(clicklocation); + var tile = eventArgs.ClickLocation.Grid.GetTile(eventArgs.ClickLocation); var tileDef = (ContentTileDefinition) tile.TileDef; if (tileDef.CanCrowbar) { var underplating = _tileDefinitionManager["underplating"]; - clicklocation.Grid.SetTile(clicklocation, underplating.TileId); + eventArgs.ClickLocation.Grid.SetTile(eventArgs.ClickLocation, underplating.TileId); _entitySystemManager.GetEntitySystem().Play("/Audio/items/crowbar.ogg", Owner); } } diff --git a/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs b/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs index d24897940c..0fff0c1e4f 100644 --- a/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs +++ b/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Text; using Content.Server.GameObjects.EntitySystems; using Content.Shared.GameObjects.Components.Power; @@ -11,18 +11,18 @@ namespace Content.Server.GameObjects.Components.Power { public class PowerDebugTool : SharedPowerDebugTool, IAfterAttack { - void IAfterAttack.Afterattack(IEntity user, GridCoordinates clicklocation, IEntity attacked) + void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs) { - if (attacked == null) + if (eventArgs.Attacked == null) { return; } var builder = new StringBuilder(); - builder.AppendFormat("Entity: {0} ({1})\n", attacked.Name, attacked.Uid); + builder.AppendFormat("Entity: {0} ({1})\n", eventArgs.Attacked.Name, eventArgs.Attacked.Uid); - if (attacked.TryGetComponent(out var node)) + if (eventArgs.Attacked.TryGetComponent(out var node)) { builder.AppendFormat("Power Node:\n"); if (node.Parent == null) @@ -50,7 +50,7 @@ namespace Content.Server.GameObjects.Components.Power } } - if (attacked.TryGetComponent(out var device)) + if (eventArgs.Attacked.TryGetComponent(out var device)) { builder.AppendFormat(@"Power Device: Load: {0} W @@ -75,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Power } } - if (attacked.TryGetComponent(out var storage)) + if (eventArgs.Attacked.TryGetComponent(out var storage)) { var stateSeconds = (DateTime.Now - storage.LastChargeStateChange).TotalSeconds; builder.AppendFormat(@"Power Storage: @@ -84,14 +84,14 @@ namespace Content.Server.GameObjects.Components.Power ", storage.Capacity, storage.Charge, storage.ChargeRate, storage.DistributionRate, storage.ChargePowernet, storage.LastChargeState, storage.GetChargeState(), stateSeconds); } - if (attacked.TryGetComponent(out var transfer)) + if (eventArgs.Attacked.TryGetComponent(out var transfer)) { builder.AppendFormat(@"Power Transfer: Powernet: {0} ", transfer.Parent.Uid); } - OpenDataWindowClientSide(user, builder.ToString()); + OpenDataWindowClientSide(eventArgs.User, builder.ToString()); } private void OpenDataWindowClientSide(IEntity user, string data) diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs index 2837918c18..961f2ff730 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs @@ -32,15 +32,15 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee serializer.DataField(ref ArcWidth, "arcwidth", 90); } - void IAfterAttack.Afterattack(IEntity user, GridCoordinates clicklocation, IEntity attacked) + void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs) { - var location = user.GetComponent().GridPosition; - var angle = new Angle(clicklocation.ToWorld().Position - location.ToWorld().Position); - var entities = IoCManager.Resolve().GetEntitiesInArc(user.GetComponent().GridPosition, Range, angle, ArcWidth); + var location = eventArgs.User.GetComponent().GridPosition; + var angle = new Angle(eventArgs.ClickLocation.ToWorld().Position - location.ToWorld().Position); + var entities = IoCManager.Resolve().GetEntitiesInArc(eventArgs.User.GetComponent().GridPosition, Range, angle, ArcWidth); foreach (var entity in entities) { - if (!entity.GetComponent().IsMapTransform || entity == user) + if (!entity.GetComponent().IsMapTransform || entity == eventArgs.User) continue; if (entity.TryGetComponent(out DamageableComponent damagecomponent)) diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 102c6c539e..3243d6035d 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -88,7 +88,14 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// The entity that was clicked on out of range. May be null if no entity was clicked on.true - void Afterattack(IEntity user, GridCoordinates clicklocation, IEntity attacked); + void AfterAttack(AfterAttackEventArgs eventArgs); + } + + public class AfterAttackEventArgs : EventArgs + { + public IEntity User { get; set; } + public GridCoordinates ClickLocation { get; set; } + public IEntity Attacked { get; set; } } /// @@ -266,7 +273,7 @@ namespace Content.Server.GameObjects.EntitySystems for (var i = 0; i < afterattacks.Count; i++) { - afterattacks[i].Afterattack(user, clicklocation, null); + afterattacks[i].AfterAttack(new AfterAttackEventArgs { User = user, ClickLocation = clicklocation }); } } @@ -297,7 +304,7 @@ namespace Content.Server.GameObjects.EntitySystems for (var i = 0; i < afterattacks.Count; i++) { - afterattacks[i].Afterattack(user, clicklocation, attacked); + afterattacks[i].AfterAttack(new AfterAttackEventArgs { User = user, ClickLocation = clicklocation, Attacked = attacked }); } } @@ -383,7 +390,7 @@ namespace Content.Server.GameObjects.EntitySystems //See if we have a ranged attack interaction for (var i = 0; i < afterattacks.Count; i++) { - afterattacks[i].Afterattack(user, clicklocation, attacked); + afterattacks[i].AfterAttack(new AfterAttackEventArgs { User = user, ClickLocation = clicklocation, Attacked = attacked }); } } } From c90d54664be9fbe7be44d89c7bd4edd1e68c2369 Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:42:49 +0200 Subject: [PATCH 7/9] UseEntity with an EventArg object for a parameter --- .../GameObjects/Components/Healing/HealingComponent.cs | 6 +++--- .../Components/Interactable/HandheldLightComponent.cs | 2 +- .../Components/Interactable/Tools/WelderComponent.cs | 2 +- .../Components/Items/Storage/ServerStorageComponent.cs | 6 +++--- .../Projectile/BallisticMagazineWeaponComponent.cs | 6 +++--- .../GameObjects/EntitySystems/Click/InteractionSystem.cs | 9 +++++++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Content.Server/GameObjects/Components/Healing/HealingComponent.cs b/Content.Server/GameObjects/Components/Healing/HealingComponent.cs index 76dc535382..357bdc66ef 100644 --- a/Content.Server/GameObjects/Components/Healing/HealingComponent.cs +++ b/Content.Server/GameObjects/Components/Healing/HealingComponent.cs @@ -1,4 +1,4 @@ -using System; +using System; using Content.Server.GameObjects.Components.Stack; using SS14.Shared.GameObjects; using Content.Server.GameObjects.EntitySystems; @@ -54,9 +54,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee Owner.Delete(); } - bool IUse.UseEntity(IEntity user) + bool IUse.UseEntity(UseEntityEventArgs eventArgs) { - if (!user.TryGetComponent(out DamageableComponent damagecomponent)) return false; + if (!eventArgs.User.TryGetComponent(out DamageableComponent damagecomponent)) return false; if (Owner.TryGetComponent(out StackComponent stackComponent)) { if (!stackComponent.Use(1)) diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs index cdc9fb254c..87e1b16e9e 100644 --- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs @@ -59,7 +59,7 @@ namespace Content.Server.GameObjects.Components.Interactable return null; } - bool IUse.UseEntity(IEntity user) + bool IUse.UseEntity(UseEntityEventArgs eventArgs) { return ToggleStatus(); } diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs index 2a42e3ce56..6e44644212 100644 --- a/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs @@ -115,7 +115,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools return Fuel > 0; } - public bool UseEntity(IEntity user) + public bool UseEntity(UseEntityEventArgs eventArgs) { return ToggleStatus(); } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index 5ebb35d31c..4a094fae79 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -159,10 +159,10 @@ namespace Content.Server.GameObjects /// /// /// - bool IUse.UseEntity(IEntity user) + bool IUse.UseEntity(UseEntityEventArgs eventArgs) { _ensureInitialCalculated(); - var user_session = user.GetComponent().playerSession; + var user_session = eventArgs.User.GetComponent().playerSession; Logger.DebugS("Storage", "Storage (UID {0}) \"used\" by player session (UID {1}).", Owner.Uid, user_session.AttachedEntityUid); SubscribeSession(user_session); SendNetworkMessage(new OpenStorageUIMessage(), user_session.ConnectedClient); @@ -304,7 +304,7 @@ namespace Content.Server.GameObjects /// void IActivate.Activate(IEntity user) { - ((IUse) this).UseEntity(user); + ((IUse) this).UseEntity(new UseEntityEventArgs { User = user }); } private void _ensureInitialCalculated() diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs index 94bca2c65a..b121bd1e8f 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs @@ -185,16 +185,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile _updateAppearance(); } - public bool UseEntity(IEntity user) + public bool UseEntity(UseEntityEventArgs eventArgs) { var ret = EjectMagazine(); if (ret) { - Owner.PopupMessage(user, "Magazine ejected"); + Owner.PopupMessage(eventArgs.User, "Magazine ejected"); } else { - Owner.PopupMessage(user, "No magazine"); + Owner.PopupMessage(eventArgs.User, "No magazine"); } return true; diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 3243d6035d..dc091410a0 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -108,7 +108,12 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// - bool UseEntity(IEntity user); + bool UseEntity(UseEntityEventArgs eventArgs); + } + + public class UseEntityEventArgs : EventArgs + { + public IEntity User { get; set; } } /// @@ -356,7 +361,7 @@ namespace Content.Server.GameObjects.EntitySystems //Try to use item on any components which have the interface for (var i = 0; i < usables.Count; i++) { - if (usables[i].UseEntity(user)) //If an attackby returns a status completion we finish our attack + if (usables[i].UseEntity(new UseEntityEventArgs { User = user })) //If an attackby returns a status completion we finish our attack { return; } From 66344c3ac7f9659ac640a6b242f73edb09fcf599 Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:44:32 +0200 Subject: [PATCH 8/9] Activate with an EventArg object for a parameter --- .../Components/Items/Storage/ServerStorageComponent.cs | 4 ++-- .../GameObjects/EntitySystems/Click/InteractionSystem.cs | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index 4a094fae79..759ff0585b 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -302,9 +302,9 @@ namespace Content.Server.GameObjects } /// - void IActivate.Activate(IEntity user) + void IActivate.Activate(ActivateEventArgs eventArgs) { - ((IUse) this).UseEntity(new UseEntityEventArgs { User = user }); + ((IUse) this).UseEntity(new UseEntityEventArgs { User = eventArgs.User }); } private void _ensureInitialCalculated() diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index dc091410a0..982a56df0b 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -125,7 +125,12 @@ namespace Content.Server.GameObjects.EntitySystems /// Called when this component is activated by another entity. /// /// Entity that activated this component. - void Activate(IEntity user); + void Activate(ActivateEventArgs eventArgs); + } + + public class ActivateEventArgs : EventArgs + { + public IEntity User { get; set; } } /// @@ -159,7 +164,7 @@ namespace Content.Server.GameObjects.EntitySystems if (!playerEnt.Transform.GridPosition.InRange(used.Transform.GridPosition, INTERACTION_RANGE)) return; - activateComp.Activate(playerEnt); + activateComp.Activate(new ActivateEventArgs { User = playerEnt }); } private void HandleUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid) From 43cef42fba57a6d616a739e8ff90cde16a5d701c Mon Sep 17 00:00:00 2001 From: PrPleGoo Date: Fri, 5 Apr 2019 19:54:24 +0200 Subject: [PATCH 9/9] Fixed module --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 1a78220d3a..08e5dd6d0a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "RobustToolbox"] path = RobustToolbox - url = https://github.com/PrPleGoo/RobustToolbox.git + url = https://github.com/space-wizards/RobustToolbox.git branch = master \ No newline at end of file