Content update for UI prediction (#27214)
* Content update for UI refactor * Big update * Sharing * Remaining content updates * First big update * Prototype updates * AUGH * Fix UI comp ref * Cleanup - Fix predicted message, fix item slots, fix interaction range check. * Fix regressions * Make this predictive idk why it wasn't. * Fix slime merge * Merge conflict * Fix merge
This commit is contained in:
@@ -82,8 +82,8 @@ namespace Content.Server.Communications
|
||||
|
||||
comp.UIUpdateAccumulator -= UIUpdateInterval;
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, CommunicationsConsoleUiKey.Key, out var ui) && ui.SubscribedSessions.Count > 0)
|
||||
UpdateCommsConsoleInterface(uid, comp, ui);
|
||||
if (_uiSystem.IsUiOpen(uid, CommunicationsConsoleUiKey.Key))
|
||||
UpdateCommsConsoleInterface(uid, comp);
|
||||
}
|
||||
|
||||
base.Update(frameTime);
|
||||
@@ -136,11 +136,8 @@ namespace Content.Server.Communications
|
||||
/// <summary>
|
||||
/// Updates the UI for a particular comms console.
|
||||
/// </summary>
|
||||
public void UpdateCommsConsoleInterface(EntityUid uid, CommunicationsConsoleComponent comp, PlayerBoundUserInterface? ui = null)
|
||||
public void UpdateCommsConsoleInterface(EntityUid uid, CommunicationsConsoleComponent comp)
|
||||
{
|
||||
if (ui == null && !_uiSystem.TryGetUi(uid, CommunicationsConsoleUiKey.Key, out ui))
|
||||
return;
|
||||
|
||||
var stationUid = _stationSystem.GetOwningStation(uid);
|
||||
List<string>? levels = null;
|
||||
string currentLevel = default!;
|
||||
@@ -168,7 +165,7 @@ namespace Content.Server.Communications
|
||||
}
|
||||
}
|
||||
|
||||
_uiSystem.SetUiState(ui, new CommunicationsConsoleInterfaceState(
|
||||
_uiSystem.SetUiState(uid, CommunicationsConsoleUiKey.Key, new CommunicationsConsoleInterfaceState(
|
||||
CanAnnounce(comp),
|
||||
CanCallOrRecall(comp),
|
||||
levels,
|
||||
@@ -219,12 +216,12 @@ namespace Content.Server.Communications
|
||||
|
||||
private void OnSelectAlertLevelMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleSelectAlertLevelMessage message)
|
||||
{
|
||||
if (message.Session.AttachedEntity is not { Valid: true } mob)
|
||||
if (message.Actor is not { Valid: true } mob)
|
||||
return;
|
||||
|
||||
if (!CanUse(mob, uid))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("comms-console-permission-denied"), message.Session, PopupType.Medium);
|
||||
_popupSystem.PopupCursor(Loc.GetString("comms-console-permission-denied"), message.Actor, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -241,7 +238,7 @@ namespace Content.Server.Communications
|
||||
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
|
||||
var msg = SharedChatSystem.SanitizeAnnouncement(message.Message, maxLength);
|
||||
var author = Loc.GetString("comms-console-announcement-unknown-sender");
|
||||
if (message.Session.AttachedEntity is { Valid: true } mob)
|
||||
if (message.Actor is { Valid: true } mob)
|
||||
{
|
||||
if (!CanAnnounce(comp))
|
||||
{
|
||||
@@ -250,7 +247,7 @@ namespace Content.Server.Communications
|
||||
|
||||
if (!CanUse(mob, uid))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Actor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,7 +260,7 @@ namespace Content.Server.Communications
|
||||
comp.AnnouncementCooldownRemaining = comp.Delay;
|
||||
UpdateCommsConsoleInterface(uid, comp);
|
||||
|
||||
var ev = new CommunicationConsoleAnnouncementEvent(uid, comp, msg, message.Session.AttachedEntity);
|
||||
var ev = new CommunicationConsoleAnnouncementEvent(uid, comp, msg, message.Actor);
|
||||
RaiseLocalEvent(ref ev);
|
||||
|
||||
// allow admemes with vv
|
||||
@@ -275,15 +272,14 @@ namespace Content.Server.Communications
|
||||
{
|
||||
_chatSystem.DispatchGlobalAnnouncement(msg, title, announcementSound: comp.Sound, colorOverride: comp.Color);
|
||||
|
||||
if (message.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following global announcement: {msg}");
|
||||
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Actor):player} has sent the following global announcement: {msg}");
|
||||
return;
|
||||
}
|
||||
|
||||
_chatSystem.DispatchStationAnnouncement(uid, msg, title, colorOverride: comp.Color);
|
||||
|
||||
if (message.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following station announcement: {msg}");
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Actor):player} has sent the following station announcement: {msg}");
|
||||
|
||||
}
|
||||
|
||||
private void OnBroadcastMessage(EntityUid uid, CommunicationsConsoleComponent component, CommunicationsConsoleBroadcastMessage message)
|
||||
@@ -298,8 +294,7 @@ namespace Content.Server.Communications
|
||||
|
||||
_deviceNetworkSystem.QueuePacket(uid, null, payload, net.TransmitFrequency);
|
||||
|
||||
if (message.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.DeviceNetwork, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following broadcast: {message.Message:msg}");
|
||||
_adminLogger.Add(LogType.DeviceNetwork, LogImpact.Low, $"{ToPrettyString(message.Actor):player} has sent the following broadcast: {message.Message:msg}");
|
||||
}
|
||||
|
||||
private void OnCallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleCallEmergencyShuttleMessage message)
|
||||
@@ -307,12 +302,11 @@ namespace Content.Server.Communications
|
||||
if (!CanCallOrRecall(comp))
|
||||
return;
|
||||
|
||||
if (message.Session.AttachedEntity is not { Valid: true } mob)
|
||||
return;
|
||||
var mob = message.Actor;
|
||||
|
||||
if (!CanUse(mob, uid))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Actor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -320,7 +314,7 @@ namespace Content.Server.Communications
|
||||
RaiseLocalEvent(ref ev);
|
||||
if (ev.Cancelled)
|
||||
{
|
||||
_popupSystem.PopupEntity(ev.Reason ?? Loc.GetString("comms-console-shuttle-unavailable"), uid, message.Session);
|
||||
_popupSystem.PopupEntity(ev.Reason ?? Loc.GetString("comms-console-shuttle-unavailable"), uid, message.Actor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -333,17 +327,14 @@ namespace Content.Server.Communications
|
||||
if (!CanCallOrRecall(comp))
|
||||
return;
|
||||
|
||||
if (message.Session.AttachedEntity is not { Valid: true } mob)
|
||||
return;
|
||||
|
||||
if (!CanUse(mob, uid))
|
||||
if (!CanUse(message.Actor, uid))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Session);
|
||||
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Actor);
|
||||
return;
|
||||
}
|
||||
|
||||
_roundEndSystem.CancelRoundEndCountdown(uid);
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(mob):player} has recalled the shuttle.");
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(message.Actor):player} has recalled the shuttle.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user