Make popups nullable (#24802)

This standardises it with audio and whatever. Me when I sprinkle nullchecks everywhere.

Was 50/50 on making new non-nullable methods but figured it would bloat too hard and you can't access strings by .Value anyway.
This commit is contained in:
metalgearsloth
2024-02-02 15:25:58 +11:00
committed by GitHub
parent dfa86fbff8
commit 606c5a8c8b
3 changed files with 81 additions and 46 deletions

View File

@@ -13,70 +13,99 @@ namespace Content.Server.Popups
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly TransformSystem _xform = default!;
public override void PopupCursor(string message, PopupType type = PopupType.Small)
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)
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)
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)
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)
public override void PopupCoordinates(string? message, EntityCoordinates coordinates, PopupType type = PopupType.Small)
{
if (message == null)
return;
var mapPos = coordinates.ToMap(EntityManager, _xform);
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)
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)
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 PopupEntity(string message, EntityUid uid, PopupType type = PopupType.Small)
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)
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 uid, 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 PopupEntity(string message, EntityUid uid, ICommonSession 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)
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);
}
}