Add two-message overload to PopupPredicted (#26907)

Added two-message overload to PopupPredicted
This commit is contained in:
Tayrtahn
2024-04-13 23:42:45 -04:00
committed by GitHub
parent f1d1e6c6fd
commit 9107d421bd
7 changed files with 31 additions and 12 deletions

View File

@@ -184,6 +184,12 @@ namespace Content.Client.Popups
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)
PopupEntity(recipientMessage, uid, recipient.Value, type);
}
#endregion
#region Network Event Handlers

View File

@@ -126,5 +126,10 @@ namespace Content.Server.Popups
RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)));
}
}
public override void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
{
PopupPredicted(othersMessage, uid, recipient, type);
}
}
}

View File

@@ -116,8 +116,9 @@ public sealed class BurialSystem : EntitySystem
{
if (used != null)
{
_popupSystem.PopupClient(Loc.GetString("grave-start-digging-user", ("grave", uid), ("tool", used)), user, user);
_popupSystem.PopupEntity(Loc.GetString("grave-start-digging-others", ("user", user), ("grave", uid), ("tool", used)), user, Filter.PvsExcept(user), true);
var selfMessage = Loc.GetString("grave-start-digging-user", ("grave", uid), ("tool", used));
var othersMessage = Loc.GetString("grave-start-digging-others", ("user", user), ("grave", uid), ("tool", used));
_popupSystem.PopupPredicted(selfMessage, othersMessage, user, user);
component.ActiveShovelDigging = true;
Dirty(uid, component);
}

View File

@@ -57,9 +57,11 @@ public sealed partial class BonkSystem : EntitySystem
if (user == source)
{
// Non-local, non-bonking players
_popupSystem.PopupEntity(Loc.GetString("bonkable-success-message-others", ("user", userName), ("bonkable", bonkableName)), user, Filter.PvsExcept(user), true);
var othersMessage = Loc.GetString("bonkable-success-message-others", ("user", userName), ("bonkable", bonkableName));
// Local, bonking player
_popupSystem.PopupClient(Loc.GetString("bonkable-success-message-user", ("user", userName), ("bonkable", bonkableName)), user, user);
var selfMessage = Loc.GetString("bonkable-success-message-user", ("user", userName), ("bonkable", bonkableName));
_popupSystem.PopupPredicted(selfMessage, othersMessage, user, user);
}
else if (source != null)
{

View File

@@ -307,8 +307,7 @@ public sealed partial class ClimbSystem : VirtualController
("climbable", climbable));
}
_popupSystem.PopupEntity(othersMessage, uid, Filter.PvsExcept(user, entityManager: EntityManager), true);
_popupSystem.PopupClient(selfMessage, uid, user);
_popupSystem.PopupPredicted(selfMessage, othersMessage, uid, user);
}
/// <summary>

View File

@@ -94,6 +94,12 @@ namespace Content.Shared.Popups
/// will do nothing and the server will show the message to every player in PVS range.
/// </summary>
public abstract void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, 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.
/// </summary>
public abstract void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small);
}
/// <summary>

View File

@@ -195,8 +195,9 @@ public sealed class WieldableSystem : EntitySystem
&& !_delay.TryResetDelay((used, useDelay), true))
return false;
_popupSystem.PopupClient(Loc.GetString("wieldable-component-successful-wield", ("item", used)), user, user);
_popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", user), ("item", used)), user, Filter.PvsExcept(user), true);
var selfMessage = Loc.GetString("wieldable-component-successful-wield", ("item", used));
var othersMessage = Loc.GetString("wieldable-component-successful-wield-other", ("user", user), ("item", used));
_popupSystem.PopupPredicted(selfMessage, othersMessage, user, user);
var targEv = new ItemWieldedEvent();
RaiseLocalEvent(used, ref targEv);
@@ -239,10 +240,9 @@ public sealed class WieldableSystem : EntitySystem
if (component.UnwieldSound != null)
_audioSystem.PlayPredicted(component.UnwieldSound, uid, args.User);
_popupSystem.PopupClient(Loc.GetString("wieldable-component-failed-wield",
("item", uid)), args.User.Value, args.User.Value);
_popupSystem.PopupEntity(Loc.GetString("wieldable-component-failed-wield-other",
("user", args.User.Value), ("item", uid)), args.User.Value, Filter.PvsExcept(args.User.Value), true);
var selfMessage = Loc.GetString("wieldable-component-failed-wield", ("item", uid));
var othersMessage = Loc.GetString("wieldable-component-failed-wield-other", ("user", args.User.Value), ("item", uid));
_popupSystem.PopupPredicted(selfMessage, othersMessage, args.User.Value, args.User.Value);
}
_appearance.SetData(uid, WieldableVisuals.Wielded, false);