diff --git a/Content.Server/Guardian/GuardianSystem.cs b/Content.Server/Guardian/GuardianSystem.cs index 0e5e57747d..d92dff0604 100644 --- a/Content.Server/Guardian/GuardianSystem.cs +++ b/Content.Server/Guardian/GuardianSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Audio; using Content.Shared.Damage; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.MobState; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -48,6 +49,8 @@ namespace Content.Server.Guardian SubscribeLocalEvent(OnHostMove); SubscribeLocalEvent(OnHostStateChange); SubscribeLocalEvent(OnHostShutdown); + + SubscribeLocalEvent(OnGuardianAttackAttempt); } private void OnGuardianUnplayer(EntityUid uid, GuardianComponent component, PlayerDetachedEvent args) @@ -79,6 +82,15 @@ namespace Content.Server.Guardian EntityManager.QueueDeleteEntity(component.HostedGuardian.Value); } + private void OnGuardianAttackAttempt(EntityUid uid, GuardianComponent component, AttackAttemptEvent args) + { + if (args.Cancelled || args.Target != component.Host) + return; + + _popupSystem.PopupCursor(Loc.GetString("guardian-attack-host"), Filter.Entities(uid)); + args.Cancel(); + } + public void ToggleGuardian(GuardianHostComponent hostComponent) { if (hostComponent.HostedGuardian == null || diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 5ffee37741..cee194a319 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -299,7 +299,7 @@ namespace Content.Server.Interaction if (!ValidateInteractAndFace(user, coordinates)) return; - if (!_actionBlockerSystem.CanAttack(user)) + if (!_actionBlockerSystem.CanAttack(user, target)) return; if (!wideAttack) diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index a919038bf5..bd36316bae 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -82,9 +82,9 @@ namespace Content.Shared.ActionBlocker return !ev.Cancelled; } - public bool CanAttack(EntityUid uid) + public bool CanAttack(EntityUid uid, EntityUid? target = null) { - var ev = new AttackAttemptEvent(uid); + var ev = new AttackAttemptEvent(uid, target); RaiseLocalEvent(uid, ev); return !ev.Cancelled; diff --git a/Content.Shared/Interaction/Events/AttackAttemptEvent.cs b/Content.Shared/Interaction/Events/AttackAttemptEvent.cs index 0ac23db7ca..9f27a75fa7 100644 --- a/Content.Shared/Interaction/Events/AttackAttemptEvent.cs +++ b/Content.Shared/Interaction/Events/AttackAttemptEvent.cs @@ -4,11 +4,13 @@ namespace Content.Shared.Interaction.Events { public class AttackAttemptEvent : CancellableEntityEventArgs { - public AttackAttemptEvent(EntityUid uid) + public EntityUid Uid { get; } + public EntityUid? Target { get; } + + public AttackAttemptEvent(EntityUid uid, EntityUid? target = null) { Uid = uid; + Target = target; } - - public EntityUid Uid { get; } } } diff --git a/Resources/Locale/en-US/guardian/guardian.ftl b/Resources/Locale/en-US/guardian/guardian.ftl index 370a405284..cf7ec019bc 100644 --- a/Resources/Locale/en-US/guardian/guardian.ftl +++ b/Resources/Locale/en-US/guardian/guardian.ftl @@ -20,4 +20,5 @@ guardian-entity-taking-damage = Your guardian is taking damage! guardian-host-critical-warn = YOUR HOST IS WOUNDED! guardian-host-death-warn = YOUR FORM SUCCUMBS TO NONEXISTENCE! guardian-death-warn = YOUR BODY IS PIERCED BY SUBATOMIC PAIN AS IT DISINTEGRATES! +guardian-attack-host = You cannot attack your host.