add predicted popups with PVS filtering (#36092)

add
This commit is contained in:
Milon
2025-03-26 12:45:29 +01:00
committed by GitHub
parent 2f30fe3ceb
commit b97de9d603
3 changed files with 33 additions and 0 deletions

View File

@@ -237,6 +237,12 @@ namespace Content.Client.Popups
PopupEntity(message, uid, recipient.Value, type); 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) public override void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
{ {
if (recipient != null && _timing.IsFirstTimePredicted) if (recipient != null && _timing.IsFirstTimePredicted)

View 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) public override void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
{ {
PopupPredicted(othersMessage, uid, recipient, type); PopupPredicted(othersMessage, uid, recipient, type);

View File

@@ -114,6 +114,19 @@ namespace Content.Shared.Popups
/// </summary> /// </summary>
public abstract void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small); 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> /// <summary>
/// Variant of <see cref="PopupPredicted(string?, EntityUid, EntityUid?, PopupType)"/> that displays <paramref name="recipientMessage"/> /// 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. /// to the recipient and <paramref name="othersMessage"/> to everyone else in PVS range.