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:
@@ -89,7 +89,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
continue;
|
||||
|
||||
//The network configurator is a handheld device. There can only ever be an ui session open for the player holding the device.
|
||||
_uiSystem.TryCloseAll(uid, NetworkConfiguratorUiKey.Configure);
|
||||
_uiSystem.CloseUi(uid, NetworkConfiguratorUiKey.Configure);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
|
||||
private void OnComponentRemoved(EntityUid uid, DeviceListComponent component, ComponentRemove args)
|
||||
{
|
||||
_uiSystem.TryCloseAll(uid, NetworkConfiguratorUiKey.Configure);
|
||||
_uiSystem.CloseUi(uid, NetworkConfiguratorUiKey.Configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -433,7 +433,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
return;
|
||||
|
||||
|
||||
_uiSystem.TryOpen(configuratorUid, NetworkConfiguratorUiKey.Link, actor.PlayerSession);
|
||||
_uiSystem.OpenUi(configuratorUid, NetworkConfiguratorUiKey.Link, actor.PlayerSession);
|
||||
configurator.DeviceLinkTarget = targetUid;
|
||||
|
||||
|
||||
@@ -464,7 +464,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
var sinkAddress = Resolve(sinkUid, ref sinkNetworkComponent, false) ? sinkNetworkComponent.Address : "";
|
||||
|
||||
var state = new DeviceLinkUserInterfaceState(sources, sinks, links, sourceAddress, sinkAddress, defaults);
|
||||
_uiSystem.TrySetUiState(configuratorUid, NetworkConfiguratorUiKey.Link, state);
|
||||
_uiSystem.SetUiState(configuratorUid, NetworkConfiguratorUiKey.Link, state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -478,7 +478,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
if (Delay(configurator))
|
||||
return;
|
||||
|
||||
if (!targetUid.HasValue || !TryComp(userUid, out ActorComponent? actor) || !AccessCheck(targetUid.Value, userUid, configurator))
|
||||
if (!targetUid.HasValue || !AccessCheck(targetUid.Value, userUid, configurator))
|
||||
return;
|
||||
|
||||
if (!TryComp(targetUid, out DeviceListComponent? list))
|
||||
@@ -488,14 +488,13 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
configurator.ActiveDeviceList = targetUid;
|
||||
Dirty(configuratorUid, configurator);
|
||||
|
||||
if (!_uiSystem.TryGetUi(configuratorUid, NetworkConfiguratorUiKey.Configure, out var bui))
|
||||
return;
|
||||
|
||||
if (_uiSystem.OpenUi(bui, actor.PlayerSession))
|
||||
_uiSystem.SetUiState(bui, new DeviceListUserInterfaceState(
|
||||
if (_uiSystem.TryOpenUi(configuratorUid, NetworkConfiguratorUiKey.Configure, userUid))
|
||||
{
|
||||
_uiSystem.SetUiState(configuratorUid, NetworkConfiguratorUiKey.Configure, new DeviceListUserInterfaceState(
|
||||
_deviceListSystem.GetDeviceList(configurator.ActiveDeviceList.Value)
|
||||
.Select(v => (v.Key, MetaData(v.Value).EntityName)).ToHashSet()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -523,8 +522,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
component.Devices.Remove(invalidDevice);
|
||||
}
|
||||
|
||||
if (_uiSystem.TryGetUi(uid, NetworkConfiguratorUiKey.List, out var bui))
|
||||
_uiSystem.SetUiState(bui, new NetworkConfiguratorUserInterfaceState(devices));
|
||||
_uiSystem.SetUiState(uid, NetworkConfiguratorUiKey.List, new NetworkConfiguratorUserInterfaceState(devices));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -565,10 +563,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
/// </summary>
|
||||
private void OnRemoveDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorRemoveDeviceMessage args)
|
||||
{
|
||||
if (component.Devices.TryGetValue(args.Address, out var removedDevice) && args.Session.AttachedEntity != null)
|
||||
if (component.Devices.TryGetValue(args.Address, out var removedDevice))
|
||||
{
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} removed buffered device {ToPrettyString(removedDevice):subject} from {ToPrettyString(uid):tool}");
|
||||
$"{ToPrettyString(args.Actor):actor} removed buffered device {ToPrettyString(removedDevice):subject} from {ToPrettyString(uid):tool}");
|
||||
}
|
||||
|
||||
component.Devices.Remove(args.Address);
|
||||
@@ -583,10 +581,8 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
/// </summary>
|
||||
private void OnClearDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorClearDevicesMessage args)
|
||||
{
|
||||
if (args.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} cleared buffered devices from {ToPrettyString(uid):tool}");
|
||||
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Actor):actor} cleared buffered devices from {ToPrettyString(uid):tool}");
|
||||
|
||||
ClearDevices(uid, component);
|
||||
UpdateListUiState(uid, component);
|
||||
@@ -609,9 +605,8 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
if (!configurator.ActiveDeviceLink.HasValue || !configurator.DeviceLinkTarget.HasValue)
|
||||
return;
|
||||
|
||||
if (args.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} cleared links between {ToPrettyString(configurator.ActiveDeviceLink.Value):subject} and {ToPrettyString(configurator.DeviceLinkTarget.Value):subject2} with {ToPrettyString(uid):tool}");
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Actor):actor} cleared links between {ToPrettyString(configurator.ActiveDeviceLink.Value):subject} and {ToPrettyString(configurator.DeviceLinkTarget.Value):subject2} with {ToPrettyString(uid):tool}");
|
||||
|
||||
if (HasComp<DeviceLinkSourceComponent>(configurator.ActiveDeviceLink) && HasComp<DeviceLinkSinkComponent>(configurator.DeviceLinkTarget))
|
||||
{
|
||||
@@ -649,7 +644,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSourceComponent? activeSource) && TryComp(configurator.DeviceLinkTarget, out DeviceLinkSinkComponent? targetSink))
|
||||
{
|
||||
_deviceLinkSystem.ToggleLink(
|
||||
args.Session.AttachedEntity,
|
||||
args.Actor,
|
||||
configurator.ActiveDeviceLink.Value,
|
||||
configurator.DeviceLinkTarget.Value,
|
||||
args.Source, args.Sink,
|
||||
@@ -660,7 +655,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
else if (TryComp(configurator.DeviceLinkTarget, out DeviceLinkSourceComponent? targetSource) && TryComp(configurator.ActiveDeviceLink, out DeviceLinkSinkComponent? activeSink))
|
||||
{
|
||||
_deviceLinkSystem.ToggleLink(
|
||||
args.Session.AttachedEntity,
|
||||
args.Actor,
|
||||
configurator.DeviceLinkTarget.Value,
|
||||
configurator.ActiveDeviceLink.Value,
|
||||
args.Source, args.Sink,
|
||||
@@ -687,7 +682,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSourceComponent? activeSource) && TryComp(configurator.DeviceLinkTarget, out DeviceLinkSinkComponent? targetSink))
|
||||
{
|
||||
_deviceLinkSystem.SaveLinks(
|
||||
args.Session.AttachedEntity,
|
||||
args.Actor,
|
||||
configurator.ActiveDeviceLink.Value,
|
||||
configurator.DeviceLinkTarget.Value,
|
||||
args.Links,
|
||||
@@ -705,7 +700,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
else if (TryComp(configurator.DeviceLinkTarget, out DeviceLinkSourceComponent? targetSource) && TryComp(configurator.ActiveDeviceLink, out DeviceLinkSinkComponent? activeSink))
|
||||
{
|
||||
_deviceLinkSystem.SaveLinks(
|
||||
args.Session.AttachedEntity,
|
||||
args.Actor,
|
||||
configurator.DeviceLinkTarget.Value,
|
||||
configurator.ActiveDeviceLink.Value,
|
||||
args.Links,
|
||||
@@ -735,29 +730,25 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
switch (args.ButtonKey)
|
||||
{
|
||||
case NetworkConfiguratorButtonKey.Set:
|
||||
if (args.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} set device links to {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Actor):actor} set device links to {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||
|
||||
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>(component.Devices.Values));
|
||||
break;
|
||||
case NetworkConfiguratorButtonKey.Add:
|
||||
if (args.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} added device links to {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Actor):actor} added device links to {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||
|
||||
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>(component.Devices.Values), true);
|
||||
break;
|
||||
case NetworkConfiguratorButtonKey.Clear:
|
||||
if (args.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} cleared device links from {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Actor):actor} cleared device links from {ToPrettyString(component.ActiveDeviceList.Value):subject} with {ToPrettyString(uid):tool}");
|
||||
result = _deviceListSystem.UpdateDeviceList(component.ActiveDeviceList.Value, new HashSet<EntityUid>());
|
||||
break;
|
||||
case NetworkConfiguratorButtonKey.Copy:
|
||||
if (args.Session.AttachedEntity != null)
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} copied devices from {ToPrettyString(component.ActiveDeviceList.Value):subject} to {ToPrettyString(uid):tool}");
|
||||
_adminLogger.Add(LogType.DeviceLinking, LogImpact.Low,
|
||||
$"{ToPrettyString(args.Actor):actor} copied devices from {ToPrettyString(component.ActiveDeviceList.Value):subject} to {ToPrettyString(uid):tool}");
|
||||
|
||||
ClearDevices(uid, component);
|
||||
|
||||
@@ -783,8 +774,8 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
_ => "error"
|
||||
};
|
||||
|
||||
_popupSystem.PopupCursor(Loc.GetString(resultText), args.Session, PopupType.Medium);
|
||||
_uiSystem.TrySetUiState(
|
||||
_popupSystem.PopupCursor(Loc.GetString(resultText), args.Actor, PopupType.Medium);
|
||||
_uiSystem.SetUiState(
|
||||
uid,
|
||||
NetworkConfiguratorUiKey.Configure,
|
||||
new DeviceListUserInterfaceState(
|
||||
|
||||
Reference in New Issue
Block a user