]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Wizard Recall shows Disappearing text at Coordinate (#35272)
authorCooper Wallace <6856074+CooperWallace@users.noreply.github.com>
Wed, 19 Feb 2025 01:47:10 +0000 (18:47 -0700)
committerGitHub <noreply@github.com>
Wed, 19 Feb 2025 01:47:10 +0000 (20:47 -0500)
* 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 <CooperWallace@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Client/Popups/PopupSystem.cs
Content.Server/Popups/PopupSystem.cs
Content.Shared/ItemRecall/SharedItemRecallSystem.cs
Content.Shared/Popups/SharedPopupSystem.cs
Resources/Locale/en-US/item-recall/item-recall.ftl

index a249c9251bf0fa60853f9c13fe7efb90229aa5f1..38cad2d59cc802a120760fd478cb00be1383bb61 100644 (file)
@@ -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)
index 4aa3d39224cfd887da22fcafef1850b112baf72f..22e4ae483aef3a475ed253688a470d5c80c82f81 100644 (file)
@@ -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)
index a4a49e97088442a1c3ef57efe697065a3cf37236..aaedfb6c61850da5ffb6240de1b79534c3384fd4 100644 (file)
@@ -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<EmbeddableProjectileComponent>(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);
     }
index 38d2030cd5a039f74fc0b464699f9d10a4bea8dd..1ce8efcdf130d3061d931278f7b6d6af52e2996d 100644 (file)
@@ -58,6 +58,13 @@ namespace Content.Shared.Popups
         /// </summary>
         public abstract void PopupCoordinates(string? message, EntityCoordinates coordinates, ICommonSession recipient, PopupType type = PopupType.Small);
 
+        /// <summary>
+        ///    Variant of <see cref="PopupCoordinates(string, EntityCoordinates, PopupType)"/> 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.
+        /// </summary>
+        public abstract void PopupPredictedCoordinates(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small);
+
         /// <summary>
         ///     Shows a popup above an entity for every player in pvs range.
         /// </summary>
index 680c7b7b3fb763733b9f1dd5c1a63b3195bce7ad..2240442902e120470e799b47fe1ba73c81e9aee6 100644 (file)
@@ -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.