From 47a10c2499cecd30c663aef26d37486498245644 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 6 Jun 2022 09:04:40 +1000 Subject: [PATCH] Anchorable popups (#8667) --- .../Construction/AnchorableSystem.cs | 27 ++++++++++--------- .../en-US/anchorable/anchorable-component.ftl | 2 ++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 Resources/Locale/en-US/anchorable/anchorable-component.ftl diff --git a/Content.Server/Construction/AnchorableSystem.cs b/Content.Server/Construction/AnchorableSystem.cs index ec679fd5cb..61499a63f9 100644 --- a/Content.Server/Construction/AnchorableSystem.cs +++ b/Content.Server/Construction/AnchorableSystem.cs @@ -2,6 +2,7 @@ using System.Threading; using System.Threading.Tasks; using Content.Server.Administration.Logs; using Content.Server.Coordinates.Helpers; +using Content.Server.Popups; using Content.Server.Pulling; using Content.Server.Tools; using Content.Shared.Construction.Components; @@ -10,22 +11,24 @@ using Content.Shared.Database; using Content.Shared.Examine; using Content.Shared.Pulling.Components; using Content.Shared.Tools.Components; +using Robust.Shared.Player; namespace Content.Server.Construction { public sealed class AnchorableSystem : SharedAnchorableSystem { [Dependency] private readonly IAdminLogManager _adminLogger = default!; + [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly ToolSystem _toolSystem = default!; [Dependency] private readonly PullingSystem _pullingSystem = default!; public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnAnchorComplete2); - SubscribeLocalEvent(OnAnchorCancelled2); - SubscribeLocalEvent(OnUnanchorComplete2); - SubscribeLocalEvent(OnUnanchorCancelled2); + SubscribeLocalEvent(OnAnchorComplete); + SubscribeLocalEvent(OnAnchorCancelled); + SubscribeLocalEvent(OnUnanchorComplete); + SubscribeLocalEvent(OnUnanchorCancelled); SubscribeLocalEvent(OnAnchoredExamine); } @@ -36,22 +39,22 @@ namespace Content.Server.Construction args.PushMarkup(Loc.GetString(messageId, ("target", uid))); } - private void OnUnanchorCancelled2(EntityUid uid, AnchorableComponent component, TryUnanchorCancelledEvent args) + private void OnUnanchorCancelled(EntityUid uid, AnchorableComponent component, TryUnanchorCancelledEvent args) { component.CancelToken = null; } - private void OnUnanchorComplete2(EntityUid uid, AnchorableComponent component, TryUnanchorCompletedEvent args) + private void OnUnanchorComplete(EntityUid uid, AnchorableComponent component, TryUnanchorCompletedEvent args) { component.CancelToken = null; var xform = Transform(uid); RaiseLocalEvent(uid, new BeforeUnanchoredEvent(args.User, args.Using), false); - xform.Anchored = false; - RaiseLocalEvent(uid, new UserUnanchoredEvent(args.User, args.Using), false); + _popup.PopupEntity(Loc.GetString("anchorable-unanchored"), uid, Filter.Pvs(uid, entityManager: EntityManager)); + _adminLogger.Add( LogType.Action, LogImpact.Low, @@ -59,12 +62,12 @@ namespace Content.Server.Construction ); } - private void OnAnchorCancelled2(EntityUid uid, AnchorableComponent component, TryAnchorCancelledEvent args) + private void OnAnchorCancelled(EntityUid uid, AnchorableComponent component, TryAnchorCancelledEvent args) { component.CancelToken = null; } - private void OnAnchorComplete2(EntityUid uid, AnchorableComponent component, TryAnchorCompletedEvent args) + private void OnAnchorComplete(EntityUid uid, AnchorableComponent component, TryAnchorCompletedEvent args) { component.CancelToken = null; var xform = Transform(uid); @@ -82,11 +85,11 @@ namespace Content.Server.Construction xform.Coordinates = xform.Coordinates.SnapToGrid(); RaiseLocalEvent(uid, new BeforeAnchoredEvent(args.User, args.Using), false); - xform.Anchored = true; - RaiseLocalEvent(uid, new UserAnchoredEvent(args.User, args.Using), false); + _popup.PopupEntity(Loc.GetString("anchorable-anchored"), uid, Filter.Pvs(uid, entityManager: EntityManager)); + _adminLogger.Add( LogType.Action, LogImpact.Low, diff --git a/Resources/Locale/en-US/anchorable/anchorable-component.ftl b/Resources/Locale/en-US/anchorable/anchorable-component.ftl new file mode 100644 index 0000000000..9cc3b3c86c --- /dev/null +++ b/Resources/Locale/en-US/anchorable/anchorable-component.ftl @@ -0,0 +1,2 @@ +anchorable-anchored = Anchored +anchorable-unanchored = Unanchored \ No newline at end of file