]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add predicted popups with PVS filtering (#36092)
authorMilon <milonpl.git@proton.me>
Wed, 26 Mar 2025 11:45:29 +0000 (12:45 +0100)
committerGitHub <noreply@github.com>
Wed, 26 Mar 2025 11:45:29 +0000 (12:45 +0100)
add

Content.Client/Popups/PopupSystem.cs
Content.Server/Popups/PopupSystem.cs
Content.Shared/Popups/SharedPopupSystem.cs

index 38cad2d59cc802a120760fd478cb00be1383bb61..b0a3d9b21ed46d4855ae5eef31dd07652b3f2d26 100644 (file)
@@ -237,6 +237,12 @@ namespace Content.Client.Popups
                 PopupEntity(message, uid, recipient.Value, type);
         }
 
+        public override void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, Filter filter, bool recordReplay, PopupType type = PopupType.Small)
+        {
+            if (recipient != null && _timing.IsFirstTimePredicted)
+                PopupEntity(message, uid, recipient.Value, type);
+        }
+
         public override void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
         {
             if (recipient != null && _timing.IsFirstTimePredicted)
index 22e4ae483aef3a475ed253688a470d5c80c82f81..9338d81b924db4db2cb4edecf0d5211d97dc7ca4 100644 (file)
@@ -149,6 +149,20 @@ namespace Content.Server.Popups
             }
         }
 
+        public override void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, Filter filter, bool recordReplay, PopupType type = PopupType.Small)
+        {
+            if (message == null)
+                return;
+
+            if (recipient != null)
+            {
+                // Don't send to recipient, since they predicted it locally
+                filter = filter.RemovePlayerByAttachedEntity(recipient.Value);
+            }
+
+            RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), filter, recordReplay);
+        }
+
         public override void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
         {
             PopupPredicted(othersMessage, uid, recipient, type);
index 1ce8efcdf130d3061d931278f7b6d6af52e2996d..66f901c59f67ef6247033e2651342720e4b82dd6 100644 (file)
@@ -114,6 +114,19 @@ namespace Content.Shared.Popups
         /// </summary>
         public abstract void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small);
 
+        /// <summary>
+        /// Variant of <see cref="PopupEntity(string, EntityUid, Filter, bool, PopupType)"/> for use with prediction.
+        /// The local client will show the popup to the recipient, and the server will show it to players in the filter.
+        /// If recipient is null, the local client will do nothing and the server will show the message to players in the filter.
+        /// </summary>
+        /// <param name="message">The message to display.</param>
+        /// <param name="uid">The entity to display the popup above.</param>
+        /// <param name="recipient">The client that will see this popup locally during prediction.</param>
+        /// <param name="filter">Filter for players that will see the popup from the server.</param>
+        /// <param name="recordReplay">If true, this pop-up will be considered as a globally visible pop-up that gets shown during replays.</param>
+        /// <param name="type">Used to customize how this popup should appear visually. See: <see cref="PopupType"/>.</param>
+        public abstract void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, Filter filter, bool recordReplay, PopupType type = PopupType.Small);
+
         /// <summary>
         /// Variant of <see cref="PopupPredicted(string?, EntityUid, EntityUid?, PopupType)"/> that displays <paramref name="recipientMessage"/>
         /// to the recipient and <paramref name="othersMessage"/> to everyone else in PVS range.