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 }); } } }