From e0d911bc4727c33f3cf68cb1cdce464a04a29d8b Mon Sep 17 00:00:00 2001 From: Cooper Wallace <6856074+CooperWallace@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:47:10 -0700 Subject: [PATCH] Wizard Recall shows Disappearing text at Coordinate (#35272) * Add prediction for coordinate based popups * Remove use of deprecated EntityCoordinates.ToMap * RecallItem displays disppearing text at entity coordinates * Update Content.Shared/ItemRecall/SharedItemRecallSystem.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Content.Shared/Popups/SharedPopupSystem.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Add ItemRecall message for witnesses * Update Content.Shared/ItemRecall/SharedItemRecallSystem.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Resources/Locale/en-US/item-recall/item-recall.ftl Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Fix namespace issues * Fix Loc string * Dont fixstuff tired.. * Prefix THE * Filter around the entity, and remove recipient if needed * Alphabetical imports * Update Content.Client/Popups/PopupSystem.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * fixup * Better handling. --------- Co-authored-by: Cooper Wallace Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- Content.Client/Popups/PopupSystem.cs | 6 ++++++ Content.Server/Popups/PopupSystem.cs | 20 ++++++++++++++++--- .../ItemRecall/SharedItemRecallSystem.cs | 6 +++++- Content.Shared/Popups/SharedPopupSystem.cs | 7 +++++++ .../Locale/en-US/item-recall/item-recall.ftl | 4 +++- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index a249c9251b..38cad2d59c 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -123,6 +123,12 @@ namespace Content.Client.Popups PopupMessage(message, type, coordinates, null, true); } + public override void PopupPredictedCoordinates(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small) + { + if (recipient != null && _timing.IsFirstTimePredicted) + PopupCoordinates(message, coordinates, recipient.Value, type); + } + private void PopupCursorInternal(string? message, PopupType type, bool recordReplay) { if (message == null) diff --git a/Content.Server/Popups/PopupSystem.cs b/Content.Server/Popups/PopupSystem.cs index 4aa3d39224..22e4ae483a 100644 --- a/Content.Server/Popups/PopupSystem.cs +++ b/Content.Server/Popups/PopupSystem.cs @@ -11,7 +11,7 @@ namespace Content.Server.Popups { [Dependency] private readonly IPlayerManager _player = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; - [Dependency] private readonly TransformSystem _xform = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void PopupCursor(string? message, PopupType type = PopupType.Small) { @@ -47,8 +47,7 @@ namespace Content.Server.Popups { if (message == null) return; - - var mapPos = coordinates.ToMap(EntityManager, _xform); + var mapPos = _transform.ToMapCoordinates(coordinates); var filter = Filter.Empty().AddPlayersByPvs(mapPos, entManager: EntityManager, playerMan: _player, cfgMan: _cfg); RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), filter); } @@ -70,6 +69,21 @@ namespace Content.Server.Popups RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), actor.PlayerSession); } + public override void PopupPredictedCoordinates(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small) + { + if (message == null) + return; + + var mapPos = _transform.ToMapCoordinates(coordinates); + var filter = Filter.Empty().AddPlayersByPvs(mapPos, entManager: EntityManager, playerMan: _player, cfgMan: _cfg); + if (recipient != null) + { + // Don't send to recipient, since they predicted it locally + filter = filter.RemovePlayerByAttachedEntity(recipient.Value); + } + RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), filter); + } + public override void PopupEntity(string? message, EntityUid uid, PopupType type = PopupType.Small) { if (message == null) diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index a4a49e9708..aaedfb6c61 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -1,6 +1,7 @@ using Content.Shared.Actions; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; +using Content.Shared.IdentityManagement; using Content.Shared.Popups; using Content.Shared.Projectiles; using Robust.Shared.GameStates; @@ -83,7 +84,10 @@ public abstract partial class SharedItemRecallSystem : EntitySystem if (TryComp(ent, out var projectile)) _proj.EmbedDetach(ent, projectile, actionOwner.Value); - _popups.PopupPredicted(Loc.GetString("item-recall-item-summon", ("item", ent)), actionOwner.Value, actionOwner.Value); + _popups.PopupPredicted(Loc.GetString("item-recall-item-summon-self", ("item", ent)), + Loc.GetString("item-recall-item-summon-others", ("item", ent), ("name", Identity.Entity(actionOwner.Value, EntityManager))), + actionOwner.Value, actionOwner.Value); + _popups.PopupPredictedCoordinates(Loc.GetString("item-recall-item-disappear", ("item", ent)), Transform(ent).Coordinates, actionOwner.Value); _hands.TryForcePickupAnyHand(actionOwner.Value, ent); } diff --git a/Content.Shared/Popups/SharedPopupSystem.cs b/Content.Shared/Popups/SharedPopupSystem.cs index 38d2030cd5..1ce8efcdf1 100644 --- a/Content.Shared/Popups/SharedPopupSystem.cs +++ b/Content.Shared/Popups/SharedPopupSystem.cs @@ -58,6 +58,13 @@ namespace Content.Shared.Popups /// public abstract void PopupCoordinates(string? message, EntityCoordinates coordinates, ICommonSession recipient, PopupType type = PopupType.Small); + /// + /// Variant of for use with prediction. The local client will + /// the popup to the recipient, and the server will show it to every other player in PVS range. If recipient is null, the local + // client will do nothing and the server will show the message to every player in PVS range. + /// + public abstract void PopupPredictedCoordinates(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small); + /// /// Shows a popup above an entity for every player in pvs range. /// diff --git a/Resources/Locale/en-US/item-recall/item-recall.ftl b/Resources/Locale/en-US/item-recall/item-recall.ftl index 680c7b7b3f..2240442902 100644 --- a/Resources/Locale/en-US/item-recall/item-recall.ftl +++ b/Resources/Locale/en-US/item-recall/item-recall.ftl @@ -4,6 +4,8 @@ item-recall-marked-description = Recall {THE($item)} back into your hand. item-recall-item-marked = You draw a magical sigil on {THE($item)}. item-recall-item-already-marked = {CAPITALIZE(THE($item))} is already marked! item-recall-item-mark-empty = You must be holding an item! -item-recall-item-summon = {CAPITALIZE(THE($item))} appears in your hand! +item-recall-item-summon-self = {CAPITALIZE(THE($item))} appears in your hand! +item-recall-item-summon-others = {CAPITALIZE(THE($item))} appears in {THE($name)}'s hand! +item-recall-item-disappear = {CAPITALIZE(THE($item))} disappears! item-recall-item-unmark = You feel your connection with {THE($item)} sever.