Files
wwdpublic/Content.Server/Popups/PopupSystem.cs
Cooper Wallace 8d7752467a 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 <CooperWallace@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
(cherry picked from commit e0d911bc4727c33f3cf68cb1cdce464a04a29d8b)
2026-02-11 18:44:33 +03:00

158 lines
6.5 KiB
C#

using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Player;
namespace Content.Server.Popups
{
public sealed class PopupSystem : SharedPopupSystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void PopupCursor(string? message, PopupType type = PopupType.Small)
{
// No local user.
}
public override void PopupCursor(string? message, ICommonSession recipient, PopupType type = PopupType.Small)
{
if (message == null)
return;
RaiseNetworkEvent(new PopupCursorEvent(message, type), recipient);
}
public override void PopupCursor(string? message, EntityUid recipient, PopupType type = PopupType.Small)
{
if (message == null)
return;
if (TryComp(recipient, out ActorComponent? actor))
RaiseNetworkEvent(new PopupCursorEvent(message, type), actor.PlayerSession);
}
public override void PopupCoordinates(string? message, EntityCoordinates coordinates, Filter filter, bool replayRecord, PopupType type = PopupType.Small)
{
if (message == null)
return;
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), filter, replayRecord);
}
public override void PopupCoordinates(string? message, EntityCoordinates coordinates, 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);
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), filter);
}
public override void PopupCoordinates(string? message, EntityCoordinates coordinates, ICommonSession recipient, PopupType type = PopupType.Small)
{
if (message == null)
return;
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), recipient);
}
public override void PopupCoordinates(string? message, EntityCoordinates coordinates, EntityUid recipient, PopupType type = PopupType.Small)
{
if (message == null)
return;
if (TryComp(recipient, out ActorComponent? actor))
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)
return;
var filter = Filter.Empty().AddPlayersByPvs(uid, entityManager: EntityManager, playerMan: _player, cfgMan: _cfg);
RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), filter);
}
public override void PopupEntity(string? message, EntityUid uid, EntityUid recipient, PopupType type = PopupType.Small)
{
if (message == null)
return;
if (TryComp(recipient, out ActorComponent? actor))
RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), actor.PlayerSession);
}
public override void PopupClient(string? message, EntityUid? recipient, PopupType type = PopupType.Small)
{
}
public override void PopupClient(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
{
// do nothing duh its for client only
}
public override void PopupClient(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small)
{
}
public override void PopupEntity(string? message, EntityUid uid, ICommonSession recipient, PopupType type = PopupType.Small)
{
if (message == null)
return;
RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), recipient);
}
public override void PopupEntity(string? message, EntityUid uid, Filter filter, bool recordReplay, PopupType type = PopupType.Small)
{
if (message == null)
return;
RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), filter, recordReplay);
}
public override void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
{
if (message == null)
return;
if (recipient != null)
{
// Don't send to recipient, since they predicted it locally
var filter = Filter.PvsExcept(recipient.Value, entityManager: EntityManager);
RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), filter);
}
else
{
// With no recipient, send to everyone (in PVS range)
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);
}
}
}