PopupSystem public methods rejig (#12830)

This commit is contained in:
Leon Friedrich
2022-12-19 10:41:47 +13:00
committed by GitHub
parent e459452333
commit 881a2b2ece
164 changed files with 721 additions and 631 deletions

View File

@@ -1,31 +1,78 @@
using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Players;
namespace Content.Server.Popups
{
public sealed class PopupSystem : SharedPopupSystem
{
public override void PopupCursor(string message, Filter filter, PopupType type=PopupType.Small)
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
public override void PopupCursor(string message, PopupType type = PopupType.Small)
{
// TODO REPLAYS
// add variants that take in a EntityUid or ICommonSession
// then remove any that send Filter.SinglePlayer() or single entity.
// then default to recording replays
// and manually remove any that shouldn't be replayed.
RaiseNetworkEvent(new PopupCursorEvent(message, type), filter);
// No local user.
}
public override void PopupCoordinates(string message, EntityCoordinates coordinates, Filter filter, PopupType type=PopupType.Small)
public override void PopupCursor(string message, ICommonSession recipient, PopupType type=PopupType.Small)
{
// TODO REPLAYS See above
RaiseNetworkEvent(new PopupCursorEvent(message, type), recipient);
}
public override void PopupCursor(string message, EntityUid recipient, PopupType type = PopupType.Small)
{
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)
{
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), filter, replayRecord);
}
public override void PopupCoordinates(string message, EntityCoordinates coordinates, PopupType type = PopupType.Small)
{
var mapPos = coordinates.ToMap(EntityManager);
var filter = Filter.Empty().AddPlayersByPvs(mapPos, entManager: EntityManager, playerMan: _player, cfgMan: _cfg);
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), filter);
}
public override void PopupEntity(string message, EntityUid uid, Filter filter, PopupType type=PopupType.Small)
public override void PopupCoordinates(string message, EntityCoordinates coordinates, ICommonSession recipient, PopupType type = PopupType.Small)
{
// TODO REPLAYS See above
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), recipient);
}
public override void PopupCoordinates(string message, EntityCoordinates coordinates, EntityUid recipient, PopupType type = PopupType.Small)
{
if (TryComp(recipient, out ActorComponent? actor))
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), actor.PlayerSession);
}
public override void PopupEntity(string message, EntityUid uid, PopupType type = PopupType.Small)
{
var filter = Filter.Empty().AddPlayersByPvs(uid, entityManager:EntityManager, playerMan: _player, cfgMan: _cfg);
RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), filter);
}
public override void PopupEntity(string message, EntityUid uid, EntityUid recipient, PopupType type=PopupType.Small)
{
if (TryComp(recipient, out ActorComponent? actor))
RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), actor.PlayerSession);
}
public override void PopupEntity(string message, EntityUid uid, ICommonSession recipient, PopupType type = PopupType.Small)
{
RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), recipient);
}
public override void PopupEntity(string message, EntityUid uid, Filter filter, bool recordReplay, PopupType type = PopupType.Small)
{
RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), filter, recordReplay);
}
}
}