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:
metalgearsloth
2024-04-26 18:16:24 +10:00
committed by GitHub
parent 32b81de8c5
commit 5896e68752
279 changed files with 1308 additions and 1582 deletions

View File

@@ -3,7 +3,7 @@ using Robust.Shared.GameStates;
namespace Content.Client.Administration.Components; namespace Content.Client.Administration.Components;
[RegisterComponent, NetworkedComponent] [RegisterComponent]
public sealed partial class HeadstandComponent : SharedHeadstandComponent public sealed partial class HeadstandComponent : SharedHeadstandComponent
{ {

View File

@@ -3,6 +3,5 @@ using Robust.Shared.GameStates;
namespace Content.Client.Administration.Components; namespace Content.Client.Administration.Components;
[NetworkedComponent, RegisterComponent] [RegisterComponent]
public sealed partial class KillSignComponent : SharedKillSignComponent public sealed partial class KillSignComponent : SharedKillSignComponent;
{ }

View File

@@ -11,6 +11,7 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
[Dependency] private readonly IPrototypeManager _protoManager = default!; [Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly AnimationPlayerSystem _animationPlayer = default!; [Dependency] private readonly AnimationPlayerSystem _animationPlayer = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -35,13 +36,10 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
var query = AllEntityQuery<JukeboxComponent, UserInterfaceComponent>(); var query = AllEntityQuery<JukeboxComponent, UserInterfaceComponent>();
while (query.MoveNext(out _, out var ui)) while (query.MoveNext(out var uid, out _, out var ui))
{
if (!ui.OpenInterfaces.TryGetValue(JukeboxUiKey.Key, out var baseBui) ||
baseBui is not JukeboxBoundUserInterface bui)
{ {
if (!_uiSystem.TryGetOpenUi<JukeboxBoundUserInterface>((uid, ui), JukeboxUiKey.Key, out var bui))
continue; continue;
}
bui.PopulateMusic(); bui.PopulateMusic();
} }
@@ -49,15 +47,9 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
private void OnJukeboxAfterState(Entity<JukeboxComponent> ent, ref AfterAutoHandleStateEvent args) private void OnJukeboxAfterState(Entity<JukeboxComponent> ent, ref AfterAutoHandleStateEvent args)
{ {
if (!TryComp(ent, out UserInterfaceComponent? ui)) if (!_uiSystem.TryGetOpenUi<JukeboxBoundUserInterface>(ent.Owner, JukeboxUiKey.Key, out var bui))
return; return;
if (!ui.OpenInterfaces.TryGetValue(JukeboxUiKey.Key, out var baseBui) ||
baseBui is not JukeboxBoundUserInterface bui)
{
return;
}
bui.Reload(); bui.Reload();
} }

View File

@@ -3,7 +3,5 @@ using Robust.Shared.GameStates;
namespace Content.Client.Extinguisher; namespace Content.Client.Extinguisher;
[NetworkedComponent, RegisterComponent] [RegisterComponent]
public sealed partial class FireExtinguisherComponent : SharedFireExtinguisherComponent public sealed partial class FireExtinguisherComponent : SharedFireExtinguisherComponent;
{
}

View File

@@ -21,7 +21,6 @@ namespace Content.Client.PDA
protected override void Open() protected override void Open()
{ {
base.Open(); base.Open();
SendMessage(new PdaRequestUpdateInterfaceMessage());
_menu = new PdaMenu(); _menu = new PdaMenu();
_menu.OpenCenteredLeft(); _menu.OpenCenteredLeft();
_menu.OnClose += Close; _menu.OnClose += Close;
@@ -32,17 +31,17 @@ namespace Content.Client.PDA
_menu.EjectIdButton.OnPressed += _ => _menu.EjectIdButton.OnPressed += _ =>
{ {
SendMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaIdSlotId)); SendPredictedMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaIdSlotId));
}; };
_menu.EjectPenButton.OnPressed += _ => _menu.EjectPenButton.OnPressed += _ =>
{ {
SendMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaPenSlotId)); SendPredictedMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaPenSlotId));
}; };
_menu.EjectPaiButton.OnPressed += _ => _menu.EjectPaiButton.OnPressed += _ =>
{ {
SendMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaPaiSlotId)); SendPredictedMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaPaiSlotId));
}; };
_menu.ActivateMusicButton.OnPressed += _ => _menu.ActivateMusicButton.OnPressed += _ =>

View File

@@ -1,9 +1,6 @@
using Content.Shared.Paper; using Content.Shared.Paper;
using Robust.Shared.GameStates;
namespace Content.Client.Paper; namespace Content.Client.Paper;
[NetworkedComponent, RegisterComponent] [RegisterComponent]
public sealed partial class PaperComponent : SharedPaperComponent public sealed partial class PaperComponent : SharedPaperComponent;
{
}

View File

@@ -0,0 +1,21 @@
using Content.Shared.Power.Components;
using Content.Shared.UserInterface;
using Content.Shared.Wires;
namespace Content.Client.Power;
public sealed class ActivatableUIRequiresPowerSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ActivatableUIRequiresPowerComponent, ActivatableUIOpenAttemptEvent>(OnActivate);
}
private void OnActivate(EntityUid uid, ActivatableUIRequiresPowerComponent component, ActivatableUIOpenAttemptEvent args)
{
// Client can't predict the power properly at the moment so rely upon the server to do it.
args.Cancel();
}
}

View File

@@ -17,6 +17,14 @@ public sealed class StorageBoundUserInterface : BoundUserInterface
_storage = _entManager.System<StorageSystem>(); _storage = _entManager.System<StorageSystem>();
} }
protected override void Open()
{
base.Open();
if (_entManager.TryGetComponent<StorageComponent>(Owner, out var comp))
_storage.OpenStorageWindow((Owner, comp));
}
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
@@ -25,16 +33,5 @@ public sealed class StorageBoundUserInterface : BoundUserInterface
_storage.CloseStorageWindow(Owner); _storage.CloseStorageWindow(Owner);
} }
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
base.ReceiveMessage(message);
if (message is StorageModifyWindowMessage)
{
if (_entManager.TryGetComponent<StorageComponent>(Owner, out var comp))
_storage.OpenStorageWindow((Owner, comp));
}
}
} }

View File

@@ -111,7 +111,7 @@ public sealed class StorageSystem : SharedStorageSystem
if (!Resolve(entity, ref entity.Comp, false)) if (!Resolve(entity, ref entity.Comp, false))
return; return;
if (entity.Comp.OpenInterfaces.GetValueOrDefault(StorageComponent.StorageUiKey.Key) is not { } bui) if (entity.Comp.ClientOpenInterfaces.GetValueOrDefault(StorageComponent.StorageUiKey.Key) is not { } bui)
return; return;
bui.Close(); bui.Close();

View File

@@ -35,7 +35,7 @@ public sealed class StrippableSystem : SharedStrippableSystem
if (!TryComp(uid, out UserInterfaceComponent? uiComp)) if (!TryComp(uid, out UserInterfaceComponent? uiComp))
return; return;
foreach (var ui in uiComp.OpenInterfaces.Values) foreach (var ui in uiComp.ClientOpenInterfaces.Values)
{ {
if (ui is StrippableBoundUserInterface stripUi) if (ui is StrippableBoundUserInterface stripUi)
stripUi.DirtyMenu(); stripUi.DirtyMenu();

View File

@@ -262,7 +262,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
} }
else if (args.Function == ContentKeyFunctions.ActivateItemInWorld) else if (args.Function == ContentKeyFunctions.ActivateItemInWorld)
{ {
_entity.EntityNetManager?.SendSystemNetworkMessage( _entity.RaisePredictiveEvent(
new InteractInventorySlotEvent(_entity.GetNetEntity(control.Entity), altInteract: false)); new InteractInventorySlotEvent(_entity.GetNetEntity(control.Entity), altInteract: false));
args.Handle(); args.Handle();
} }

View File

@@ -820,7 +820,7 @@ public abstract partial class InteractionTest
return false; return false;
} }
if (!ui.OpenInterfaces.TryGetValue(key, out bui)) if (!ui.ClientOpenInterfaces.TryGetValue(key, out bui))
{ {
if (shouldSucceed) if (shouldSucceed)
Assert.Fail($"Entity {SEntMan.ToPrettyString(SEntMan.GetEntity(target.Value))} does not have an open bui with key {key.GetType()}.{key}."); Assert.Fail($"Entity {SEntMan.ToPrettyString(SEntMan.GetEntity(target.Value))} does not have an open bui with key {key.GetType()}.{key}.");

View File

@@ -143,7 +143,7 @@ namespace Content.IntegrationTests.Tests.Power
anchored: true anchored: true
- type: UserInterface - type: UserInterface
interfaces: interfaces:
- key: enum.ApcUiKey.Key enum.ApcUiKey.Key:
type: ApcBoundUserInterface type: ApcBoundUserInterface
- type: AccessReader - type: AccessReader
access: [['Engineering']] access: [['Engineering']]

View File

@@ -68,16 +68,13 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem
private void OnDoAfter(EntityUid uid, AccessOverriderComponent component, AccessOverriderDoAfterEvent args) private void OnDoAfter(EntityUid uid, AccessOverriderComponent component, AccessOverriderDoAfterEvent args)
{ {
if (!TryComp(args.User, out ActorComponent? actor))
return;
if (args.Handled || args.Cancelled) if (args.Handled || args.Cancelled)
return; return;
if (args.Args.Target != null) if (args.Args.Target != null)
{ {
component.TargetAccessReaderId = args.Args.Target.Value; component.TargetAccessReaderId = args.Args.Target.Value;
_userInterface.TryOpen(uid, AccessOverriderUiKey.Key, actor.PlayerSession); _userInterface.OpenUi(uid, AccessOverriderUiKey.Key, args.User);
UpdateUserInterface(uid, component, args); UpdateUserInterface(uid, component, args);
} }
@@ -94,7 +91,7 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem
private void OnWriteToTargetAccessReaderIdMessage(EntityUid uid, AccessOverriderComponent component, WriteToTargetAccessReaderIdMessage args) private void OnWriteToTargetAccessReaderIdMessage(EntityUid uid, AccessOverriderComponent component, WriteToTargetAccessReaderIdMessage args)
{ {
if (args.Session.AttachedEntity is not { Valid: true } player) if (args.Actor is not { Valid: true } player)
return; return;
TryWriteToTargetAccessReaderId(uid, args.AccessList, player, component); TryWriteToTargetAccessReaderId(uid, args.AccessList, player, component);
@@ -154,22 +151,19 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem
targetLabel, targetLabel,
targetLabelColor); targetLabelColor);
_userInterface.TrySetUiState(uid, AccessOverriderUiKey.Key, newState); _userInterface.SetUiState(uid, AccessOverriderUiKey.Key, newState);
} }
private List<ProtoId<AccessLevelPrototype>> ConvertAccessHashSetsToList(List<HashSet<ProtoId<AccessLevelPrototype>>> accessHashsets) private List<ProtoId<AccessLevelPrototype>> ConvertAccessHashSetsToList(List<HashSet<ProtoId<AccessLevelPrototype>>> accessHashsets)
{ {
List<ProtoId<AccessLevelPrototype>> accessList = new List<ProtoId<AccessLevelPrototype>>(); var accessList = new List<ProtoId<AccessLevelPrototype>>();
if (accessHashsets != null && accessHashsets.Any()) if (accessHashsets.Count <= 0)
return accessList;
foreach (var hashSet in accessHashsets)
{ {
foreach (HashSet<ProtoId<AccessLevelPrototype>> hashSet in accessHashsets) accessList.AddRange(hashSet);
{
foreach (ProtoId<AccessLevelPrototype> hash in hashSet.ToArray())
{
accessList.Add(hash);
}
}
} }
return accessList; return accessList;

View File

@@ -61,14 +61,14 @@ namespace Content.Server.Access.Systems
private void AfterUIOpen(EntityUid uid, AgentIDCardComponent component, AfterActivatableUIOpenEvent args) private void AfterUIOpen(EntityUid uid, AgentIDCardComponent component, AfterActivatableUIOpenEvent args)
{ {
if (!_uiSystem.TryGetUi(uid, AgentIDCardUiKey.Key, out var ui)) if (!_uiSystem.HasUi(uid, AgentIDCardUiKey.Key))
return; return;
if (!TryComp<IdCardComponent>(uid, out var idCard)) if (!TryComp<IdCardComponent>(uid, out var idCard))
return; return;
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", component.Icons); var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", component.Icons);
_uiSystem.SetUiState(ui, state, args.Session); _uiSystem.SetUiState(uid, AgentIDCardUiKey.Key, state);
} }
private void OnJobChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobChangedMessage args) private void OnJobChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobChangedMessage args)

View File

@@ -41,7 +41,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
private void OnWriteToTargetIdMessage(EntityUid uid, IdCardConsoleComponent component, WriteToTargetIdMessage args) private void OnWriteToTargetIdMessage(EntityUid uid, IdCardConsoleComponent component, WriteToTargetIdMessage args)
{ {
if (args.Session.AttachedEntity is not { Valid: true } player) if (args.Actor is not { Valid: true } player)
return; return;
TryWriteToTargetId(uid, args.FullName, args.JobTitle, args.AccessList, args.JobPrototype, player, component); TryWriteToTargetId(uid, args.FullName, args.JobTitle, args.AccessList, args.JobPrototype, player, component);
@@ -104,7 +104,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
Name(targetId)); Name(targetId));
} }
_userInterface.TrySetUiState(uid, IdCardConsoleUiKey.Key, newState); _userInterface.SetUiState(uid, IdCardConsoleUiKey.Key, newState);
} }
/// <summary> /// <summary>

View File

@@ -3,7 +3,7 @@ using Robust.Shared.GameStates;
namespace Content.Server.Administration.Components; namespace Content.Server.Administration.Components;
[RegisterComponent, NetworkedComponent] [RegisterComponent]
public sealed partial class HeadstandComponent : SharedHeadstandComponent public sealed partial class HeadstandComponent : SharedHeadstandComponent
{ {

View File

@@ -3,6 +3,5 @@ using Robust.Shared.GameStates;
namespace Content.Server.Administration.Components; namespace Content.Server.Administration.Components;
[NetworkedComponent, RegisterComponent] [RegisterComponent]
public sealed partial class KillSignComponent : SharedKillSignComponent public sealed partial class KillSignComponent : SharedKillSignComponent;
{ }

View File

@@ -463,7 +463,7 @@ namespace Content.Server.Administration.Systems
Text = Loc.GetString("configure-verb-get-data-text"), Text = Loc.GetString("configure-verb-get-data-text"),
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")), Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
Category = VerbCategory.Debug, Category = VerbCategory.Debug,
Act = () => _uiSystem.TryOpen(args.Target, ConfigurationUiKey.Key, actor.PlayerSession) Act = () => _uiSystem.OpenUi(args.Target, ConfigurationUiKey.Key, actor.PlayerSession)
}; };
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }

View File

@@ -4,6 +4,7 @@ using Content.Server.UserInterface;
using Content.Shared.Advertise; using Content.Shared.Advertise;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
using ActivatableUIComponent = Content.Shared.UserInterface.ActivatableUIComponent;
namespace Content.Server.Advertise; namespace Content.Server.Advertise;

View File

@@ -129,11 +129,11 @@ public sealed class AmeControllerSystem : EntitySystem
if (!Resolve(uid, ref controller)) if (!Resolve(uid, ref controller))
return; return;
if (!_userInterfaceSystem.TryGetUi(uid, AmeControllerUiKey.Key, out var bui)) if (!_userInterfaceSystem.HasUi(uid, AmeControllerUiKey.Key))
return; return;
var state = GetUiState(uid, controller); var state = GetUiState(uid, controller);
_userInterfaceSystem.SetUiState(bui, state); _userInterfaceSystem.SetUiState(uid, AmeControllerUiKey.Key, state);
controller.NextUIUpdate = _gameTiming.CurTime + controller.UpdateUIPeriod; controller.NextUIUpdate = _gameTiming.CurTime + controller.UpdateUIPeriod;
} }
@@ -324,7 +324,7 @@ public sealed class AmeControllerSystem : EntitySystem
private void OnUiButtonPressed(EntityUid uid, AmeControllerComponent comp, UiButtonPressedMessage msg) private void OnUiButtonPressed(EntityUid uid, AmeControllerComponent comp, UiButtonPressedMessage msg)
{ {
var user = msg.Session.AttachedEntity; var user = msg.Actor;
if (!Exists(user)) if (!Exists(user))
return; return;
@@ -334,7 +334,7 @@ public sealed class AmeControllerSystem : EntitySystem
_ => true, _ => true,
}; };
if (!PlayerCanUseController(uid, user!.Value, needsPower, comp)) if (!PlayerCanUseController(uid, user, needsPower, comp))
return; return;
_audioSystem.PlayPvs(comp.ClickSound, uid, AudioParams.Default.WithVolume(-2f)); _audioSystem.PlayPvs(comp.ClickSound, uid, AudioParams.Default.WithVolume(-2f));

View File

@@ -61,7 +61,7 @@ public sealed partial class AnomalySystem
var materialAmount = _material.GetMaterialAmount(uid, component.RequiredMaterial); var materialAmount = _material.GetMaterialAmount(uid, component.RequiredMaterial);
var state = new AnomalyGeneratorUserInterfaceState(component.CooldownEndTime, materialAmount, component.MaterialPerAnomaly); var state = new AnomalyGeneratorUserInterfaceState(component.CooldownEndTime, materialAmount, component.MaterialPerAnomaly);
_ui.TrySetUiState(uid, AnomalyGeneratorUiKey.Key, state); _ui.SetUiState(uid, AnomalyGeneratorUiKey.Key, state);
} }
public void TryGeneratorCreateAnomaly(EntityUid uid, AnomalyGeneratorComponent? component = null) public void TryGeneratorCreateAnomaly(EntityUid uid, AnomalyGeneratorComponent? component = null)

View File

@@ -31,7 +31,8 @@ public sealed partial class AnomalySystem
{ {
if (component.ScannedAnomaly != args.Anomaly) if (component.ScannedAnomaly != args.Anomaly)
continue; continue;
_ui.TryCloseAll(uid, AnomalyScannerUiKey.Key);
_ui.CloseUi(uid, AnomalyScannerUiKey.Key);
} }
} }
@@ -108,7 +109,7 @@ public sealed partial class AnomalySystem
Popup.PopupEntity(Loc.GetString("anomaly-scanner-component-scan-complete"), uid); Popup.PopupEntity(Loc.GetString("anomaly-scanner-component-scan-complete"), uid);
UpdateScannerWithNewAnomaly(uid, args.Args.Target.Value, component); UpdateScannerWithNewAnomaly(uid, args.Args.Target.Value, component);
if (TryComp<ActorComponent>(args.Args.User, out var actor)) _ui.TryOpen(uid, AnomalyScannerUiKey.Key, actor.PlayerSession); _ui.OpenUi(uid, AnomalyScannerUiKey.Key, args.User);
args.Handled = true; args.Handled = true;
} }
@@ -123,7 +124,7 @@ public sealed partial class AnomalySystem
nextPulse = anomalyComponent.NextPulseTime; nextPulse = anomalyComponent.NextPulseTime;
var state = new AnomalyScannerUserInterfaceState(GetScannerMessage(component), nextPulse); var state = new AnomalyScannerUserInterfaceState(GetScannerMessage(component), nextPulse);
_ui.TrySetUiState(uid, AnomalyScannerUiKey.Key, state); _ui.SetUiState(uid, AnomalyScannerUiKey.Key, state);
} }
public void UpdateScannerWithNewAnomaly(EntityUid scanner, EntityUid anomaly, AnomalyScannerComponent? scannerComp = null, AnomalyComponent? anomalyComp = null) public void UpdateScannerWithNewAnomaly(EntityUid scanner, EntityUid anomaly, AnomalyScannerComponent? scannerComp = null, AnomalyComponent? anomalyComp = null)

View File

@@ -157,39 +157,37 @@ public sealed partial class BlockGame
/// <param name="message">The message to broadcase to all players/spectators.</param> /// <param name="message">The message to broadcase to all players/spectators.</param>
private void SendMessage(BoundUserInterfaceMessage message) private void SendMessage(BoundUserInterfaceMessage message)
{ {
if (_uiSystem.TryGetUi(_owner, BlockGameUiKey.Key, out var bui)) _uiSystem.ServerSendUiMessage(_entityManager.GetEntity(message.Entity), BlockGameUiKey.Key, message);
_uiSystem.SendUiMessage(bui, message);
} }
/// <summary> /// <summary>
/// Handles sending a message to a specific player/spectator. /// Handles sending a message to a specific player/spectator.
/// </summary> /// </summary>
/// <param name="message">The message to send to a specific player/spectator.</param> /// <param name="message">The message to send to a specific player/spectator.</param>
/// <param name="session">The target recipient.</param> /// <param name="actor">The target recipient.</param>
private void SendMessage(BoundUserInterfaceMessage message, ICommonSession session) private void SendMessage(BoundUserInterfaceMessage message, EntityUid actor)
{ {
if (_uiSystem.TryGetUi(_owner, BlockGameUiKey.Key, out var bui)) _uiSystem.ServerSendUiMessage(_entityManager.GetEntity(message.Entity), BlockGameUiKey.Key, message, actor);
_uiSystem.TrySendUiMessage(bui, message, session);
} }
/// <summary> /// <summary>
/// Handles sending the current state of the game to a player that has just opened the UI. /// Handles sending the current state of the game to a player that has just opened the UI.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="actor">The target recipient.</param>
public void UpdateNewPlayerUI(ICommonSession session) public void UpdateNewPlayerUI(EntityUid actor)
{ {
if (_gameOver) if (_gameOver)
{ {
SendMessage(new BlockGameMessages.BlockGameGameOverScreenMessage(Points, _highScorePlacement?.LocalPlacement, _highScorePlacement?.GlobalPlacement), session); SendMessage(new BlockGameMessages.BlockGameGameOverScreenMessage(Points, _highScorePlacement?.LocalPlacement, _highScorePlacement?.GlobalPlacement), actor);
return; return;
} }
if (Paused) if (Paused)
SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Pause, Started), session); SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Pause, Started), actor);
else else
SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Game, Started), session); SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Game, Started), actor);
FullUpdate(session); FullUpdate(actor);
} }
/// <summary> /// <summary>
@@ -209,14 +207,14 @@ public sealed partial class BlockGame
/// Handles broadcasting the full player-visible game state to a specific player/spectator. /// Handles broadcasting the full player-visible game state to a specific player/spectator.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void FullUpdate(ICommonSession session) private void FullUpdate(EntityUid actor)
{ {
UpdateFieldUI(session); UpdateFieldUI(actor);
SendNextPieceUpdate(session); SendNextPieceUpdate(actor);
SendHoldPieceUpdate(session); SendHoldPieceUpdate(actor);
SendLevelUpdate(session); SendLevelUpdate(actor);
SendPointsUpdate(session); SendPointsUpdate(actor);
SendHighscoreUpdate(session); SendHighscoreUpdate(actor);
} }
/// <summary> /// <summary>
@@ -234,14 +232,13 @@ public sealed partial class BlockGame
/// <summary> /// <summary>
/// Handles broadcasting the current location of all of the blocks in the playfield + the active piece to a specific player/spectator. /// Handles broadcasting the current location of all of the blocks in the playfield + the active piece to a specific player/spectator.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> public void UpdateFieldUI(EntityUid actor)
public void UpdateFieldUI(ICommonSession session)
{ {
if (!Started) if (!Started)
return; return;
var computedField = ComputeField(); var computedField = ComputeField();
SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(computedField.ToArray(), BlockGameMessages.BlockGameVisualType.GameField), session); SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(computedField.ToArray(), BlockGameMessages.BlockGameVisualType.GameField), actor);
} }
/// <summary> /// <summary>
@@ -282,10 +279,9 @@ public sealed partial class BlockGame
/// <summary> /// <summary>
/// Broadcasts the state of the next queued piece to a specific viewer. /// Broadcasts the state of the next queued piece to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> private void SendNextPieceUpdate(EntityUid actor)
private void SendNextPieceUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(NextPiece.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.NextBlock), session); SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(NextPiece.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.NextBlock), actor);
} }
/// <summary> /// <summary>
@@ -302,13 +298,12 @@ public sealed partial class BlockGame
/// <summary> /// <summary>
/// Broadcasts the state of the currently held piece to a specific viewer. /// Broadcasts the state of the currently held piece to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> private void SendHoldPieceUpdate(EntityUid actor)
private void SendHoldPieceUpdate(ICommonSession session)
{ {
if (HeldPiece.HasValue) if (HeldPiece.HasValue)
SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(HeldPiece.Value.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.HoldBlock), session); SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(HeldPiece.Value.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.HoldBlock), actor);
else else
SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(Array.Empty<BlockGameBlock>(), BlockGameMessages.BlockGameVisualType.HoldBlock), session); SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(Array.Empty<BlockGameBlock>(), BlockGameMessages.BlockGameVisualType.HoldBlock), actor);
} }
/// <summary> /// <summary>
@@ -322,10 +317,9 @@ public sealed partial class BlockGame
/// <summary> /// <summary>
/// Broadcasts the current game level to a specific viewer. /// Broadcasts the current game level to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> private void SendLevelUpdate(EntityUid actor)
private void SendLevelUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameLevelUpdateMessage(Level), session); SendMessage(new BlockGameMessages.BlockGameLevelUpdateMessage(Level), actor);
} }
/// <summary> /// <summary>
@@ -339,10 +333,9 @@ public sealed partial class BlockGame
/// <summary> /// <summary>
/// Broadcasts the current game score to a specific viewer. /// Broadcasts the current game score to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> private void SendPointsUpdate(EntityUid actor)
private void SendPointsUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameScoreUpdateMessage(Points), session); SendMessage(new BlockGameMessages.BlockGameScoreUpdateMessage(Points), actor);
} }
/// <summary> /// <summary>
@@ -356,9 +349,8 @@ public sealed partial class BlockGame
/// <summary> /// <summary>
/// Broadcasts the current game high score positions to a specific viewer. /// Broadcasts the current game high score positions to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> private void SendHighscoreUpdate(EntityUid actor)
private void SendHighscoreUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameHighScoreUpdateMessage(_arcadeSystem.GetLocalHighscores(), _arcadeSystem.GetGlobalHighscores()), session); SendMessage(new BlockGameMessages.BlockGameHighScoreUpdateMessage(_arcadeSystem.GetLocalHighscores(), _arcadeSystem.GetGlobalHighscores()), actor);
} }
} }

View File

@@ -9,8 +9,8 @@ public sealed partial class BlockGame
{ {
[Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
private readonly ArcadeSystem _arcadeSystem = default!; private readonly ArcadeSystem _arcadeSystem;
private readonly UserInterfaceSystem _uiSystem = default!; private readonly UserInterfaceSystem _uiSystem;
/// <summary> /// <summary>
/// What entity is currently hosting this game of NT-BG. /// What entity is currently hosting this game of NT-BG.
@@ -78,7 +78,7 @@ public sealed partial class BlockGame
_gameOver = true; _gameOver = true;
if (_entityManager.TryGetComponent<BlockGameArcadeComponent>(_owner, out var cabinet) if (_entityManager.TryGetComponent<BlockGameArcadeComponent>(_owner, out var cabinet)
&& _entityManager.TryGetComponent<MetaDataComponent>(cabinet.Player?.AttachedEntity, out var meta)) && _entityManager.TryGetComponent<MetaDataComponent>(cabinet.Player, out var meta))
{ {
_highScorePlacement = _arcadeSystem.RegisterHighScore(meta.EntityName, Points); _highScorePlacement = _arcadeSystem.RegisterHighScore(meta.EntityName, Points);
SendHighscoreUpdate(); SendHighscoreUpdate();

View File

@@ -13,10 +13,10 @@ public sealed partial class BlockGameArcadeComponent : Component
/// <summary> /// <summary>
/// The player currently playing the active session of NT-BG. /// The player currently playing the active session of NT-BG.
/// </summary> /// </summary>
public ICommonSession? Player = null; public EntityUid? Player = null;
/// <summary> /// <summary>
/// The players currently viewing (but not playing) the active session of NT-BG. /// The players currently viewing (but not playing) the active session of NT-BG.
/// </summary> /// </summary>
public readonly List<ICommonSession> Spectators = new(); public readonly List<EntityUid> Spectators = new();
} }

View File

@@ -37,14 +37,12 @@ public sealed class BlockGameArcadeSystem : EntitySystem
} }
} }
private void UpdatePlayerStatus(EntityUid uid, ICommonSession session, PlayerBoundUserInterface? bui = null, BlockGameArcadeComponent? blockGame = null) private void UpdatePlayerStatus(EntityUid uid, EntityUid actor, BlockGameArcadeComponent? blockGame = null)
{ {
if (!Resolve(uid, ref blockGame)) if (!Resolve(uid, ref blockGame))
return; return;
if (bui == null && !_uiSystem.TryGetUi(uid, BlockGameUiKey.Key, out bui))
return;
_uiSystem.TrySendUiMessage(bui, new BlockGameMessages.BlockGameUserStatusMessage(blockGame.Player == session), session); _uiSystem.ServerSendUiMessage(uid, BlockGameUiKey.Key, new BlockGameMessages.BlockGameUserStatusMessage(blockGame.Player == actor), actor);
} }
private void OnComponentInit(EntityUid uid, BlockGameArcadeComponent component, ComponentInit args) private void OnComponentInit(EntityUid uid, BlockGameArcadeComponent component, ComponentInit args)
@@ -54,33 +52,21 @@ public sealed class BlockGameArcadeSystem : EntitySystem
private void OnAfterUIOpen(EntityUid uid, BlockGameArcadeComponent component, AfterActivatableUIOpenEvent args) private void OnAfterUIOpen(EntityUid uid, BlockGameArcadeComponent component, AfterActivatableUIOpenEvent args)
{ {
if (!TryComp<ActorComponent>(args.User, out var actor))
return;
if (!_uiSystem.TryGetUi(uid, BlockGameUiKey.Key, out var bui))
return;
var session = actor.PlayerSession;
if (!bui.SubscribedSessions.Contains(session))
return;
if (component.Player == null) if (component.Player == null)
component.Player = session; component.Player = args.Actor;
else else
component.Spectators.Add(session); component.Spectators.Add(args.Actor);
UpdatePlayerStatus(uid, session, bui, component); UpdatePlayerStatus(uid, args.Actor, component);
component.Game?.UpdateNewPlayerUI(session); component.Game?.UpdateNewPlayerUI(args.Actor);
} }
private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args) private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args)
{ {
if (args.Session is not { } session) if (component.Player != args.Actor)
return;
if (component.Player != session)
{ {
component.Spectators.Remove(session); component.Spectators.Remove(args.Actor);
UpdatePlayerStatus(uid, session, blockGame: component); UpdatePlayerStatus(uid, args.Actor, blockGame: component);
return; return;
} }
@@ -88,11 +74,11 @@ public sealed class BlockGameArcadeSystem : EntitySystem
if (component.Spectators.Count > 0) if (component.Spectators.Count > 0)
{ {
component.Player = component.Spectators[0]; component.Player = component.Spectators[0];
component.Spectators.Remove(component.Player); component.Spectators.Remove(component.Player.Value);
UpdatePlayerStatus(uid, component.Player, blockGame: component); UpdatePlayerStatus(uid, component.Player.Value, blockGame: component);
} }
UpdatePlayerStatus(uid, temp, blockGame: component); UpdatePlayerStatus(uid, temp.Value, blockGame: component);
} }
private void OnBlockPowerChanged(EntityUid uid, BlockGameArcadeComponent component, ref PowerChangedEvent args) private void OnBlockPowerChanged(EntityUid uid, BlockGameArcadeComponent component, ref PowerChangedEvent args)
@@ -100,8 +86,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
if (args.Powered) if (args.Powered)
return; return;
if (_uiSystem.TryGetUi(uid, BlockGameUiKey.Key, out var bui)) _uiSystem.CloseUi(uid, BlockGameUiKey.Key);
_uiSystem.CloseAll(bui);
component.Player = null; component.Player = null;
component.Spectators.Clear(); component.Spectators.Clear();
} }
@@ -112,7 +97,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
return; return;
if (!BlockGameUiKey.Key.Equals(msg.UiKey)) if (!BlockGameUiKey.Key.Equals(msg.UiKey))
return; return;
if (msg.Session != component.Player) if (msg.Actor != component.Player)
return; return;
if (msg.PlayerAction == BlockGamePlayerAction.NewGame) if (msg.PlayerAction == BlockGamePlayerAction.NewGame)

View File

@@ -90,12 +90,10 @@ public sealed partial class SpaceVillainArcadeSystem : EntitySystem
_audioSystem.PlayPvs(component.NewGameSound, uid, AudioParams.Default.WithVolume(-4f)); _audioSystem.PlayPvs(component.NewGameSound, uid, AudioParams.Default.WithVolume(-4f));
component.Game = new SpaceVillainGame(uid, component, this); component.Game = new SpaceVillainGame(uid, component, this);
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out var bui)) _uiSystem.ServerSendUiMessage(uid, SpaceVillainArcadeUiKey.Key, component.Game.GenerateMetaDataMessage());
_uiSystem.SendUiMessage(bui, component.Game.GenerateMetaDataMessage());
break; break;
case PlayerAction.RequestData: case PlayerAction.RequestData:
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out bui)) _uiSystem.ServerSendUiMessage(uid, SpaceVillainArcadeUiKey.Key, component.Game.GenerateMetaDataMessage());
_uiSystem.SendUiMessage(bui, component.Game.GenerateMetaDataMessage());
break; break;
} }
} }
@@ -110,7 +108,6 @@ public sealed partial class SpaceVillainArcadeSystem : EntitySystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var power) && power.Powered) if (TryComp<ApcPowerReceiverComponent>(uid, out var power) && power.Powered)
return; return;
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out var bui)) _uiSystem.CloseUi(uid, SpaceVillainArcadeUiKey.Key);
_uiSystem.CloseAll(bui);
} }
} }

View File

@@ -9,8 +9,7 @@ public sealed partial class SpaceVillainGame
/// </summary> /// </summary>
private void UpdateUi(EntityUid uid, bool metadata = false) private void UpdateUi(EntityUid uid, bool metadata = false)
{ {
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out var bui)) _uiSystem.ServerSendUiMessage(uid, SpaceVillainArcadeUiKey.Key, metadata ? GenerateMetaDataMessage() : GenerateUpdateMessage());
_uiSystem.SendUiMessage(bui, metadata ? GenerateMetaDataMessage() : GenerateUpdateMessage());
} }
private void UpdateUi(EntityUid uid, string message1, string message2, bool metadata = false) private void UpdateUi(EntityUid uid, string message1, string message2, bool metadata = false)

View File

@@ -118,8 +118,7 @@ namespace Content.Server.Atmos.EntitySystems
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
if (user != null && TryComp<ActorComponent>(user, out var actor)) _userInterface.CloseUi(uid, GasAnalyzerUiKey.Key, user);
_userInterface.TryClose(uid, GasAnalyzerUiKey.Key, actor.PlayerSession);
component.Enabled = false; component.Enabled = false;
Dirty(uid, component); Dirty(uid, component);
@@ -132,8 +131,6 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary> /// </summary>
private void OnDisabledMessage(EntityUid uid, GasAnalyzerComponent component, GasAnalyzerDisableMessage message) private void OnDisabledMessage(EntityUid uid, GasAnalyzerComponent component, GasAnalyzerDisableMessage message)
{ {
if (message.Session.AttachedEntity is not { Valid: true })
return;
DisableAnalyzer(uid, component); DisableAnalyzer(uid, component);
} }
@@ -142,10 +139,7 @@ namespace Content.Server.Atmos.EntitySystems
if (!Resolve(uid, ref component, false)) if (!Resolve(uid, ref component, false))
return; return;
if (!TryComp<ActorComponent>(user, out var actor)) _userInterface.OpenUi(uid, GasAnalyzerUiKey.Key, user);
return;
_userInterface.TryOpen(uid, GasAnalyzerUiKey.Key, actor.PlayerSession);
} }
/// <summary> /// <summary>
@@ -242,7 +236,7 @@ namespace Content.Server.Atmos.EntitySystems
if (gasMixList.Count == 0) if (gasMixList.Count == 0)
return false; return false;
_userInterface.TrySendUiMessage(uid, GasAnalyzerUiKey.Key, _userInterface.ServerSendUiMessage(uid, GasAnalyzerUiKey.Key,
new GasAnalyzerUserMessage(gasMixList.ToArray(), new GasAnalyzerUserMessage(gasMixList.ToArray(),
component.Target != null ? Name(component.Target.Value) : string.Empty, component.Target != null ? Name(component.Target.Value) : string.Empty,
GetNetEntity(component.Target) ?? NetEntity.Invalid, GetNetEntity(component.Target) ?? NetEntity.Invalid,

View File

@@ -75,7 +75,7 @@ namespace Content.Server.Atmos.EntitySystems
public void UpdateUserInterface(Entity<GasTankComponent> ent, bool initialUpdate = false) public void UpdateUserInterface(Entity<GasTankComponent> ent, bool initialUpdate = false)
{ {
var (owner, component) = ent; var (owner, component) = ent;
_ui.TrySetUiState(owner, SharedGasTankUiKey.Key, _ui.SetUiState(owner, SharedGasTankUiKey.Key,
new GasTankBoundUserInterfaceState new GasTankBoundUserInterfaceState
{ {
TankPressure = component.Air?.Pressure ?? 0, TankPressure = component.Air?.Pressure ?? 0,

View File

@@ -24,8 +24,6 @@ public sealed partial class AirAlarmComponent : Component
public readonly Dictionary<string, GasVentScrubberData> ScrubberData = new(); public readonly Dictionary<string, GasVentScrubberData> ScrubberData = new();
public readonly Dictionary<string, AtmosSensorData> SensorData = new(); public readonly Dictionary<string, AtmosSensorData> SensorData = new();
public HashSet<NetUserId> ActivePlayers = new();
public bool CanSync = true; public bool CanSync = true;
/// <summary> /// <summary>

View File

@@ -223,8 +223,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnClose(EntityUid uid, AirAlarmComponent component, BoundUIClosedEvent args) private void OnClose(EntityUid uid, AirAlarmComponent component, BoundUIClosedEvent args)
{ {
component.ActivePlayers.Remove(args.Session.UserId); if (!_ui.IsUiOpen(uid, SharedAirAlarmInterfaceKey.Key))
if (component.ActivePlayers.Count == 0)
RemoveActiveInterface(uid); RemoveActiveInterface(uid);
} }
@@ -247,9 +246,6 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnActivate(EntityUid uid, AirAlarmComponent component, ActivateInWorldEvent args) private void OnActivate(EntityUid uid, AirAlarmComponent component, ActivateInWorldEvent args)
{ {
if (!TryComp<ActorComponent>(args.User, out var actor))
return;
if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open) if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open)
{ {
args.Handled = false; args.Handled = false;
@@ -259,10 +255,7 @@ public sealed class AirAlarmSystem : EntitySystem
if (!this.IsPowered(uid, EntityManager)) if (!this.IsPowered(uid, EntityManager))
return; return;
var ui = _ui.GetUiOrNull(uid, SharedAirAlarmInterfaceKey.Key); _ui.OpenUi(uid, SharedAirAlarmInterfaceKey.Key, args.User);
if (ui != null)
_ui.OpenUi(ui, actor.PlayerSession);
component.ActivePlayers.Add(actor.PlayerSession.UserId);
AddActiveInterface(uid); AddActiveInterface(uid);
SyncAllDevices(uid); SyncAllDevices(uid);
UpdateUI(uid, component); UpdateUI(uid, component);
@@ -270,7 +263,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnResyncAll(EntityUid uid, AirAlarmComponent component, AirAlarmResyncAllDevicesMessage args) private void OnResyncAll(EntityUid uid, AirAlarmComponent component, AirAlarmResyncAllDevicesMessage args)
{ {
if (!AccessCheck(uid, args.Session.AttachedEntity, component)) if (!AccessCheck(uid, args.Actor, component))
{ {
return; return;
} }
@@ -285,7 +278,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnUpdateAlarmMode(EntityUid uid, AirAlarmComponent component, AirAlarmUpdateAlarmModeMessage args) private void OnUpdateAlarmMode(EntityUid uid, AirAlarmComponent component, AirAlarmUpdateAlarmModeMessage args)
{ {
if (AccessCheck(uid, args.Session.AttachedEntity, component)) if (AccessCheck(uid, args.Actor, component))
{ {
var addr = string.Empty; var addr = string.Empty;
if (TryComp<DeviceNetworkComponent>(uid, out var netConn)) if (TryComp<DeviceNetworkComponent>(uid, out var netConn))
@@ -309,7 +302,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnUpdateThreshold(EntityUid uid, AirAlarmComponent component, AirAlarmUpdateAlarmThresholdMessage args) private void OnUpdateThreshold(EntityUid uid, AirAlarmComponent component, AirAlarmUpdateAlarmThresholdMessage args)
{ {
if (AccessCheck(uid, args.Session.AttachedEntity, component)) if (AccessCheck(uid, args.Actor, component))
SetThreshold(uid, args.Address, args.Type, args.Threshold, args.Gas); SetThreshold(uid, args.Address, args.Type, args.Threshold, args.Gas);
else else
UpdateUI(uid, component); UpdateUI(uid, component);
@@ -317,7 +310,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnUpdateDeviceData(EntityUid uid, AirAlarmComponent component, AirAlarmUpdateDeviceDataMessage args) private void OnUpdateDeviceData(EntityUid uid, AirAlarmComponent component, AirAlarmUpdateDeviceDataMessage args)
{ {
if (AccessCheck(uid, args.Session.AttachedEntity, component) if (AccessCheck(uid, args.Actor, component)
&& _deviceList.ExistsInDeviceList(uid, args.Address)) && _deviceList.ExistsInDeviceList(uid, args.Address))
{ {
SetDeviceData(uid, args.Address, args.Data); SetDeviceData(uid, args.Address, args.Data);
@@ -330,7 +323,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnCopyDeviceData(EntityUid uid, AirAlarmComponent component, AirAlarmCopyDeviceDataMessage args) private void OnCopyDeviceData(EntityUid uid, AirAlarmComponent component, AirAlarmCopyDeviceDataMessage args)
{ {
if (!AccessCheck(uid, args.Session.AttachedEntity, component)) if (!AccessCheck(uid, args.Actor, component))
{ {
UpdateUI(uid, component); UpdateUI(uid, component);
return; return;
@@ -377,7 +370,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnAtmosAlarm(EntityUid uid, AirAlarmComponent component, AtmosAlarmEvent args) private void OnAtmosAlarm(EntityUid uid, AirAlarmComponent component, AtmosAlarmEvent args)
{ {
if (component.ActivePlayers.Count != 0) if (_ui.IsUiOpen(uid, SharedAirAlarmInterfaceKey.Key))
{ {
SyncAllDevices(uid); SyncAllDevices(uid);
} }
@@ -571,7 +564,7 @@ public sealed class AirAlarmSystem : EntitySystem
/// </summary> /// </summary>
private void ForceCloseAllInterfaces(EntityUid uid) private void ForceCloseAllInterfaces(EntityUid uid)
{ {
_ui.TryCloseAll(uid, SharedAirAlarmInterfaceKey.Key); _ui.CloseUi(uid, SharedAirAlarmInterfaceKey.Key);
} }
private void OnAtmosUpdate(EntityUid uid, AirAlarmComponent alarm, ref AtmosDeviceUpdateEvent args) private void OnAtmosUpdate(EntityUid uid, AirAlarmComponent alarm, ref AtmosDeviceUpdateEvent args)
@@ -639,7 +632,7 @@ public sealed class AirAlarmSystem : EntitySystem
highestAlarm = AtmosAlarmType.Normal; highestAlarm = AtmosAlarmType.Normal;
} }
_ui.TrySetUiState( _ui.SetUiState(
uid, uid,
SharedAirAlarmInterfaceKey.Key, SharedAirAlarmInterfaceKey.Key,
new AirAlarmUIState(devNet.Address, deviceCount, pressure, temperature, dataToSend, alarm.CurrentMode, alarm.CurrentTab, highestAlarm.Value, alarm.AutoMode)); new AirAlarmUIState(devNet.Address, deviceCount, pressure, temperature, dataToSend, alarm.CurrentMode, alarm.CurrentTab, highestAlarm.Value, alarm.AutoMode));

View File

@@ -98,7 +98,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
UpdateAppearance(uid, pump); UpdateAppearance(uid, pump);
DirtyUI(uid, pump); DirtyUI(uid, pump);
_userInterfaceSystem.TryCloseAll(uid, GasPressurePumpUiKey.Key); _userInterfaceSystem.CloseUi(uid, GasPressurePumpUiKey.Key);
} }
private void OnPumpActivate(EntityUid uid, GasPressurePumpComponent pump, ActivateInWorldEvent args) private void OnPumpActivate(EntityUid uid, GasPressurePumpComponent pump, ActivateInWorldEvent args)
@@ -108,7 +108,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (Transform(uid).Anchored) if (Transform(uid).Anchored)
{ {
_userInterfaceSystem.TryOpen(uid, GasPressurePumpUiKey.Key, actor.PlayerSession); _userInterfaceSystem.OpenUi(uid, GasPressurePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, pump); DirtyUI(uid, pump);
} }
else else
@@ -123,7 +123,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{ {
pump.Enabled = args.Enabled; pump.Enabled = args.Enabled;
_adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}"); $"{ToPrettyString(args.Actor):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}");
DirtyUI(uid, pump); DirtyUI(uid, pump);
UpdateAppearance(uid, pump); UpdateAppearance(uid, pump);
} }
@@ -132,7 +132,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{ {
pump.TargetPressure = Math.Clamp(args.Pressure, 0f, Atmospherics.MaxOutputPressure); pump.TargetPressure = Math.Clamp(args.Pressure, 0f, Atmospherics.MaxOutputPressure);
_adminLogger.Add(LogType.AtmosPressureChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosPressureChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the pressure on {ToPrettyString(uid):device} to {args.Pressure}kPa"); $"{ToPrettyString(args.Actor):player} set the pressure on {ToPrettyString(uid):device} to {args.Pressure}kPa");
DirtyUI(uid, pump); DirtyUI(uid, pump);
} }
@@ -142,7 +142,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (!Resolve(uid, ref pump)) if (!Resolve(uid, ref pump))
return; return;
_userInterfaceSystem.TrySetUiState(uid, GasPressurePumpUiKey.Key, _userInterfaceSystem.SetUiState(uid, GasPressurePumpUiKey.Key,
new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(uid).EntityName, pump.TargetPressure, pump.Enabled)); new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(uid).EntityName, pump.TargetPressure, pump.Enabled));
} }

View File

@@ -128,7 +128,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
UpdateAppearance(uid, pump); UpdateAppearance(uid, pump);
DirtyUI(uid, pump); DirtyUI(uid, pump);
_userInterfaceSystem.TryCloseAll(uid, GasVolumePumpUiKey.Key); _userInterfaceSystem.CloseUi(uid, GasVolumePumpUiKey.Key);
} }
private void OnPumpActivate(EntityUid uid, GasVolumePumpComponent pump, ActivateInWorldEvent args) private void OnPumpActivate(EntityUid uid, GasVolumePumpComponent pump, ActivateInWorldEvent args)
@@ -138,7 +138,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (Transform(uid).Anchored) if (Transform(uid).Anchored)
{ {
_userInterfaceSystem.TryOpen(uid, GasVolumePumpUiKey.Key, actor.PlayerSession); _userInterfaceSystem.OpenUi(uid, GasVolumePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, pump); DirtyUI(uid, pump);
} }
else else
@@ -153,7 +153,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{ {
pump.Enabled = args.Enabled; pump.Enabled = args.Enabled;
_adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}"); $"{ToPrettyString(args.Actor):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}");
DirtyUI(uid, pump); DirtyUI(uid, pump);
UpdateAppearance(uid, pump); UpdateAppearance(uid, pump);
} }
@@ -162,7 +162,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{ {
pump.TransferRate = Math.Clamp(args.TransferRate, 0f, pump.MaxTransferRate); pump.TransferRate = Math.Clamp(args.TransferRate, 0f, pump.MaxTransferRate);
_adminLogger.Add(LogType.AtmosVolumeChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosVolumeChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the transfer rate on {ToPrettyString(uid):device} to {args.TransferRate}"); $"{ToPrettyString(args.Actor):player} set the transfer rate on {ToPrettyString(uid):device} to {args.TransferRate}");
DirtyUI(uid, pump); DirtyUI(uid, pump);
} }
@@ -171,7 +171,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (!Resolve(uid, ref pump)) if (!Resolve(uid, ref pump))
return; return;
_userInterfaceSystem.TrySetUiState(uid, GasVolumePumpUiKey.Key, _userInterfaceSystem.SetUiState(uid, GasVolumePumpUiKey.Key,
new GasVolumePumpBoundUserInterfaceState(Name(uid), pump.TransferRate, pump.Enabled)); new GasVolumePumpBoundUserInterfaceState(Name(uid), pump.TransferRate, pump.Enabled));
} }

View File

@@ -94,7 +94,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
_ambientSoundSystem.SetAmbience(uid, false); _ambientSoundSystem.SetAmbience(uid, false);
DirtyUI(uid, filter); DirtyUI(uid, filter);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key); _userInterfaceSystem.CloseUi(uid, GasFilterUiKey.Key);
} }
private void OnFilterActivate(EntityUid uid, GasFilterComponent filter, ActivateInWorldEvent args) private void OnFilterActivate(EntityUid uid, GasFilterComponent filter, ActivateInWorldEvent args)
@@ -104,7 +104,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (EntityManager.GetComponent<TransformComponent>(uid).Anchored) if (EntityManager.GetComponent<TransformComponent>(uid).Anchored)
{ {
_userInterfaceSystem.TryOpen(uid, GasFilterUiKey.Key, actor.PlayerSession); _userInterfaceSystem.OpenUi(uid, GasFilterUiKey.Key, actor.PlayerSession);
DirtyUI(uid, filter); DirtyUI(uid, filter);
} }
else else
@@ -120,7 +120,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (!Resolve(uid, ref filter)) if (!Resolve(uid, ref filter))
return; return;
_userInterfaceSystem.TrySetUiState(uid, GasFilterUiKey.Key, _userInterfaceSystem.SetUiState(uid, GasFilterUiKey.Key,
new GasFilterBoundUserInterfaceState(MetaData(uid).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas)); new GasFilterBoundUserInterfaceState(MetaData(uid).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas));
} }
@@ -136,7 +136,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{ {
filter.Enabled = args.Enabled; filter.Enabled = args.Enabled;
_adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}"); $"{ToPrettyString(args.Actor):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}");
DirtyUI(uid, filter); DirtyUI(uid, filter);
UpdateAppearance(uid, filter); UpdateAppearance(uid, filter);
} }
@@ -145,7 +145,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{ {
filter.TransferRate = Math.Clamp(args.Rate, 0f, filter.MaxTransferRate); filter.TransferRate = Math.Clamp(args.Rate, 0f, filter.MaxTransferRate);
_adminLogger.Add(LogType.AtmosVolumeChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosVolumeChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the transfer rate on {ToPrettyString(uid):device} to {args.Rate}"); $"{ToPrettyString(args.Actor):player} set the transfer rate on {ToPrettyString(uid):device} to {args.Rate}");
DirtyUI(uid, filter); DirtyUI(uid, filter);
} }
@@ -158,7 +158,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{ {
filter.FilteredGas = parsedGas; filter.FilteredGas = parsedGas;
_adminLogger.Add(LogType.AtmosFilterChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosFilterChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the filter on {ToPrettyString(uid):device} to {parsedGas.ToString()}"); $"{ToPrettyString(args.Actor):player} set the filter on {ToPrettyString(uid):device} to {parsedGas.ToString()}");
DirtyUI(uid, filter); DirtyUI(uid, filter);
} }
else else
@@ -170,7 +170,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{ {
filter.FilteredGas = null; filter.FilteredGas = null;
_adminLogger.Add(LogType.AtmosFilterChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosFilterChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the filter on {ToPrettyString(uid):device} to none"); $"{ToPrettyString(args.Actor):player} set the filter on {ToPrettyString(uid):device} to none");
DirtyUI(uid, filter); DirtyUI(uid, filter);
} }
} }

View File

@@ -134,7 +134,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
DirtyUI(uid, mixer); DirtyUI(uid, mixer);
UpdateAppearance(uid, mixer); UpdateAppearance(uid, mixer);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key); _userInterfaceSystem.CloseUi(uid, GasFilterUiKey.Key);
} }
private void OnMixerActivate(EntityUid uid, GasMixerComponent mixer, ActivateInWorldEvent args) private void OnMixerActivate(EntityUid uid, GasMixerComponent mixer, ActivateInWorldEvent args)
@@ -144,7 +144,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (Transform(uid).Anchored) if (Transform(uid).Anchored)
{ {
_userInterfaceSystem.TryOpen(uid, GasMixerUiKey.Key, actor.PlayerSession); _userInterfaceSystem.OpenUi(uid, GasMixerUiKey.Key, actor.PlayerSession);
DirtyUI(uid, mixer); DirtyUI(uid, mixer);
} }
else else
@@ -160,7 +160,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (!Resolve(uid, ref mixer)) if (!Resolve(uid, ref mixer))
return; return;
_userInterfaceSystem.TrySetUiState(uid, GasMixerUiKey.Key, _userInterfaceSystem.SetUiState(uid, GasMixerUiKey.Key,
new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(uid).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration)); new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(uid).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
} }
@@ -176,7 +176,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{ {
mixer.Enabled = args.Enabled; mixer.Enabled = args.Enabled;
_adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosPowerChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}"); $"{ToPrettyString(args.Actor):player} set the power on {ToPrettyString(uid):device} to {args.Enabled}");
DirtyUI(uid, mixer); DirtyUI(uid, mixer);
UpdateAppearance(uid, mixer); UpdateAppearance(uid, mixer);
} }
@@ -185,7 +185,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{ {
mixer.TargetPressure = Math.Clamp(args.Pressure, 0f, mixer.MaxTargetPressure); mixer.TargetPressure = Math.Clamp(args.Pressure, 0f, mixer.MaxTargetPressure);
_adminLogger.Add(LogType.AtmosPressureChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosPressureChanged, LogImpact.Medium,
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the pressure on {ToPrettyString(uid):device} to {args.Pressure}kPa"); $"{ToPrettyString(args.Actor):player} set the pressure on {ToPrettyString(uid):device} to {args.Pressure}kPa");
DirtyUI(uid, mixer); DirtyUI(uid, mixer);
} }
@@ -196,7 +196,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
mixer.InletOneConcentration = nodeOne; mixer.InletOneConcentration = nodeOne;
mixer.InletTwoConcentration = 1.0f - mixer.InletOneConcentration; mixer.InletTwoConcentration = 1.0f - mixer.InletOneConcentration;
_adminLogger.Add(LogType.AtmosRatioChanged, LogImpact.Medium, _adminLogger.Add(LogType.AtmosRatioChanged, LogImpact.Medium,
$"{EntityManager.ToPrettyString(args.Session.AttachedEntity!.Value):player} set the ratio on {EntityManager.ToPrettyString(uid):device} to {mixer.InletOneConcentration}:{mixer.InletTwoConcentration}"); $"{EntityManager.ToPrettyString(args.Actor):player} set the ratio on {EntityManager.ToPrettyString(uid):device} to {mixer.InletOneConcentration}:{mixer.InletTwoConcentration}");
DirtyUI(uid, mixer); DirtyUI(uid, mixer);
} }

View File

@@ -96,7 +96,7 @@ public sealed class GasCanisterSystem : EntitySystem
tankPressure = tankComponent.Air.Pressure; tankPressure = tankComponent.Air.Pressure;
} }
_ui.TrySetUiState(uid, GasCanisterUiKey.Key, _ui.SetUiState(uid, GasCanisterUiKey.Key,
new GasCanisterBoundUserInterfaceState(Name(uid), new GasCanisterBoundUserInterfaceState(Name(uid),
canister.Air.Pressure, portStatus, tankLabel, tankPressure, canister.ReleasePressure, canister.Air.Pressure, portStatus, tankLabel, tankPressure, canister.ReleasePressure,
canister.ReleaseValve, canister.MinReleasePressure, canister.MaxReleasePressure)); canister.ReleaseValve, canister.MinReleasePressure, canister.MaxReleasePressure));
@@ -104,19 +104,19 @@ public sealed class GasCanisterSystem : EntitySystem
private void OnHoldingTankEjectMessage(EntityUid uid, GasCanisterComponent canister, GasCanisterHoldingTankEjectMessage args) private void OnHoldingTankEjectMessage(EntityUid uid, GasCanisterComponent canister, GasCanisterHoldingTankEjectMessage args)
{ {
if (canister.GasTankSlot.Item == null || args.Session.AttachedEntity == null) if (canister.GasTankSlot.Item == null)
return; return;
var item = canister.GasTankSlot.Item; var item = canister.GasTankSlot.Item;
_slots.TryEjectToHands(uid, canister.GasTankSlot, args.Session.AttachedEntity); _slots.TryEjectToHands(uid, canister.GasTankSlot, args.Actor);
_adminLogger.Add(LogType.CanisterTankEjected, LogImpact.Medium, $"Player {ToPrettyString(args.Session.AttachedEntity.GetValueOrDefault()):player} ejected tank {ToPrettyString(item):tank} from {ToPrettyString(uid):canister}"); _adminLogger.Add(LogType.CanisterTankEjected, LogImpact.Medium, $"Player {ToPrettyString(args.Actor):player} ejected tank {ToPrettyString(item):tank} from {ToPrettyString(uid):canister}");
} }
private void OnCanisterChangeReleasePressure(EntityUid uid, GasCanisterComponent canister, GasCanisterChangeReleasePressureMessage args) private void OnCanisterChangeReleasePressure(EntityUid uid, GasCanisterComponent canister, GasCanisterChangeReleasePressureMessage args)
{ {
var pressure = Math.Clamp(args.Pressure, canister.MinReleasePressure, canister.MaxReleasePressure); var pressure = Math.Clamp(args.Pressure, canister.MinReleasePressure, canister.MaxReleasePressure);
_adminLogger.Add(LogType.CanisterPressure, LogImpact.Medium, $"{ToPrettyString(args.Session.AttachedEntity.GetValueOrDefault()):player} set the release pressure on {ToPrettyString(uid):canister} to {args.Pressure}"); _adminLogger.Add(LogType.CanisterPressure, LogImpact.Medium, $"{ToPrettyString(args.Actor):player} set the release pressure on {ToPrettyString(uid):canister} to {args.Pressure}");
canister.ReleasePressure = pressure; canister.ReleasePressure = pressure;
DirtyUI(uid, canister); DirtyUI(uid, canister);
@@ -129,14 +129,14 @@ public sealed class GasCanisterSystem : EntitySystem
impact = canister.GasTankSlot.HasItem ? LogImpact.Medium : LogImpact.High; impact = canister.GasTankSlot.HasItem ? LogImpact.Medium : LogImpact.High;
var containedGasDict = new Dictionary<Gas, float>(); var containedGasDict = new Dictionary<Gas, float>();
var containedGasArray = Gas.GetValues(typeof(Gas)); var containedGasArray = Enum.GetValues(typeof(Gas));
for (int i = 0; i < containedGasArray.Length; i++) for (int i = 0; i < containedGasArray.Length; i++)
{ {
containedGasDict.Add((Gas)i, canister.Air[i]); containedGasDict.Add((Gas)i, canister.Air[i]);
} }
_adminLogger.Add(LogType.CanisterValve, impact, $"{ToPrettyString(args.Session.AttachedEntity.GetValueOrDefault()):player} set the valve on {ToPrettyString(uid):canister} to {args.Valve:valveState} while it contained [{string.Join(", ", containedGasDict)}]"); _adminLogger.Add(LogType.CanisterValve, impact, $"{ToPrettyString(args.Actor):player} set the valve on {ToPrettyString(uid):canister} to {args.Valve:valveState} while it contained [{string.Join(", ", containedGasDict)}]");
canister.ReleaseValve = args.Valve; canister.ReleaseValve = args.Valve;
DirtyUI(uid, canister); DirtyUI(uid, canister);
@@ -212,7 +212,7 @@ public sealed class GasCanisterSystem : EntitySystem
if (args.Handled) if (args.Handled)
return; return;
_ui.TryOpen(uid, GasCanisterUiKey.Key, actor.PlayerSession); _ui.OpenUi(uid, GasCanisterUiKey.Key, actor.PlayerSession);
args.Handled = true; args.Handled = true;
} }
@@ -224,7 +224,7 @@ public sealed class GasCanisterSystem : EntitySystem
if (CheckLocked(uid, component, args.User)) if (CheckLocked(uid, component, args.User))
return; return;
_ui.TryOpen(uid, GasCanisterUiKey.Key, actor.PlayerSession); _ui.OpenUi(uid, GasCanisterUiKey.Key, actor.PlayerSession);
args.Handled = true; args.Handled = true;
} }

View File

@@ -144,7 +144,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnToggleMessage(EntityUid uid, GasThermoMachineComponent thermoMachine, GasThermomachineToggleMessage args) private void OnToggleMessage(EntityUid uid, GasThermoMachineComponent thermoMachine, GasThermomachineToggleMessage args)
{ {
var powerState = _power.TogglePower(uid); var powerState = _power.TogglePower(uid);
_adminLogger.Add(LogType.AtmosPowerChanged, $"{ToPrettyString(args.Session.AttachedEntity)} turned {(powerState ? "On" : "Off")} {ToPrettyString(uid)}"); _adminLogger.Add(LogType.AtmosPowerChanged, $"{ToPrettyString(args.Actor)} turned {(powerState ? "On" : "Off")} {ToPrettyString(uid)}");
DirtyUI(uid, thermoMachine); DirtyUI(uid, thermoMachine);
} }
@@ -155,7 +155,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
else else
thermoMachine.TargetTemperature = MathF.Max(args.Temperature, thermoMachine.MinTemperature); thermoMachine.TargetTemperature = MathF.Max(args.Temperature, thermoMachine.MinTemperature);
thermoMachine.TargetTemperature = MathF.Max(thermoMachine.TargetTemperature, Atmospherics.TCMB); thermoMachine.TargetTemperature = MathF.Max(thermoMachine.TargetTemperature, Atmospherics.TCMB);
_adminLogger.Add(LogType.AtmosTemperatureChanged, $"{ToPrettyString(args.Session.AttachedEntity)} set temperature on {ToPrettyString(uid)} to {thermoMachine.TargetTemperature}"); _adminLogger.Add(LogType.AtmosTemperatureChanged, $"{ToPrettyString(args.Actor)} set temperature on {ToPrettyString(uid)} to {thermoMachine.TargetTemperature}");
DirtyUI(uid, thermoMachine); DirtyUI(uid, thermoMachine);
} }
@@ -168,8 +168,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!Resolve(uid, ref powerReceiver)) if (!Resolve(uid, ref powerReceiver))
return; return;
_userInterfaceSystem.TrySetUiState(uid, ThermomachineUiKey.Key, _userInterfaceSystem.SetUiState(uid, ThermomachineUiKey.Key,
new GasThermomachineBoundUserInterfaceState(thermoMachine.MinTemperature, thermoMachine.MaxTemperature, thermoMachine.TargetTemperature, !powerReceiver.PowerDisabled, IsHeater(thermoMachine)), null, ui); new GasThermomachineBoundUserInterfaceState(thermoMachine.MinTemperature, thermoMachine.MaxTemperature, thermoMachine.TargetTemperature, !powerReceiver.PowerDisabled, IsHeater(thermoMachine)));
} }
private void OnExamined(EntityUid uid, GasThermoMachineComponent thermoMachine, ExaminedEvent args) private void OnExamined(EntityUid uid, GasThermoMachineComponent thermoMachine, ExaminedEvent args)

View File

@@ -163,7 +163,7 @@ public sealed class SpaceHeaterSystem : EntitySystem
{ {
return; return;
} }
_userInterfaceSystem.TrySetUiState(uid, SpaceHeaterUiKey.Key, _userInterfaceSystem.SetUiState(uid, SpaceHeaterUiKey.Key,
new SpaceHeaterBoundUserInterfaceState(spaceHeater.MinTemperature, spaceHeater.MaxTemperature, thermoMachine.TargetTemperature, !powerReceiver.PowerDisabled, spaceHeater.Mode, spaceHeater.PowerLevel)); new SpaceHeaterBoundUserInterfaceState(spaceHeater.MinTemperature, spaceHeater.MaxTemperature, thermoMachine.TargetTemperature, !powerReceiver.PowerDisabled, spaceHeater.Mode, spaceHeater.PowerLevel));
} }

View File

@@ -5,6 +5,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Audio.Components; using Robust.Shared.Audio.Components;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using JukeboxComponent = Content.Shared.Audio.Jukebox.JukeboxComponent; using JukeboxComponent = Content.Shared.Audio.Jukebox.JukeboxComponent;
@@ -66,9 +67,12 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
private void OnJukeboxSetTime(EntityUid uid, JukeboxComponent component, JukeboxSetTimeMessage args) private void OnJukeboxSetTime(EntityUid uid, JukeboxComponent component, JukeboxSetTimeMessage args)
{ {
var offset = (args.Session.Channel.Ping * 1.5f) / 1000f; if (TryComp(args.Actor, out ActorComponent? actorComp))
{
var offset = actorComp.PlayerSession.Channel.Ping * 1.5f / 1000f;
Audio.SetPlaybackPosition(component.AudioStream, args.SongTime + offset); Audio.SetPlaybackPosition(component.AudioStream, args.SongTime + offset);
} }
}
private void OnPowerChanged(Entity<JukeboxComponent> entity, ref PowerChangedEvent args) private void OnPowerChanged(Entity<JukeboxComponent> entity, ref PowerChangedEvent args)
{ {

View File

@@ -79,9 +79,7 @@ public sealed class CryostorageSystem : SharedCryostorageSystem
private void OnRemoveItemBuiMessage(Entity<CryostorageComponent> ent, ref CryostorageRemoveItemBuiMessage args) private void OnRemoveItemBuiMessage(Entity<CryostorageComponent> ent, ref CryostorageRemoveItemBuiMessage args)
{ {
var (_, comp) = ent; var (_, comp) = ent;
if (args.Session.AttachedEntity is not { } attachedEntity) var attachedEntity = args.Actor;
return;
var cryoContained = GetEntity(args.StoredEntity); var cryoContained = GetEntity(args.StoredEntity);
if (!comp.StoredPlayers.Contains(cryoContained) || !IsInPausedMap(cryoContained)) if (!comp.StoredPlayers.Contains(cryoContained) || !IsInPausedMap(cryoContained))
@@ -114,6 +112,7 @@ public sealed class CryostorageSystem : SharedCryostorageSystem
AdminLog.Add(LogType.Action, LogImpact.High, AdminLog.Add(LogType.Action, LogImpact.High,
$"{ToPrettyString(attachedEntity):player} removed item {ToPrettyString(entity)} from cryostorage-contained player " + $"{ToPrettyString(attachedEntity):player} removed item {ToPrettyString(entity)} from cryostorage-contained player " +
$"{ToPrettyString(cryoContained):player}, stored in cryostorage {ToPrettyString(ent)}"); $"{ToPrettyString(cryoContained):player}, stored in cryostorage {ToPrettyString(ent)}");
_container.TryRemoveFromContainer(entity.Value); _container.TryRemoveFromContainer(entity.Value);
_transform.SetCoordinates(entity.Value, Transform(attachedEntity).Coordinates); _transform.SetCoordinates(entity.Value, Transform(attachedEntity).Coordinates);
_hands.PickupOrDrop(attachedEntity, entity.Value); _hands.PickupOrDrop(attachedEntity, entity.Value);
@@ -122,8 +121,8 @@ public sealed class CryostorageSystem : SharedCryostorageSystem
private void UpdateCryostorageUIState(Entity<CryostorageComponent> ent) private void UpdateCryostorageUIState(Entity<CryostorageComponent> ent)
{ {
var state = new CryostorageBuiState(GetAllContainedData(ent).ToList()); var state = new CryostorageBuiState(GetAllContainedData(ent));
_ui.TrySetUiState(ent, CryostorageUIKey.Key, state); _ui.SetUiState(ent.Owner, CryostorageUIKey.Key, state);
} }
private void OnPlayerSpawned(Entity<CryostorageContainedComponent> ent, ref PlayerSpawnCompleteEvent args) private void OnPlayerSpawned(Entity<CryostorageContainedComponent> ent, ref PlayerSpawnCompleteEvent args)
@@ -293,12 +292,17 @@ public sealed class CryostorageSystem : SharedCryostorageSystem
_chatManager.ChatMessageToOne(ChatChannel.Server, msg, msg, uid, false, actor.PlayerSession.Channel); _chatManager.ChatMessageToOne(ChatChannel.Server, msg, msg, uid, false, actor.PlayerSession.Channel);
} }
private IEnumerable<CryostorageContainedPlayerData> GetAllContainedData(Entity<CryostorageComponent> ent) private List<CryostorageContainedPlayerData> GetAllContainedData(Entity<CryostorageComponent> ent)
{ {
var data = new List<CryostorageContainedPlayerData>();
data.EnsureCapacity(ent.Comp.StoredPlayers.Count);
foreach (var contained in ent.Comp.StoredPlayers) foreach (var contained in ent.Comp.StoredPlayers)
{ {
yield return GetContainedData(contained); data.Add(GetContainedData(contained));
} }
return data;
} }
private CryostorageContainedPlayerData GetContainedData(EntityUid uid) private CryostorageContainedPlayerData GetContainedData(EntityUid uid)

View File

@@ -52,7 +52,7 @@ public sealed partial class CargoSystem
return; return;
var untilNextSkip = bountyDb.NextSkipTime - _timing.CurTime; var untilNextSkip = bountyDb.NextSkipTime - _timing.CurTime;
_uiSystem.TrySetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(bountyDb.Bounties, untilNextSkip)); _uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(bountyDb.Bounties, untilNextSkip));
} }
private void OnPrintLabelMessage(EntityUid uid, CargoBountyConsoleComponent component, BountyPrintLabelMessage args) private void OnPrintLabelMessage(EntityUid uid, CargoBountyConsoleComponent component, BountyPrintLabelMessage args)
@@ -83,7 +83,7 @@ public sealed partial class CargoSystem
if (!TryGetBountyFromId(station, args.BountyId, out var bounty)) if (!TryGetBountyFromId(station, args.BountyId, out var bounty))
return; return;
if (args.Session.AttachedEntity is not { Valid: true } mob) if (args.Actor is not { Valid: true } mob)
return; return;
if (TryComp<AccessReaderComponent>(uid, out var accessReaderComponent) && if (TryComp<AccessReaderComponent>(uid, out var accessReaderComponent) &&
@@ -99,7 +99,7 @@ public sealed partial class CargoSystem
FillBountyDatabase(station); FillBountyDatabase(station);
db.NextSkipTime = _timing.CurTime + db.SkipDelay; db.NextSkipTime = _timing.CurTime + db.SkipDelay;
var untilNextSkip = db.NextSkipTime - _timing.CurTime; var untilNextSkip = db.NextSkipTime - _timing.CurTime;
_uiSystem.TrySetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, untilNextSkip)); _uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, untilNextSkip));
_audio.PlayPvs(component.SkipSound, uid); _audio.PlayPvs(component.SkipSound, uid);
} }
@@ -462,10 +462,12 @@ public sealed partial class CargoSystem
{ {
if (_station.GetOwningStation(uid) is not { } station || if (_station.GetOwningStation(uid) is not { } station ||
!TryComp<StationCargoBountyDatabaseComponent>(station, out var db)) !TryComp<StationCargoBountyDatabaseComponent>(station, out var db))
{
continue; continue;
}
var untilNextSkip = db.NextSkipTime - _timing.CurTime; var untilNextSkip = db.NextSkipTime - _timing.CurTime;
_uiSystem.TrySetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, untilNextSkip), ui: ui); _uiSystem.SetUiState((uid, ui), CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, untilNextSkip));
} }
} }

View File

@@ -102,12 +102,12 @@ namespace Content.Server.Cargo.Systems
private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleApproveOrderMessage args) private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleApproveOrderMessage args)
{ {
if (args.Session.AttachedEntity is not { Valid: true } player) if (args.Actor is not { Valid: true } player)
return; return;
if (!_accessReaderSystem.IsAllowed(player, uid)) if (!_accessReaderSystem.IsAllowed(player, uid))
{ {
ConsolePopup(args.Session, Loc.GetString("cargo-console-order-not-allowed")); ConsolePopup(args.Actor, Loc.GetString("cargo-console-order-not-allowed"));
PlayDenySound(uid, component); PlayDenySound(uid, component);
return; return;
} }
@@ -119,7 +119,7 @@ namespace Content.Server.Cargo.Systems
!TryComp(station, out StationDataComponent? stationData) || !TryComp(station, out StationDataComponent? stationData) ||
!TryGetOrderDatabase(station, out var orderDatabase)) !TryGetOrderDatabase(station, out var orderDatabase))
{ {
ConsolePopup(args.Session, Loc.GetString("cargo-console-station-not-found")); ConsolePopup(args.Actor, Loc.GetString("cargo-console-station-not-found"));
PlayDenySound(uid, component); PlayDenySound(uid, component);
return; return;
} }
@@ -134,7 +134,7 @@ namespace Content.Server.Cargo.Systems
// Invalid order // Invalid order
if (!_protoMan.HasIndex<EntityPrototype>(order.ProductId)) if (!_protoMan.HasIndex<EntityPrototype>(order.ProductId))
{ {
ConsolePopup(args.Session, Loc.GetString("cargo-console-invalid-product")); ConsolePopup(args.Actor, Loc.GetString("cargo-console-invalid-product"));
PlayDenySound(uid, component); PlayDenySound(uid, component);
return; return;
} }
@@ -145,7 +145,7 @@ namespace Content.Server.Cargo.Systems
// Too many orders, avoid them getting spammed in the UI. // Too many orders, avoid them getting spammed in the UI.
if (amount >= capacity) if (amount >= capacity)
{ {
ConsolePopup(args.Session, Loc.GetString("cargo-console-too-many")); ConsolePopup(args.Actor, Loc.GetString("cargo-console-too-many"));
PlayDenySound(uid, component); PlayDenySound(uid, component);
return; return;
} }
@@ -156,7 +156,7 @@ namespace Content.Server.Cargo.Systems
if (cappedAmount != order.OrderQuantity) if (cappedAmount != order.OrderQuantity)
{ {
order.OrderQuantity = cappedAmount; order.OrderQuantity = cappedAmount;
ConsolePopup(args.Session, Loc.GetString("cargo-console-snip-snip")); ConsolePopup(args.Actor, Loc.GetString("cargo-console-snip-snip"));
PlayDenySound(uid, component); PlayDenySound(uid, component);
} }
@@ -165,7 +165,7 @@ namespace Content.Server.Cargo.Systems
// Not enough balance // Not enough balance
if (cost > bank.Balance) if (cost > bank.Balance)
{ {
ConsolePopup(args.Session, Loc.GetString("cargo-console-insufficient-funds", ("cost", cost))); ConsolePopup(args.Actor, Loc.GetString("cargo-console-insufficient-funds", ("cost", cost)));
PlayDenySound(uid, component); PlayDenySound(uid, component);
return; return;
} }
@@ -180,7 +180,7 @@ namespace Content.Server.Cargo.Systems
if (ev.FulfillmentEntity == null) if (ev.FulfillmentEntity == null)
{ {
ConsolePopup(args.Session, Loc.GetString("cargo-console-unfulfilled")); ConsolePopup(args.Actor, Loc.GetString("cargo-console-unfulfilled"));
PlayDenySound(uid, component); PlayDenySound(uid, component);
return; return;
} }
@@ -200,7 +200,7 @@ namespace Content.Server.Cargo.Systems
("approverJob", approverJob), ("approverJob", approverJob),
("cost", cost)); ("cost", cost));
_radio.SendRadioMessage(uid, message, component.AnnouncementChannel, uid, escapeMarkup: false); _radio.SendRadioMessage(uid, message, component.AnnouncementChannel, uid, escapeMarkup: false);
ConsolePopup(args.Session, Loc.GetString("cargo-console-trade-station", ("destination", MetaData(ev.FulfillmentEntity.Value).EntityName))); ConsolePopup(args.Actor, Loc.GetString("cargo-console-trade-station", ("destination", MetaData(ev.FulfillmentEntity.Value).EntityName)));
// Log order approval // Log order approval
_adminLogger.Add(LogType.Action, LogImpact.Low, _adminLogger.Add(LogType.Action, LogImpact.Low,
@@ -271,7 +271,7 @@ namespace Content.Server.Cargo.Systems
private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args) private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args)
{ {
if (args.Session.AttachedEntity is not { Valid: true } player) if (args.Actor is not { Valid: true } player)
return; return;
if (args.Amount <= 0) if (args.Amount <= 0)
@@ -319,9 +319,9 @@ namespace Content.Server.Cargo.Systems
!TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase) || !TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase) ||
!TryComp<StationBankAccountComponent>(station, out var bankAccount)) return; !TryComp<StationBankAccountComponent>(station, out var bankAccount)) return;
if (_uiSystem.TryGetUi(consoleUid, CargoConsoleUiKey.Orders, out var bui)) if (_uiSystem.HasUi(consoleUid, CargoConsoleUiKey.Orders))
{ {
_uiSystem.SetUiState(bui, new CargoConsoleInterfaceState( _uiSystem.SetUiState(consoleUid, CargoConsoleUiKey.Orders, new CargoConsoleInterfaceState(
MetaData(station.Value).EntityName, MetaData(station.Value).EntityName,
GetOutstandingOrderCount(orderDatabase), GetOutstandingOrderCount(orderDatabase),
orderDatabase.Capacity, orderDatabase.Capacity,
@@ -331,9 +331,9 @@ namespace Content.Server.Cargo.Systems
} }
} }
private void ConsolePopup(ICommonSession session, string text) private void ConsolePopup(EntityUid actor, string text)
{ {
_popup.PopupCursor(text, session); _popup.PopupCursor(text, actor);
} }
private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component) private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component)

View File

@@ -54,21 +54,20 @@ public sealed partial class CargoSystem
private void UpdatePalletConsoleInterface(EntityUid uid) private void UpdatePalletConsoleInterface(EntityUid uid)
{ {
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
if (Transform(uid).GridUid is not EntityUid gridUid) if (Transform(uid).GridUid is not EntityUid gridUid)
{ {
_uiSystem.SetUiState(bui, _uiSystem.SetUiState(uid, CargoPalletConsoleUiKey.Sale,
new CargoPalletConsoleInterfaceState(0, 0, false)); new CargoPalletConsoleInterfaceState(0, 0, false));
return; return;
} }
GetPalletGoods(gridUid, out var toSell, out var amount); GetPalletGoods(gridUid, out var toSell, out var amount);
_uiSystem.SetUiState(bui, _uiSystem.SetUiState(uid, CargoPalletConsoleUiKey.Sale,
new CargoPalletConsoleInterfaceState((int) amount, toSell.Count, true)); new CargoPalletConsoleInterfaceState((int) amount, toSell.Count, true));
} }
private void OnPalletUIOpen(EntityUid uid, CargoPalletConsoleComponent component, BoundUIOpenedEvent args) private void OnPalletUIOpen(EntityUid uid, CargoPalletConsoleComponent component, BoundUIOpenedEvent args)
{ {
var player = args.Session.AttachedEntity; var player = args.Actor;
if (player == null) if (player == null)
return; return;
@@ -86,7 +85,7 @@ public sealed partial class CargoSystem
private void OnPalletAppraise(EntityUid uid, CargoPalletConsoleComponent component, CargoPalletAppraiseMessage args) private void OnPalletAppraise(EntityUid uid, CargoPalletConsoleComponent component, CargoPalletAppraiseMessage args)
{ {
var player = args.Session.AttachedEntity; var player = args.Actor;
if (player == null) if (player == null)
return; return;
@@ -108,8 +107,8 @@ public sealed partial class CargoSystem
var orders = GetProjectedOrders(station ?? EntityUid.Invalid, orderDatabase, shuttle); var orders = GetProjectedOrders(station ?? EntityUid.Invalid, orderDatabase, shuttle);
var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty; var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty;
if (_uiSystem.TryGetUi(uid, CargoConsoleUiKey.Shuttle, out var bui)) if (_uiSystem.HasUi(uid, CargoConsoleUiKey.Shuttle))
_uiSystem.SetUiState(bui, new CargoShuttleConsoleBoundUserInterfaceState( _uiSystem.SetUiState(uid, CargoConsoleUiKey.Shuttle, new CargoShuttleConsoleBoundUserInterfaceState(
station != null ? MetaData(station.Value).EntityName : Loc.GetString("cargo-shuttle-console-station-unknown"), station != null ? MetaData(station.Value).EntityName : Loc.GetString("cargo-shuttle-console-station-unknown"),
string.IsNullOrEmpty(shuttleName) ? Loc.GetString("cargo-shuttle-console-shuttle-not-found") : shuttleName, string.IsNullOrEmpty(shuttleName) ? Loc.GetString("cargo-shuttle-console-shuttle-not-found") : shuttleName,
orders orders
@@ -314,17 +313,16 @@ public sealed partial class CargoSystem
private void OnPalletSale(EntityUid uid, CargoPalletConsoleComponent component, CargoPalletSellMessage args) private void OnPalletSale(EntityUid uid, CargoPalletConsoleComponent component, CargoPalletSellMessage args)
{ {
var player = args.Session.AttachedEntity; var player = args.Actor;
if (player == null) if (player == null)
return; return;
var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale);
var xform = Transform(uid); var xform = Transform(uid);
if (xform.GridUid is not EntityUid gridUid) if (xform.GridUid is not EntityUid gridUid)
{ {
_uiSystem.SetUiState(bui, _uiSystem.SetUiState(uid, CargoPalletConsoleUiKey.Sale,
new CargoPalletConsoleInterfaceState(0, 0, false)); new CargoPalletConsoleInterfaceState(0, 0, false));
return; return;
} }

View File

@@ -103,12 +103,12 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
if (!Resolve(loaderUid, ref loader)) if (!Resolve(loaderUid, ref loader))
return; return;
if (!_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui)) if (!_userInterfaceSystem.HasUi(loaderUid, loader.UiKey))
return; return;
var programs = GetAvailablePrograms(loaderUid, loader); var programs = GetAvailablePrograms(loaderUid, loader);
var state = new CartridgeLoaderUiState(programs, GetNetEntity(loader.ActiveProgram)); var state = new CartridgeLoaderUiState(programs, GetNetEntity(loader.ActiveProgram));
_userInterfaceSystem.SetUiState(ui, state, session); _userInterfaceSystem.SetUiState(loaderUid, loader.UiKey, state);
} }
/// <summary> /// <summary>
@@ -127,8 +127,8 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem
if (!Resolve(loaderUid, ref loader)) if (!Resolve(loaderUid, ref loader))
return; return;
if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui)) if (_userInterfaceSystem.HasUi(loaderUid, loader.UiKey))
_userInterfaceSystem.SetUiState(ui, state, session); _userInterfaceSystem.SetUiState(loaderUid, loader.UiKey, state);
} }
/// <summary> /// <summary>

View File

@@ -80,7 +80,7 @@ namespace Content.Server.Chemistry.EntitySystems
chemMaster.Mode, BuildInputContainerInfo(inputContainer), BuildOutputContainerInfo(outputContainer), chemMaster.Mode, BuildInputContainerInfo(inputContainer), BuildOutputContainerInfo(outputContainer),
bufferReagents, bufferCurrentVolume, chemMaster.PillType, chemMaster.PillDosageLimit, updateLabel); bufferReagents, bufferCurrentVolume, chemMaster.PillType, chemMaster.PillDosageLimit, updateLabel);
_userInterfaceSystem.TrySetUiState(owner, ChemMasterUiKey.Key, state); _userInterfaceSystem.SetUiState(owner, ChemMasterUiKey.Key, state);
} }
private void OnSetModeMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterSetModeMessage message) private void OnSetModeMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterSetModeMessage message)
@@ -179,7 +179,7 @@ namespace Content.Server.Chemistry.EntitySystems
private void OnCreatePillsMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterCreatePillsMessage message) private void OnCreatePillsMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterCreatePillsMessage message)
{ {
var user = message.Session.AttachedEntity; var user = message.Actor;
var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.OutputSlotName); var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.OutputSlotName);
if (maybeContainer is not { Valid: true } container if (maybeContainer is not { Valid: true } container
|| !TryComp(container, out StorageComponent? storage)) || !TryComp(container, out StorageComponent? storage))
@@ -218,18 +218,9 @@ namespace Content.Server.Chemistry.EntitySystems
pill.PillType = chemMaster.Comp.PillType; pill.PillType = chemMaster.Comp.PillType;
Dirty(item, pill); Dirty(item, pill);
if (user.HasValue)
{
// Log pill creation by a user // Log pill creation by a user
_adminLogger.Add(LogType.Action, LogImpact.Low, _adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user.Value):user} printed {ToPrettyString(item):pill} {SolutionContainerSystem.ToPrettyString(itemSolution.Comp.Solution)}"); $"{ToPrettyString(user):user} printed {ToPrettyString(item):pill} {SharedSolutionContainerSystem.ToPrettyString(itemSolution.Comp.Solution)}");
}
else
{
// Log pill creation by magic? This should never happen... right?
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"Unknown printed {ToPrettyString(item):pill} {SolutionContainerSystem.ToPrettyString(itemSolution.Comp.Solution)}");
}
} }
UpdateUiState(chemMaster); UpdateUiState(chemMaster);
@@ -238,7 +229,7 @@ namespace Content.Server.Chemistry.EntitySystems
private void OnOutputToBottleMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterOutputToBottleMessage message) private void OnOutputToBottleMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterOutputToBottleMessage message)
{ {
var user = message.Session.AttachedEntity; var user = message.Actor;
var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.OutputSlotName); var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.OutputSlotName);
if (maybeContainer is not { Valid: true } container if (maybeContainer is not { Valid: true } container
|| !_solutionContainerSystem.TryGetSolution(container, SharedChemMaster.BottleSolutionName, out var soln, out var solution)) || !_solutionContainerSystem.TryGetSolution(container, SharedChemMaster.BottleSolutionName, out var soln, out var solution))
@@ -260,18 +251,9 @@ namespace Content.Server.Chemistry.EntitySystems
_labelSystem.Label(container, message.Label); _labelSystem.Label(container, message.Label);
_solutionContainerSystem.TryAddSolution(soln.Value, withdrawal); _solutionContainerSystem.TryAddSolution(soln.Value, withdrawal);
if (user.HasValue)
{
// Log bottle creation by a user // Log bottle creation by a user
_adminLogger.Add(LogType.Action, LogImpact.Low, _adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user.Value):user} bottled {ToPrettyString(container):bottle} {SolutionContainerSystem.ToPrettyString(solution)}"); $"{ToPrettyString(user):user} bottled {ToPrettyString(container):bottle} {SharedSolutionContainerSystem.ToPrettyString(solution)}");
}
else
{
// Log bottle creation by magic? This should never happen... right?
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"Unknown bottled {ToPrettyString(container):bottle} {SolutionContainerSystem.ToPrettyString(solution)}");
}
UpdateUiState(chemMaster); UpdateUiState(chemMaster);
ClickSound(chemMaster); ClickSound(chemMaster);

View File

@@ -62,7 +62,7 @@ namespace Content.Server.Chemistry.EntitySystems
var inventory = GetInventory(reagentDispenser); var inventory = GetInventory(reagentDispenser);
var state = new ReagentDispenserBoundUserInterfaceState(outputContainerInfo, GetNetEntity(outputContainer), inventory, reagentDispenser.Comp.DispenseAmount); var state = new ReagentDispenserBoundUserInterfaceState(outputContainerInfo, GetNetEntity(outputContainer), inventory, reagentDispenser.Comp.DispenseAmount);
_userInterfaceSystem.TrySetUiState(reagentDispenser, ReagentDispenserUiKey.Key, state); _userInterfaceSystem.SetUiState(reagentDispenser.Owner, ReagentDispenserUiKey.Key, state);
} }
private ContainerInfo? BuildOutputContainerInfo(EntityUid? container) private ContainerInfo? BuildOutputContainerInfo(EntityUid? container)

View File

@@ -135,17 +135,17 @@ namespace Content.Server.Cloning
public void UpdateUserInterface(EntityUid consoleUid, CloningConsoleComponent consoleComponent) public void UpdateUserInterface(EntityUid consoleUid, CloningConsoleComponent consoleComponent)
{ {
if (!_uiSystem.TryGetUi(consoleUid, CloningConsoleUiKey.Key, out var ui)) if (!_uiSystem.HasUi(consoleUid, CloningConsoleUiKey.Key))
return; return;
if (!_powerReceiverSystem.IsPowered(consoleUid)) if (!_powerReceiverSystem.IsPowered(consoleUid))
{ {
_uiSystem.CloseAll(ui); _uiSystem.CloseUis(consoleUid);
return; return;
} }
var newState = GetUserInterfaceState(consoleComponent); var newState = GetUserInterfaceState(consoleComponent);
_uiSystem.SetUiState(ui, newState); _uiSystem.SetUiState(consoleUid, CloningConsoleUiKey.Key, newState);
} }
public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null) public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null)

View File

@@ -64,7 +64,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
return; return;
var state = new ChameleonBoundUserInterfaceState(component.Slot, component.Default); var state = new ChameleonBoundUserInterfaceState(component.Slot, component.Default);
_uiSystem.TrySetUiState(uid, ChameleonUiKey.Key, state); _uiSystem.SetUiState(uid, ChameleonUiKey.Key, state);
} }
/// <summary> /// <summary>

View File

@@ -82,8 +82,8 @@ namespace Content.Server.Communications
comp.UIUpdateAccumulator -= UIUpdateInterval; comp.UIUpdateAccumulator -= UIUpdateInterval;
if (_uiSystem.TryGetUi(uid, CommunicationsConsoleUiKey.Key, out var ui) && ui.SubscribedSessions.Count > 0) if (_uiSystem.IsUiOpen(uid, CommunicationsConsoleUiKey.Key))
UpdateCommsConsoleInterface(uid, comp, ui); UpdateCommsConsoleInterface(uid, comp);
} }
base.Update(frameTime); base.Update(frameTime);
@@ -136,11 +136,8 @@ namespace Content.Server.Communications
/// <summary> /// <summary>
/// Updates the UI for a particular comms console. /// Updates the UI for a particular comms console.
/// </summary> /// </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); var stationUid = _stationSystem.GetOwningStation(uid);
List<string>? levels = null; List<string>? levels = null;
string currentLevel = default!; 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), CanAnnounce(comp),
CanCallOrRecall(comp), CanCallOrRecall(comp),
levels, levels,
@@ -219,12 +216,12 @@ namespace Content.Server.Communications
private void OnSelectAlertLevelMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleSelectAlertLevelMessage message) 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; return;
if (!CanUse(mob, uid)) 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; return;
} }
@@ -241,7 +238,7 @@ namespace Content.Server.Communications
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength); var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
var msg = SharedChatSystem.SanitizeAnnouncement(message.Message, maxLength); var msg = SharedChatSystem.SanitizeAnnouncement(message.Message, maxLength);
var author = Loc.GetString("comms-console-announcement-unknown-sender"); 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)) if (!CanAnnounce(comp))
{ {
@@ -250,7 +247,7 @@ namespace Content.Server.Communications
if (!CanUse(mob, uid)) 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; return;
} }
@@ -263,7 +260,7 @@ namespace Content.Server.Communications
comp.AnnouncementCooldownRemaining = comp.Delay; comp.AnnouncementCooldownRemaining = comp.Delay;
UpdateCommsConsoleInterface(uid, comp); 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); RaiseLocalEvent(ref ev);
// allow admemes with vv // allow admemes with vv
@@ -275,15 +272,14 @@ namespace Content.Server.Communications
{ {
_chatSystem.DispatchGlobalAnnouncement(msg, title, announcementSound: comp.Sound, colorOverride: comp.Color); _chatSystem.DispatchGlobalAnnouncement(msg, title, announcementSound: comp.Sound, colorOverride: comp.Color);
if (message.Session.AttachedEntity != null) _adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Actor):player} has sent the following global announcement: {msg}");
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following global announcement: {msg}");
return; return;
} }
_chatSystem.DispatchStationAnnouncement(uid, msg, title, colorOverride: comp.Color); _chatSystem.DispatchStationAnnouncement(uid, msg, title, colorOverride: comp.Color);
if (message.Session.AttachedEntity != null) _adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Actor):player} has sent the following station announcement: {msg}");
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following station announcement: {msg}");
} }
private void OnBroadcastMessage(EntityUid uid, CommunicationsConsoleComponent component, CommunicationsConsoleBroadcastMessage message) private void OnBroadcastMessage(EntityUid uid, CommunicationsConsoleComponent component, CommunicationsConsoleBroadcastMessage message)
@@ -298,8 +294,7 @@ namespace Content.Server.Communications
_deviceNetworkSystem.QueuePacket(uid, null, payload, net.TransmitFrequency); _deviceNetworkSystem.QueuePacket(uid, null, payload, net.TransmitFrequency);
if (message.Session.AttachedEntity != null) _adminLogger.Add(LogType.DeviceNetwork, LogImpact.Low, $"{ToPrettyString(message.Actor):player} has sent the following broadcast: {message.Message:msg}");
_adminLogger.Add(LogType.DeviceNetwork, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following broadcast: {message.Message:msg}");
} }
private void OnCallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleCallEmergencyShuttleMessage message) private void OnCallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleCallEmergencyShuttleMessage message)
@@ -307,12 +302,11 @@ namespace Content.Server.Communications
if (!CanCallOrRecall(comp)) if (!CanCallOrRecall(comp))
return; return;
if (message.Session.AttachedEntity is not { Valid: true } mob) var mob = message.Actor;
return;
if (!CanUse(mob, uid)) 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; return;
} }
@@ -320,7 +314,7 @@ namespace Content.Server.Communications
RaiseLocalEvent(ref ev); RaiseLocalEvent(ref ev);
if (ev.Cancelled) 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; return;
} }
@@ -333,17 +327,14 @@ namespace Content.Server.Communications
if (!CanCallOrRecall(comp)) if (!CanCallOrRecall(comp))
return; return;
if (message.Session.AttachedEntity is not { Valid: true } mob) if (!CanUse(message.Actor, uid))
return;
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; return;
} }
_roundEndSystem.CancelRoundEndCountdown(uid); _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.");
} }
} }

View File

@@ -30,10 +30,7 @@ public sealed class ConfigurationSystem : EntitySystem
if (!TryComp(args.Used, out ToolComponent? tool) || !tool.Qualities.Contains(component.QualityNeeded)) if (!TryComp(args.Used, out ToolComponent? tool) || !tool.Qualities.Contains(component.QualityNeeded))
return; return;
if (!TryComp(args.User, out ActorComponent? actor)) args.Handled = _uiSystem.TryOpenUi(uid, ConfigurationUiKey.Key, args.User);
return;
args.Handled = _uiSystem.TryOpen(uid, ConfigurationUiKey.Key, actor.PlayerSession);
} }
private void OnStartup(EntityUid uid, ConfigurationComponent component, ComponentStartup args) private void OnStartup(EntityUid uid, ConfigurationComponent component, ComponentStartup args)
@@ -43,8 +40,8 @@ public sealed class ConfigurationSystem : EntitySystem
private void UpdateUi(EntityUid uid, ConfigurationComponent component) private void UpdateUi(EntityUid uid, ConfigurationComponent component)
{ {
if (_uiSystem.TryGetUi(uid, ConfigurationUiKey.Key, out var ui)) if (_uiSystem.HasUi(uid, ConfigurationUiKey.Key))
_uiSystem.SetUiState(ui, new ConfigurationBoundUserInterfaceState(component.Config)); _uiSystem.SetUiState(uid, ConfigurationUiKey.Key, new ConfigurationBoundUserInterfaceState(component.Config));
} }
private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args) private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args)

View File

@@ -90,19 +90,14 @@ public sealed class CrayonSystem : SharedCrayonSystem
if (args.Handled) if (args.Handled)
return; return;
if (!TryComp<ActorComponent>(args.User, out var actor) || if (!_uiSystem.HasUi(uid, SharedCrayonComponent.CrayonUiKey.Key))
!_uiSystem.TryGetUi(uid, SharedCrayonComponent.CrayonUiKey.Key, out var ui))
{ {
return; return;
} }
_uiSystem.ToggleUi(ui, actor.PlayerSession); _uiSystem.TryToggleUi(uid, SharedCrayonComponent.CrayonUiKey.Key, args.User);
if (ui.SubscribedSessions.Contains(actor.PlayerSession))
{
// Tell the user interface the selected stuff
_uiSystem.SetUiState(ui, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
}
_uiSystem.SetUiState(uid, SharedCrayonComponent.CrayonUiKey.Key, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
args.Handled = true; args.Handled = true;
} }
@@ -140,8 +135,8 @@ public sealed class CrayonSystem : SharedCrayonSystem
private void OnCrayonDropped(EntityUid uid, CrayonComponent component, DroppedEvent args) private void OnCrayonDropped(EntityUid uid, CrayonComponent component, DroppedEvent args)
{ {
if (TryComp<ActorComponent>(args.User, out var actor)) // TODO: Use the existing event.
_uiSystem.TryClose(uid, SharedCrayonComponent.CrayonUiKey.Key, actor.PlayerSession); _uiSystem.CloseUi(uid, SharedCrayonComponent.CrayonUiKey.Key, args.User);
} }
private void UseUpCrayon(EntityUid uid, EntityUid user) private void UseUpCrayon(EntityUid uid, EntityUid user)

View File

@@ -100,12 +100,12 @@ public sealed class CrewManifestSystem : EntitySystem
return; return;
var owningStation = _stationSystem.GetOwningStation(uid); var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || ev.Session is not { } session) if (owningStation == null || !TryComp(ev.Actor, out ActorComponent? actorComp))
{ {
return; return;
} }
CloseEui(owningStation.Value, session, uid); CloseEui(owningStation.Value, actorComp.PlayerSession, uid);
} }
/// <summary> /// <summary>
@@ -136,12 +136,12 @@ public sealed class CrewManifestSystem : EntitySystem
{ {
Log.Error( Log.Error(
"{User} tried to open crew manifest from wrong UI: {Key}. Correct owned is {ExpectedKey}", "{User} tried to open crew manifest from wrong UI: {Key}. Correct owned is {ExpectedKey}",
msg.Session, msg.UiKey, component.OwnerKey); msg.Actor, msg.UiKey, component.OwnerKey);
return; return;
} }
var owningStation = _stationSystem.GetOwningStation(uid); var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || msg.Session is not { } session) if (owningStation == null || !TryComp(msg.Actor, out ActorComponent? actorComp))
{ {
return; return;
} }
@@ -151,7 +151,7 @@ public sealed class CrewManifestSystem : EntitySystem
return; return;
} }
OpenEui(owningStation.Value, session, uid); OpenEui(owningStation.Value, actorComp.PlayerSession, uid);
} }
/// <summary> /// <summary>

View File

@@ -77,7 +77,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
msg.Status == SecurityStatus.Suspected != (msg.Reason != null)) msg.Status == SecurityStatus.Suspected != (msg.Reason != null))
return; return;
if (!CheckSelected(ent, msg.Session, out var mob, out var key)) if (!CheckSelected(ent, msg.Actor, out var mob, out var key))
return; return;
if (!_stationRecords.TryGetRecord<CriminalRecord>(key.Value, out var record) || record.Status == msg.Status) if (!_stationRecords.TryGetRecord<CriminalRecord>(key.Value, out var record) || record.Status == msg.Status)
@@ -150,7 +150,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
private void OnAddHistory(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordAddHistory msg) private void OnAddHistory(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordAddHistory msg)
{ {
if (!CheckSelected(ent, msg.Session, out _, out var key)) if (!CheckSelected(ent, msg.Actor, out _, out var key))
return; return;
var line = msg.Line.Trim(); var line = msg.Line.Trim();
@@ -167,7 +167,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
private void OnDeleteHistory(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordDeleteHistory msg) private void OnDeleteHistory(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordDeleteHistory msg)
{ {
if (!CheckSelected(ent, msg.Session, out _, out var key)) if (!CheckSelected(ent, msg.Actor, out _, out var key))
return; return;
if (!_criminalRecords.TryDeleteHistory(key.Value, msg.Index)) if (!_criminalRecords.TryDeleteHistory(key.Value, msg.Index))
@@ -185,7 +185,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
if (!TryComp<StationRecordsComponent>(owningStation, out var stationRecords)) if (!TryComp<StationRecordsComponent>(owningStation, out var stationRecords))
{ {
_ui.TrySetUiState(uid, CriminalRecordsConsoleKey.Key, new CriminalRecordsConsoleState()); _ui.SetUiState(uid, CriminalRecordsConsoleKey.Key, new CriminalRecordsConsoleState());
return; return;
} }
@@ -201,24 +201,22 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
state.SelectedKey = id; state.SelectedKey = id;
} }
_ui.TrySetUiState(uid, CriminalRecordsConsoleKey.Key, state); _ui.SetUiState(uid, CriminalRecordsConsoleKey.Key, state);
} }
/// <summary> /// <summary>
/// Boilerplate that most actions use, if they require that a record be selected. /// Boilerplate that most actions use, if they require that a record be selected.
/// Obviously shouldn't be used for selecting records. /// Obviously shouldn't be used for selecting records.
/// </summary> /// </summary>
private bool CheckSelected(Entity<CriminalRecordsConsoleComponent> ent, ICommonSession session, private bool CheckSelected(Entity<CriminalRecordsConsoleComponent> ent, EntityUid user,
[NotNullWhen(true)] out EntityUid? mob, [NotNullWhen(true)] out StationRecordKey? key) [NotNullWhen(true)] out EntityUid? mob, [NotNullWhen(true)] out StationRecordKey? key)
{ {
key = null; key = null;
mob = null; mob = null;
if (session.AttachedEntity is not { } user)
return false;
if (!_access.IsAllowed(user, ent)) if (!_access.IsAllowed(user, ent))
{ {
_popup.PopupEntity(Loc.GetString("criminal-records-permission-denied"), ent, session); _popup.PopupEntity(Loc.GetString("criminal-records-permission-denied"), ent, user);
return false; return false;
} }

View File

@@ -48,9 +48,9 @@ public sealed class SignalTimerSystem : EntitySystem
{ {
var time = TryComp<ActiveSignalTimerComponent>(uid, out var active) ? active.TriggerTime : TimeSpan.Zero; var time = TryComp<ActiveSignalTimerComponent>(uid, out var active) ? active.TriggerTime : TimeSpan.Zero;
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui)) if (_ui.HasUi(uid, SignalTimerUiKey.Key))
{ {
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label, _ui.SetUiState(uid, SignalTimerUiKey.Key, new SignalTimerBoundUserInterfaceState(component.Label,
TimeSpan.FromSeconds(component.Delay).Minutes.ToString("D2"), TimeSpan.FromSeconds(component.Delay).Minutes.ToString("D2"),
TimeSpan.FromSeconds(component.Delay).Seconds.ToString("D2"), TimeSpan.FromSeconds(component.Delay).Seconds.ToString("D2"),
component.CanEditLabel, component.CanEditLabel,
@@ -70,9 +70,9 @@ public sealed class SignalTimerSystem : EntitySystem
_audio.PlayPvs(signalTimer.DoneSound, uid); _audio.PlayPvs(signalTimer.DoneSound, uid);
_signalSystem.InvokePort(uid, signalTimer.TriggerPort); _signalSystem.InvokePort(uid, signalTimer.TriggerPort);
if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui)) if (_ui.HasUi(uid, SignalTimerUiKey.Key))
{ {
_ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label, _ui.SetUiState(uid, SignalTimerUiKey.Key, new SignalTimerBoundUserInterfaceState(signalTimer.Label,
TimeSpan.FromSeconds(signalTimer.Delay).Minutes.ToString("D2"), TimeSpan.FromSeconds(signalTimer.Delay).Minutes.ToString("D2"),
TimeSpan.FromSeconds(signalTimer.Delay).Seconds.ToString("D2"), TimeSpan.FromSeconds(signalTimer.Delay).Seconds.ToString("D2"),
signalTimer.CanEditLabel, signalTimer.CanEditLabel,
@@ -117,10 +117,7 @@ public sealed class SignalTimerSystem : EntitySystem
/// <param name="uid">The entity that is interacted with.</param> /// <param name="uid">The entity that is interacted with.</param>
private bool IsMessageValid(EntityUid uid, BoundUserInterfaceMessage message) private bool IsMessageValid(EntityUid uid, BoundUserInterfaceMessage message)
{ {
if (message.Session.AttachedEntity is not { Valid: true } mob) if (!_accessReader.IsAllowed(message.Actor, uid))
return false;
if (!_accessReader.IsAllowed(mob, uid))
return false; return false;
return true; return true;

View File

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

View File

@@ -159,8 +159,7 @@ public sealed class MailingUnitSystem : EntitySystem
args.Handled = true; args.Handled = true;
UpdateTargetList(uid, component); UpdateTargetList(uid, component);
if (_userInterfaceSystem.TryGetUi(uid, MailingUnitUiKey.Key, out var bui)) _userInterfaceSystem.OpenUi(uid, MailingUnitUiKey.Key, actor.PlayerSession);
_userInterfaceSystem.OpenUi(bui, actor.PlayerSession);
} }
/// <summary> /// <summary>
@@ -178,8 +177,7 @@ public sealed class MailingUnitSystem : EntitySystem
return; return;
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag); var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag);
if (_userInterfaceSystem.TryGetUi(uid, MailingUnitUiKey.Key, out var bui)) _userInterfaceSystem.SetUiState(uid, MailingUnitUiKey.Key, state);
_userInterfaceSystem.SetUiState(bui, state);
} }
private void OnTargetSelected(EntityUid uid, MailingUnitComponent component, TargetSelectedMessage args) private void OnTargetSelected(EntityUid uid, MailingUnitComponent component, TargetSelectedMessage args)

View File

@@ -101,8 +101,9 @@ namespace Content.Server.Disposal.Tube
/// <param name="msg">A user interface message from the client.</param> /// <param name="msg">A user interface message from the client.</param>
private void OnUiAction(EntityUid uid, DisposalRouterComponent router, SharedDisposalRouterComponent.UiActionMessage msg) private void OnUiAction(EntityUid uid, DisposalRouterComponent router, SharedDisposalRouterComponent.UiActionMessage msg)
{ {
if (!EntityManager.EntityExists(msg.Session.AttachedEntity)) if (!EntityManager.EntityExists(msg.Actor))
return; return;
if (TryComp<PhysicsComponent>(uid, out var physBody) && physBody.BodyType != BodyType.Static) if (TryComp<PhysicsComponent>(uid, out var physBody) && physBody.BodyType != BodyType.Static)
return; return;
@@ -279,9 +280,9 @@ namespace Content.Server.Disposal.Tube
private void OnOpenTaggerUI(EntityUid uid, DisposalTaggerComponent tagger, BoundUIOpenedEvent args) private void OnOpenTaggerUI(EntityUid uid, DisposalTaggerComponent tagger, BoundUIOpenedEvent args)
{ {
if (_uiSystem.TryGetUi(uid, DisposalTaggerUiKey.Key, out var bui)) if (_uiSystem.HasUi(uid, DisposalTaggerUiKey.Key))
{ {
_uiSystem.SetUiState(bui, _uiSystem.SetUiState(uid, DisposalTaggerUiKey.Key,
new DisposalTaggerUserInterfaceState(tagger.Tag)); new DisposalTaggerUserInterfaceState(tagger.Tag));
} }
} }
@@ -292,13 +293,9 @@ namespace Content.Server.Disposal.Tube
/// <returns>Returns a <see cref="SharedDisposalRouterComponent.DisposalRouterUserInterfaceState"/></returns> /// <returns>Returns a <see cref="SharedDisposalRouterComponent.DisposalRouterUserInterfaceState"/></returns>
private void UpdateRouterUserInterface(EntityUid uid, DisposalRouterComponent router) private void UpdateRouterUserInterface(EntityUid uid, DisposalRouterComponent router)
{ {
var bui = _uiSystem.GetUiOrNull(uid, DisposalRouterUiKey.Key);
if (bui == null)
return;
if (router.Tags.Count <= 0) if (router.Tags.Count <= 0)
{ {
_uiSystem.SetUiState(bui, new DisposalRouterUserInterfaceState("")); _uiSystem.SetUiState(uid, DisposalRouterUiKey.Key, new DisposalRouterUserInterfaceState(""));
return; return;
} }
@@ -312,7 +309,7 @@ namespace Content.Server.Disposal.Tube
taglist.Remove(taglist.Length - 2, 2); taglist.Remove(taglist.Length - 2, 2);
_uiSystem.SetUiState(bui, new DisposalRouterUserInterfaceState(taglist.ToString())); _uiSystem.SetUiState(uid, DisposalRouterUiKey.Key, new DisposalRouterUserInterfaceState(taglist.ToString()));
} }
private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args) private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args)

View File

@@ -219,7 +219,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
#region UI Handlers #region UI Handlers
private void OnUiButtonPressed(EntityUid uid, SharedDisposalUnitComponent component, SharedDisposalUnitComponent.UiButtonPressedMessage args) private void OnUiButtonPressed(EntityUid uid, SharedDisposalUnitComponent component, SharedDisposalUnitComponent.UiButtonPressedMessage args)
{ {
if (args.Session.AttachedEntity is not { Valid: true } player) if (args.Actor is not { Valid: true } player)
{ {
return; return;
} }
@@ -235,7 +235,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} hit flush button on {ToPrettyString(uid)}, it's now {(component.Engaged ? "on" : "off")}"); _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} hit flush button on {ToPrettyString(uid)}, it's now {(component.Engaged ? "on" : "off")}");
break; break;
case SharedDisposalUnitComponent.UiButton.Power: case SharedDisposalUnitComponent.UiButton.Power:
_power.TogglePower(uid, user: args.Session.AttachedEntity); _power.TogglePower(uid, user: args.Actor);
break; break;
default: default:
throw new ArgumentOutOfRangeException($"{ToPrettyString(player):player} attempted to hit a nonexistant button on {ToPrettyString(uid)}"); throw new ArgumentOutOfRangeException($"{ToPrettyString(player):player} attempted to hit a nonexistant button on {ToPrettyString(uid)}");
@@ -268,7 +268,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
} }
args.Handled = true; args.Handled = true;
_ui.TryOpen(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, actor.PlayerSession); _ui.OpenUi(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, actor.PlayerSession);
} }
private void OnAfterInteractUsing(EntityUid uid, SharedDisposalUnitComponent component, AfterInteractUsingEvent args) private void OnAfterInteractUsing(EntityUid uid, SharedDisposalUnitComponent component, AfterInteractUsingEvent args)
@@ -597,7 +597,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
var compState = GetState(uid, component); var compState = GetState(uid, component);
var stateString = Loc.GetString($"disposal-unit-state-{compState}"); var stateString = Loc.GetString($"disposal-unit-state-{compState}");
var state = new SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState(Name(uid), stateString, EstimatedFullPressure(uid, component), powered, component.Engaged); var state = new SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState(Name(uid), stateString, EstimatedFullPressure(uid, component), powered, component.Engaged);
_ui.TrySetUiState(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, state); _ui.SetUiState(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, state);
var stateUpdatedEvent = new DisposalUnitUIStateUpdatedEvent(state); var stateUpdatedEvent = new DisposalUnitUIStateUpdatedEvent(state);
RaiseLocalEvent(uid, stateUpdatedEvent); RaiseLocalEvent(uid, stateUpdatedEvent);
@@ -802,10 +802,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
QueueAutomaticEngage(uid, component); QueueAutomaticEngage(uid, component);
if (TryComp(inserted, out ActorComponent? actor)) _ui.CloseUi(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, inserted);
{
_ui.TryClose(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, actor.PlayerSession);
}
// Maybe do pullable instead? Eh still fine. // Maybe do pullable instead? Eh still fine.
Joints.RecursiveClearJoints(inserted); Joints.RecursiveClearJoints(inserted);

View File

@@ -39,7 +39,7 @@ public sealed class DoorElectronicsSystem : EntitySystem
} }
var state = new DoorElectronicsConfigurationState(accesses); var state = new DoorElectronicsConfigurationState(accesses);
_uiSystem.TrySetUiState(uid, DoorElectronicsConfigurationUiKey.Key, state); _uiSystem.SetUiState(uid, DoorElectronicsConfigurationUiKey.Key, state);
} }
private void OnChangeConfiguration( private void OnChangeConfiguration(

View File

@@ -3,7 +3,7 @@ using Robust.Shared.GameStates;
namespace Content.Server.Extinguisher; namespace Content.Server.Extinguisher;
[NetworkedComponent, RegisterComponent] [RegisterComponent]
[Access(typeof(FireExtinguisherSystem))] [Access(typeof(FireExtinguisherSystem))]
public sealed partial class FireExtinguisherComponent : SharedFireExtinguisherComponent public sealed partial class FireExtinguisherComponent : SharedFireExtinguisherComponent
{ {

View File

@@ -5,6 +5,7 @@ using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Eye.Blinding.Systems; using Content.Shared.Eye.Blinding.Systems;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Collections;
namespace Content.Server.Eye.Blinding; namespace Content.Server.Eye.Blinding;
@@ -37,24 +38,19 @@ public sealed class ActivatableUIRequiresVisionSystem : EntitySystem
if (!args.Blind) if (!args.Blind)
return; return;
if (!TryComp<ActorComponent>(uid, out var actor)) var toClose = new ValueList<(EntityUid Entity, Enum Key)>();
return;
var uiList = _userInterfaceSystem.GetAllUIsForSession(actor.PlayerSession); foreach (var bui in _userInterfaceSystem.GetActorUis(uid))
if (uiList == null)
return;
Queue<PlayerBoundUserInterface> closeList = new(); // foreach collection modified moment
foreach (var ui in uiList)
{ {
if (HasComp<ActivatableUIRequiresVisionComponent>(ui.Owner)) if (HasComp<ActivatableUIRequiresVisionComponent>(bui.Entity))
closeList.Enqueue(ui); {
toClose.Add(bui);
}
} }
foreach (var ui in closeList) foreach (var bui in toClose)
{ {
_userInterfaceSystem.CloseUi(ui, actor.PlayerSession); _userInterfaceSystem.CloseUi(bui.Entity, bui.Key, uid);
} }
} }
} }

View File

@@ -318,7 +318,7 @@ public sealed class FaxSystem : EntitySystem
private void OnSendButtonPressed(EntityUid uid, FaxMachineComponent component, FaxSendMessage args) private void OnSendButtonPressed(EntityUid uid, FaxMachineComponent component, FaxSendMessage args)
{ {
Send(uid, component, args.Session.AttachedEntity); Send(uid, component, args.Actor);
} }
private void OnRefreshButtonPressed(EntityUid uid, FaxMachineComponent component, FaxRefreshMessage args) private void OnRefreshButtonPressed(EntityUid uid, FaxMachineComponent component, FaxRefreshMessage args)
@@ -358,7 +358,7 @@ public sealed class FaxSystem : EntitySystem
component.SendTimeoutRemaining <= 0 && component.SendTimeoutRemaining <= 0 &&
component.InsertingTimeRemaining <= 0; component.InsertingTimeRemaining <= 0;
var state = new FaxUiState(component.FaxName, component.KnownFaxes, canSend, canCopy, isPaperInserted, component.DestinationFaxAddress); var state = new FaxUiState(component.FaxName, component.KnownFaxes, canSend, canCopy, isPaperInserted, component.DestinationFaxAddress);
_userInterface.TrySetUiState(uid, FaxUiKey.Key, state); _userInterface.SetUiState(uid, FaxUiKey.Key, state);
} }
/// <summary> /// <summary>
@@ -417,12 +417,8 @@ public sealed class FaxSystem : EntitySystem
UpdateUserInterface(uid, component); UpdateUserInterface(uid, component);
if (args.Session.AttachedEntity != null)
_adminLogger.Add(LogType.Action, LogImpact.Low, _adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} added print job to {ToPrettyString(uid):tool} with text: {args.Content}"); $"{ToPrettyString(args.Actor):actor} added print job to {ToPrettyString(uid):tool} with text: {args.Content}");
else
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"Someone added print job to {ToPrettyString(uid):tool} with text: {args.Content}");
} }
/// <summary> /// <summary>
@@ -457,9 +453,8 @@ public sealed class FaxSystem : EntitySystem
UpdateUserInterface(uid, component); UpdateUserInterface(uid, component);
if (args.Session.AttachedEntity != null)
_adminLogger.Add(LogType.Action, LogImpact.Low, _adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(args.Session.AttachedEntity.Value):actor} added copy job to {ToPrettyString(uid):tool} with text: {ToPrettyString(component.PaperSlot.Item):subject}"); $"{ToPrettyString(args.Actor):actor} added copy job to {ToPrettyString(uid):tool} with text: {ToPrettyString(component.PaperSlot.Item):subject}");
} }
/// <summary> /// <summary>

View File

@@ -52,8 +52,7 @@ namespace Content.Server.Forensics
component.PrintCooldown, component.PrintCooldown,
component.PrintReadyAt); component.PrintReadyAt);
if (!_uiSystem.TrySetUiState(uid, ForensicScannerUiKey.Key, state)) _uiSystem.SetUiState(uid, ForensicScannerUiKey.Key, state);
Log.Warning($"{ToPrettyString(uid)} was unable to set UI state.");
} }
private void OnDoAfter(EntityUid uid, ForensicScannerComponent component, DoAfterEvent args) private void OnDoAfter(EntityUid uid, ForensicScannerComponent component, DoAfterEvent args)
@@ -163,23 +162,14 @@ namespace Content.Server.Forensics
private void OpenUserInterface(EntityUid user, Entity<ForensicScannerComponent> scanner) private void OpenUserInterface(EntityUid user, Entity<ForensicScannerComponent> scanner)
{ {
if (!TryComp<ActorComponent>(user, out var actor))
return;
UpdateUserInterface(scanner, scanner.Comp); UpdateUserInterface(scanner, scanner.Comp);
_uiSystem.TryOpen(scanner, ForensicScannerUiKey.Key, actor.PlayerSession); _uiSystem.OpenUi(scanner.Owner, ForensicScannerUiKey.Key, user);
} }
private void OnPrint(EntityUid uid, ForensicScannerComponent component, ForensicScannerPrintMessage args) private void OnPrint(EntityUid uid, ForensicScannerComponent component, ForensicScannerPrintMessage args)
{ {
if (!args.Session.AttachedEntity.HasValue) var user = args.Actor;
{
Log.Warning($"{ToPrettyString(uid)} got OnPrint without Session.AttachedEntity");
return;
}
var user = args.Session.AttachedEntity.Value;
if (_gameTiming.CurTime < component.PrintReadyAt) if (_gameTiming.CurTime < component.PrintReadyAt)
{ {
@@ -191,7 +181,7 @@ namespace Content.Server.Forensics
// Spawn a piece of paper. // Spawn a piece of paper.
var printed = EntityManager.SpawnEntity(component.MachineOutput, Transform(uid).Coordinates); var printed = EntityManager.SpawnEntity(component.MachineOutput, Transform(uid).Coordinates);
_handsSystem.PickupOrDrop(args.Session.AttachedEntity, printed, checkActionBlocker: false); _handsSystem.PickupOrDrop(args.Actor, printed, checkActionBlocker: false);
if (!HasComp<PaperComponent>(printed)) if (!HasComp<PaperComponent>(printed))
{ {
@@ -240,9 +230,6 @@ namespace Content.Server.Forensics
private void OnClear(EntityUid uid, ForensicScannerComponent component, ForensicScannerClearMessage args) private void OnClear(EntityUid uid, ForensicScannerComponent component, ForensicScannerClearMessage args)
{ {
if (!args.Session.AttachedEntity.HasValue)
return;
component.Fingerprints = new(); component.Fingerprints = new();
component.Fibers = new(); component.Fibers = new();
component.DNAs = new(); component.DNAs = new();

View File

@@ -129,7 +129,7 @@ public sealed class GatewaySystem : EntitySystem
unlockTime unlockTime
); );
_ui.TrySetUiState(uid, GatewayUiKey.Key, state); _ui.SetUiState(uid, GatewayUiKey.Key, state);
} }
private void UpdateAppearance(EntityUid uid) private void UpdateAppearance(EntityUid uid)
@@ -139,12 +139,14 @@ public sealed class GatewaySystem : EntitySystem
private void OnOpenPortal(EntityUid uid, GatewayComponent comp, GatewayOpenPortalMessage args) private void OnOpenPortal(EntityUid uid, GatewayComponent comp, GatewayOpenPortalMessage args)
{ {
if (args.Session.AttachedEntity == null || GetNetEntity(uid) == args.Destination || if (GetNetEntity(uid) == args.Destination ||
!comp.Enabled || !comp.Interactable) !comp.Enabled || !comp.Interactable)
{
return; return;
}
// if the gateway has an access reader check it before allowing opening // if the gateway has an access reader check it before allowing opening
var user = args.Session.AttachedEntity.Value; var user = args.Actor;
if (CheckAccess(user, uid, comp)) if (CheckAccess(user, uid, comp))
return; return;

View File

@@ -131,13 +131,13 @@ namespace Content.Server.Gravity
} }
private void SetSwitchedOn(EntityUid uid, GravityGeneratorComponent component, bool on, private void SetSwitchedOn(EntityUid uid, GravityGeneratorComponent component, bool on,
ApcPowerReceiverComponent? powerReceiver = null, ICommonSession? session = null) ApcPowerReceiverComponent? powerReceiver = null, EntityUid? user = null)
{ {
if (!Resolve(uid, ref powerReceiver)) if (!Resolve(uid, ref powerReceiver))
return; return;
if (session is { AttachedEntity: { } }) if (user != null)
_adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{session:player} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}"); _adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{ToPrettyString(user)} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}");
component.SwitchedOn = on; component.SwitchedOn = on;
UpdatePowerState(component, powerReceiver); UpdatePowerState(component, powerReceiver);
@@ -154,7 +154,7 @@ namespace Content.Server.Gravity
private void UpdateUI(Entity<GravityGeneratorComponent, ApcPowerReceiverComponent> ent, float chargeRate) private void UpdateUI(Entity<GravityGeneratorComponent, ApcPowerReceiverComponent> ent, float chargeRate)
{ {
var (_, component, powerReceiver) = ent; var (_, component, powerReceiver) = ent;
if (!_uiSystem.IsUiOpen(ent, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key)) if (!_uiSystem.IsUiOpen(ent.Owner, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key))
return; return;
var chargeTarget = chargeRate < 0 ? 0 : component.MaxCharge; var chargeTarget = chargeRate < 0 ? 0 : component.MaxCharge;
@@ -189,8 +189,8 @@ namespace Content.Server.Gravity
chargeEta chargeEta
); );
_uiSystem.TrySetUiState( _uiSystem.SetUiState(
ent, ent.Owner,
SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key,
state); state);
@@ -209,9 +209,6 @@ namespace Content.Server.Gravity
private void OnInteractHand(EntityUid uid, GravityGeneratorComponent component, InteractHandEvent args) private void OnInteractHand(EntityUid uid, GravityGeneratorComponent component, InteractHandEvent args)
{ {
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
ApcPowerReceiverComponent? powerReceiver = default!; ApcPowerReceiverComponent? powerReceiver = default!;
if (!Resolve(uid, ref powerReceiver)) if (!Resolve(uid, ref powerReceiver))
return; return;
@@ -220,7 +217,7 @@ namespace Content.Server.Gravity
if (!component.Intact || powerReceiver.PowerReceived < component.IdlePowerUse) if (!component.Intact || powerReceiver.PowerReceived < component.IdlePowerUse)
return; return;
_uiSystem.TryOpen(uid, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key, actor.PlayerSession); _uiSystem.OpenUi(uid, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key, args.User);
component.NeedUIUpdate = true; component.NeedUIUpdate = true;
} }
@@ -287,7 +284,7 @@ namespace Content.Server.Gravity
GravityGeneratorComponent component, GravityGeneratorComponent component,
SharedGravityGeneratorComponent.SwitchGeneratorMessage args) SharedGravityGeneratorComponent.SwitchGeneratorMessage args)
{ {
SetSwitchedOn(uid, component, args.On, session:args.Session); SetSwitchedOn(uid, component, args.On, user: args.Actor);
} }
} }
} }

View File

@@ -32,8 +32,8 @@ public sealed partial class HumanoidAppearanceSystem
Icon = new SpriteSpecifier.Rsi(new("/Textures/Mobs/Customization/reptilian_parts.rsi"), "tail_smooth"), Icon = new SpriteSpecifier.Rsi(new("/Textures/Mobs/Customization/reptilian_parts.rsi"), "tail_smooth"),
Act = () => Act = () =>
{ {
_uiSystem.TryOpen(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession); _uiSystem.OpenUi(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession);
_uiSystem.TrySetUiState( _uiSystem.SetUiState(
uid, uid,
HumanoidMarkingModifierKey.Key, HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.MarkingSet, component.Species, new HumanoidMarkingModifierState(component.MarkingSet, component.Species,
@@ -48,8 +48,7 @@ public sealed partial class HumanoidAppearanceSystem
private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent component, private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierBaseLayersSetMessage message) HumanoidMarkingModifierBaseLayersSetMessage message)
{ {
if (message.Session is not { } player if (!_adminManager.HasAdminFlag(message.Actor, AdminFlags.Fun))
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
{ {
return; return;
} }
@@ -67,7 +66,7 @@ public sealed partial class HumanoidAppearanceSystem
if (message.ResendState) if (message.ResendState)
{ {
_uiSystem.TrySetUiState( _uiSystem.SetUiState(
uid, uid,
HumanoidMarkingModifierKey.Key, HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.MarkingSet, component.Species, new HumanoidMarkingModifierState(component.MarkingSet, component.Species,
@@ -81,8 +80,7 @@ public sealed partial class HumanoidAppearanceSystem
private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component, private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierMarkingSetMessage message) HumanoidMarkingModifierMarkingSetMessage message)
{ {
if (message.Session is not { } player if (!_adminManager.HasAdminFlag(message.Actor, AdminFlags.Fun))
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
{ {
return; return;
} }
@@ -92,7 +90,7 @@ public sealed partial class HumanoidAppearanceSystem
if (message.ResendState) if (message.ResendState)
{ {
_uiSystem.TrySetUiState( _uiSystem.SetUiState(
uid, uid,
HumanoidMarkingModifierKey.Key, HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.MarkingSet, component.Species, new HumanoidMarkingModifierState(component.MarkingSet, component.Species,

View File

@@ -1,6 +1,7 @@
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.Instruments; using Content.Shared.Instruments;
using Robust.Shared.Player; using Robust.Shared.Player;
using ActivatableUIComponent = Content.Shared.UserInterface.ActivatableUIComponent;
namespace Content.Server.Instruments; namespace Content.Server.Instruments;
@@ -16,9 +17,9 @@ public sealed partial class InstrumentComponent : SharedInstrumentComponent
[ViewVariables] public uint LastSequencerTick = 0; [ViewVariables] public uint LastSequencerTick = 0;
// TODO Instruments: Make this ECS // TODO Instruments: Make this ECS
public ICommonSession? InstrumentPlayer => public EntityUid? InstrumentPlayer =>
_entMan.GetComponentOrNull<ActivatableUIComponent>(Owner)?.CurrentSingleUser _entMan.GetComponentOrNull<ActivatableUIComponent>(Owner)?.CurrentSingleUser
?? _entMan.GetComponentOrNull<ActorComponent>(Owner)?.PlayerSession; ?? _entMan.GetComponentOrNull<ActorComponent>(Owner)?.PlayerSession.AttachedEntity;
} }
[RegisterComponent] [RegisterComponent]

View File

@@ -111,7 +111,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument)) if (!TryComp(uid, out InstrumentComponent? instrument))
return; return;
if (args.SenderSession != instrument.InstrumentPlayer) if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return; return;
instrument.Playing = true; instrument.Playing = true;
@@ -125,7 +125,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument)) if (!TryComp(uid, out InstrumentComponent? instrument))
return; return;
if (args.SenderSession != instrument.InstrumentPlayer) if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return; return;
Clean(uid, instrument); Clean(uid, instrument);
@@ -142,7 +142,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument)) if (!TryComp(uid, out InstrumentComponent? instrument))
return; return;
if (args.SenderSession != instrument.InstrumentPlayer) if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return; return;
if (master != null) if (master != null)
@@ -174,7 +174,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument)) if (!TryComp(uid, out InstrumentComponent? instrument))
return; return;
if (args.SenderSession != instrument.InstrumentPlayer) if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return; return;
if (msg.Channel == RobustMidiEvent.PercussionChannel && !instrument.AllowPercussion) if (msg.Channel == RobustMidiEvent.PercussionChannel && !instrument.AllowPercussion)
@@ -194,8 +194,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
private void OnBoundUIClosed(EntityUid uid, InstrumentComponent component, BoundUIClosedEvent args) private void OnBoundUIClosed(EntityUid uid, InstrumentComponent component, BoundUIClosedEvent args)
{ {
if (HasComp<ActiveInstrumentComponent>(uid) if (HasComp<ActiveInstrumentComponent>(uid)
&& _bui.TryGetUi(uid, args.UiKey, out var bui) && !_bui.IsUiOpen(uid, args.UiKey))
&& bui.SubscribedSessions.Count == 0)
{ {
RemComp<ActiveInstrumentComponent>(uid); RemComp<ActiveInstrumentComponent>(uid);
} }
@@ -232,7 +231,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
var instrumentQuery = EntityManager.GetEntityQuery<InstrumentComponent>(); var instrumentQuery = EntityManager.GetEntityQuery<InstrumentComponent>();
if (!TryComp(uid, out InstrumentComponent? originInstrument) if (!TryComp(uid, out InstrumentComponent? originInstrument)
|| originInstrument.InstrumentPlayer?.AttachedEntity is not {} originPlayer) || originInstrument.InstrumentPlayer is not {} originPlayer)
return Array.Empty<(NetEntity, string)>(); return Array.Empty<(NetEntity, string)>();
// It's probably faster to get all possible active instruments than all entities in range // It's probably faster to get all possible active instruments than all entities in range
@@ -247,7 +246,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
continue; continue;
// We want to use the instrument player's name. // We want to use the instrument player's name.
if (instrument.InstrumentPlayer?.AttachedEntity is not {} playerUid) if (instrument.InstrumentPlayer is not {} playerUid)
continue; continue;
// Maybe a bit expensive but oh well GetBands is queued and has a timer anyway. // Maybe a bit expensive but oh well GetBands is queued and has a timer anyway.
@@ -298,7 +297,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
return; return;
if (!instrument.Playing if (!instrument.Playing
|| args.SenderSession != instrument.InstrumentPlayer || args.SenderSession.AttachedEntity != instrument.InstrumentPlayer
|| instrument.InstrumentPlayer == null || instrument.InstrumentPlayer == null
|| args.SenderSession.AttachedEntity is not { } attached) || args.SenderSession.AttachedEntity is not { } attached)
{ {
@@ -374,8 +373,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
var entity = GetEntity(request.Entity); var entity = GetEntity(request.Entity);
var nearby = GetBands(entity); var nearby = GetBands(entity);
_bui.TrySendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby), _bui.ServerSendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby), request.Actor);
request.Session);
} }
_bandRequestQueue.Clear(); _bandRequestQueue.Clear();
@@ -413,7 +411,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
(instrument.BatchesDropped >= MaxMidiBatchesDropped (instrument.BatchesDropped >= MaxMidiBatchesDropped
|| instrument.LaggedBatches >= MaxMidiLaggedBatches)) || instrument.LaggedBatches >= MaxMidiLaggedBatches))
{ {
if (instrument.InstrumentPlayer?.AttachedEntity is {Valid: true} mob) if (instrument.InstrumentPlayer is {Valid: true} mob)
{ {
_stuns.TryParalyze(mob, TimeSpan.FromSeconds(1), true); _stuns.TryParalyze(mob, TimeSpan.FromSeconds(1), true);
@@ -423,7 +421,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
// Just in case // Just in case
Clean(uid); Clean(uid);
_bui.TryCloseAll(uid, InstrumentUiKey.Key); _bui.CloseUi(uid, InstrumentUiKey.Key);
} }
instrument.Timer += frameTime; instrument.Timer += frameTime;
@@ -437,13 +435,12 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
} }
} }
public void ToggleInstrumentUi(EntityUid uid, ICommonSession session, InstrumentComponent? component = null) public void ToggleInstrumentUi(EntityUid uid, EntityUid actor, InstrumentComponent? component = null)
{ {
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
if (_bui.TryGetUi(uid, InstrumentUiKey.Key, out var bui)) _bui.TryToggleUi(uid, InstrumentUiKey.Key, actor);
_bui.ToggleUi(bui, session);
} }
public override bool ResolveInstrument(EntityUid uid, ref SharedInstrumentComponent? component) public override bool ResolveInstrument(EntityUid uid, ref SharedInstrumentComponent? component)

View File

@@ -16,13 +16,6 @@ namespace Content.Server.Interaction
[Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BoundUserInterfaceCheckRangeEvent>(HandleUserInterfaceRangeCheck);
}
public override bool CanAccessViaStorage(EntityUid user, EntityUid target) public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
{ {
if (Deleted(target)) if (Deleted(target))
@@ -37,26 +30,8 @@ namespace Content.Server.Interaction
if (storage.Container?.ID != container.ID) if (storage.Container?.ID != container.ID)
return false; return false;
if (!TryComp(user, out ActorComponent? actor))
return false;
// we don't check if the user can access the storage entity itself. This should be handed by the UI system. // we don't check if the user can access the storage entity itself. This should be handed by the UI system.
return _uiSystem.SessionHasOpenUi(container.Owner, StorageComponent.StorageUiKey.Key, actor.PlayerSession); return _uiSystem.IsUiOpen(container.Owner, StorageComponent.StorageUiKey.Key, user);
}
private void HandleUserInterfaceRangeCheck(ref BoundUserInterfaceCheckRangeEvent ev)
{
if (ev.Player.AttachedEntity is not { } user || ev.Result == BoundUserInterfaceRangeResult.Fail)
return;
if (InRangeUnobstructed(user, ev.Target, ev.UserInterface.InteractionRange))
{
ev.Result = BoundUserInterfaceRangeResult.Pass;
}
else
{
ev.Result = BoundUserInterfaceRangeResult.Fail;
}
} }
} }
} }

View File

@@ -79,7 +79,7 @@ namespace Content.Server.Kitchen.EntitySystems
SubscribeLocalEvent<MicrowaveComponent, SignalReceivedEvent>(OnSignalReceived); SubscribeLocalEvent<MicrowaveComponent, SignalReceivedEvent>(OnSignalReceived);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u, c, m) => Wzhzhzh(u, c, m.Session.AttachedEntity)); SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u, c, m) => Wzhzhzh(u, c, m.Actor));
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage); SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectSolidIndexedMessage>(OnEjectIndex); SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectSolidIndexedMessage>(OnEjectIndex);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveSelectCookTimeMessage>(OnSelectTime); SubscribeLocalEvent<MicrowaveComponent, MicrowaveSelectCookTimeMessage>(OnSelectTime);
@@ -355,11 +355,7 @@ namespace Content.Server.Kitchen.EntitySystems
public void UpdateUserInterfaceState(EntityUid uid, MicrowaveComponent component) public void UpdateUserInterfaceState(EntityUid uid, MicrowaveComponent component)
{ {
var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key); _userInterface.SetUiState(uid, MicrowaveUiKey.Key, new MicrowaveUpdateUserInterfaceState(
if (ui == null)
return;
_userInterface.SetUiState(ui, new MicrowaveUpdateUserInterfaceState(
GetNetEntityArray(component.Storage.ContainedEntities.ToArray()), GetNetEntityArray(component.Storage.ContainedEntities.ToArray()),
HasComp<ActiveMicrowaveComponent>(uid), HasComp<ActiveMicrowaveComponent>(uid),
component.CurrentCookTimeButtonIndex, component.CurrentCookTimeButtonIndex,

View File

@@ -127,7 +127,7 @@ namespace Content.Server.Kitchen.EntitySystems
_solutionContainersSystem.TryAddSolution(containerSoln.Value, solution); _solutionContainersSystem.TryAddSolution(containerSoln.Value, solution);
} }
_userInterfaceSystem.TrySendUiMessage(uid, ReagentGrinderUiKey.Key, _userInterfaceSystem.ServerSendUiMessage(uid, ReagentGrinderUiKey.Key,
new ReagentGrinderWorkCompleteMessage()); new ReagentGrinderWorkCompleteMessage());
UpdateUiState(uid); UpdateUiState(uid);
@@ -228,7 +228,7 @@ namespace Content.Server.Kitchen.EntitySystems
GetNetEntityArray(inputContainer.ContainedEntities.ToArray()), GetNetEntityArray(inputContainer.ContainedEntities.ToArray()),
containerSolution?.Contents.ToArray() containerSolution?.Contents.ToArray()
); );
_userInterfaceSystem.TrySetUiState(uid, ReagentGrinderUiKey.Key, state); _userInterfaceSystem.SetUiState(uid, ReagentGrinderUiKey.Key, state);
} }
private void OnStartMessage(Entity<ReagentGrinderComponent> entity, ref ReagentGrinderStartMessage message) private void OnStartMessage(Entity<ReagentGrinderComponent> entity, ref ReagentGrinderStartMessage message)
@@ -305,7 +305,7 @@ namespace Content.Server.Kitchen.EntitySystems
reagentGrinder.AudioStream = _audioSystem.PlayPvs(sound, uid, reagentGrinder.AudioStream = _audioSystem.PlayPvs(sound, uid,
AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier)).Value.Entity; //slightly higher pitched AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier)).Value.Entity; //slightly higher pitched
_userInterfaceSystem.TrySendUiMessage(uid, ReagentGrinderUiKey.Key, _userInterfaceSystem.ServerSendUiMessage(uid, ReagentGrinderUiKey.Key,
new ReagentGrinderWorkStartedMessage(program)); new ReagentGrinderWorkStartedMessage(program));
} }

View File

@@ -90,7 +90,7 @@ namespace Content.Server.Labels
private void OnHandLabelerLabelChanged(EntityUid uid, HandLabelerComponent handLabeler, HandLabelerLabelChangedMessage args) private void OnHandLabelerLabelChanged(EntityUid uid, HandLabelerComponent handLabeler, HandLabelerLabelChangedMessage args)
{ {
if (args.Session.AttachedEntity is not {Valid: true} player) if (args.Actor is not {Valid: true} player)
return; return;
var label = args.Label.Trim(); var label = args.Label.Trim();
@@ -109,7 +109,7 @@ namespace Content.Server.Labels
if (!Resolve(uid, ref handLabeler)) if (!Resolve(uid, ref handLabeler))
return; return;
_userInterfaceSystem.TrySetUiState(uid, HandLabelerUiKey.Key, _userInterfaceSystem.SetUiState(uid, HandLabelerUiKey.Key,
new HandLabelerBoundUserInterfaceState(handLabeler.AssignedLabel)); new HandLabelerBoundUserInterfaceState(handLabeler.AssignedLabel));
} }
} }

View File

@@ -226,11 +226,10 @@ namespace Content.Server.Lathe
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
var ui = _uiSys.GetUi(uid, LatheUiKey.Key);
var producing = component.CurrentRecipe ?? component.Queue.FirstOrDefault(); var producing = component.CurrentRecipe ?? component.Queue.FirstOrDefault();
var state = new LatheUpdateState(GetAvailableRecipes(uid, component), component.Queue, producing); var state = new LatheUpdateState(GetAvailableRecipes(uid, component), component.Queue, producing);
_uiSys.SetUiState(ui, state); _uiSys.SetUiState(uid, LatheUiKey.Key, state);
} }
private void OnGetRecipes(EntityUid uid, TechnologyDatabaseComponent component, LatheGetRecipesEvent args) private void OnGetRecipes(EntityUid uid, TechnologyDatabaseComponent component, LatheGetRecipesEvent args)
@@ -337,10 +336,10 @@ namespace Content.Server.Lathe
else else
break; break;
} }
if (count > 0 && args.Session.AttachedEntity != null) if (count > 0)
{ {
_adminLogger.Add(LogType.Action, LogImpact.Low, _adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(args.Session.AttachedEntity.Value):player} queued {count} {recipe.Name} at {ToPrettyString(uid):lathe}"); $"{ToPrettyString(args.Actor):player} queued {count} {recipe.Name} at {ToPrettyString(uid):lathe}");
} }
} }
TryStartProducing(uid, component); TryStartProducing(uid, component);

View File

@@ -3,6 +3,7 @@ using Content.Server.Popups;
using Content.Shared.UserInterface; using Content.Shared.UserInterface;
using Content.Shared.Lock; using Content.Shared.Lock;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using ActivatableUISystem = Content.Shared.UserInterface.ActivatableUISystem;
namespace Content.Server.Lock.EntitySystems; namespace Content.Server.Lock.EntitySystems;
public sealed class ActivatableUIRequiresLockSystem : EntitySystem public sealed class ActivatableUIRequiresLockSystem : EntitySystem

View File

@@ -32,7 +32,7 @@ public sealed class MagicMirrorSystem : EntitySystem
Subs.BuiEvents<MagicMirrorComponent>(MagicMirrorUiKey.Key, subs => Subs.BuiEvents<MagicMirrorComponent>(MagicMirrorUiKey.Key, subs =>
{ {
subs.Event<BoundUIClosedEvent>(OnUIClosed); subs.Event<BoundUIClosedEvent>(OnUiClosed);
subs.Event<MagicMirrorSelectMessage>(OnMagicMirrorSelect); subs.Event<MagicMirrorSelectMessage>(OnMagicMirrorSelect);
subs.Event<MagicMirrorChangeColorMessage>(OnTryMagicMirrorChangeColor); subs.Event<MagicMirrorChangeColorMessage>(OnTryMagicMirrorChangeColor);
subs.Event<MagicMirrorAddSlotMessage>(OnTryMagicMirrorAddSlot); subs.Event<MagicMirrorAddSlotMessage>(OnTryMagicMirrorAddSlot);
@@ -62,10 +62,7 @@ public sealed class MagicMirrorSystem : EntitySystem
if (!args.CanReach || args.Target == null) if (!args.CanReach || args.Target == null)
return; return;
if (!TryComp<ActorComponent>(args.User, out var actor)) if (!_uiSystem.TryOpenUi(mirror.Owner, MagicMirrorUiKey.Key, args.User))
return;
if (!_uiSystem.TryOpen(mirror.Owner, MagicMirrorUiKey.Key, actor.PlayerSession))
return; return;
UpdateInterface(mirror.Owner, args.Target.Value, mirror.Comp); UpdateInterface(mirror.Owner, args.Target.Value, mirror.Comp);
@@ -79,7 +76,7 @@ public sealed class MagicMirrorSystem : EntitySystem
private void OnMagicMirrorSelect(EntityUid uid, MagicMirrorComponent component, MagicMirrorSelectMessage message) private void OnMagicMirrorSelect(EntityUid uid, MagicMirrorComponent component, MagicMirrorSelectMessage message)
{ {
if (component.Target is not { } target || message.Session.AttachedEntity is not { } user) if (component.Target is not { } target)
return; return;
_doAfterSystem.Cancel(component.DoAfter); _doAfterSystem.Cancel(component.DoAfter);
@@ -92,7 +89,7 @@ public sealed class MagicMirrorSystem : EntitySystem
Marking = message.Marking, Marking = message.Marking,
}; };
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.SelectSlotTime, doAfter, uid, target: target, used: uid) _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, message.Actor, component.SelectSlotTime, doAfter, uid, target: target, used: uid)
{ {
DistanceThreshold = SharedInteractionSystem.InteractionRange, DistanceThreshold = SharedInteractionSystem.InteractionRange,
BreakOnDamage = true, BreakOnDamage = true,
@@ -134,7 +131,7 @@ public sealed class MagicMirrorSystem : EntitySystem
private void OnTryMagicMirrorChangeColor(EntityUid uid, MagicMirrorComponent component, MagicMirrorChangeColorMessage message) private void OnTryMagicMirrorChangeColor(EntityUid uid, MagicMirrorComponent component, MagicMirrorChangeColorMessage message)
{ {
if (component.Target is not { } target || message.Session.AttachedEntity is not { } user) if (component.Target is not { } target)
return; return;
_doAfterSystem.Cancel(component.DoAfter); _doAfterSystem.Cancel(component.DoAfter);
@@ -147,7 +144,7 @@ public sealed class MagicMirrorSystem : EntitySystem
Colors = message.Colors, Colors = message.Colors,
}; };
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.ChangeSlotTime, doAfter, uid, target: target, used: uid) _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, message.Actor, component.ChangeSlotTime, doAfter, uid, target: target, used: uid)
{ {
BreakOnDamage = true, BreakOnDamage = true,
BreakOnMove = true, BreakOnMove = true,
@@ -187,7 +184,7 @@ public sealed class MagicMirrorSystem : EntitySystem
private void OnTryMagicMirrorRemoveSlot(EntityUid uid, MagicMirrorComponent component, MagicMirrorRemoveSlotMessage message) private void OnTryMagicMirrorRemoveSlot(EntityUid uid, MagicMirrorComponent component, MagicMirrorRemoveSlotMessage message)
{ {
if (component.Target is not { } target || message.Session.AttachedEntity is not { } user) if (component.Target is not { } target)
return; return;
_doAfterSystem.Cancel(component.DoAfter); _doAfterSystem.Cancel(component.DoAfter);
@@ -199,7 +196,7 @@ public sealed class MagicMirrorSystem : EntitySystem
Slot = message.Slot, Slot = message.Slot,
}; };
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.RemoveSlotTime, doAfter, uid, target: target, used: uid) _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, message.Actor, component.RemoveSlotTime, doAfter, uid, target: target, used: uid)
{ {
DistanceThreshold = SharedInteractionSystem.InteractionRange, DistanceThreshold = SharedInteractionSystem.InteractionRange,
BreakOnDamage = true, BreakOnDamage = true,
@@ -243,9 +240,6 @@ public sealed class MagicMirrorSystem : EntitySystem
if (component.Target == null) if (component.Target == null)
return; return;
if (message.Session.AttachedEntity == null)
return;
_doAfterSystem.Cancel(component.DoAfter); _doAfterSystem.Cancel(component.DoAfter);
component.DoAfter = null; component.DoAfter = null;
@@ -254,7 +248,7 @@ public sealed class MagicMirrorSystem : EntitySystem
Category = message.Category, Category = message.Category,
}; };
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, message.Session.AttachedEntity.Value, component.AddSlotTime, doAfter, uid, target: component.Target.Value, used: uid) _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, message.Actor, component.AddSlotTime, doAfter, uid, target: component.Target.Value, used: uid)
{ {
BreakOnDamage = true, BreakOnDamage = true,
BreakOnMove = true, BreakOnMove = true,
@@ -316,10 +310,10 @@ public sealed class MagicMirrorSystem : EntitySystem
humanoid.MarkingSet.PointsLeft(MarkingCategories.FacialHair) + facialHair.Count); humanoid.MarkingSet.PointsLeft(MarkingCategories.FacialHair) + facialHair.Count);
component.Target = targetUid; component.Target = targetUid;
_uiSystem.TrySetUiState(mirrorUid, MagicMirrorUiKey.Key, state); _uiSystem.SetUiState(mirrorUid, MagicMirrorUiKey.Key, state);
} }
private void OnUIClosed(Entity<MagicMirrorComponent> ent, ref BoundUIClosedEvent args) private void OnUiClosed(Entity<MagicMirrorComponent> ent, ref BoundUIClosedEvent args)
{ {
ent.Comp.Target = null; ent.Comp.Target = null;
} }

View File

@@ -92,15 +92,12 @@ public sealed class NewsSystem : SharedNewsSystem
if (msg.ArticleNum >= articles.Count) if (msg.ArticleNum >= articles.Count)
return; return;
if (msg.Session.AttachedEntity is not { } actor)
return;
var article = articles[msg.ArticleNum]; var article = articles[msg.ArticleNum];
if (CheckDeleteAccess(article, ent, actor)) if (CheckDeleteAccess(article, ent, msg.Actor))
{ {
_adminLogger.Add( _adminLogger.Add(
LogType.Chat, LogImpact.Medium, LogType.Chat, LogImpact.Medium,
$"{ToPrettyString(actor):actor} deleted news article {article.Title} by {article.Author}: {article.Content}" $"{ToPrettyString(msg.Actor):actor} deleted news article {article.Title} by {article.Author}: {article.Content}"
); );
articles.RemoveAt(msg.ArticleNum); articles.RemoveAt(msg.ArticleNum);
@@ -138,14 +135,11 @@ public sealed class NewsSystem : SharedNewsSystem
if (!TryGetArticles(ent, out var articles)) if (!TryGetArticles(ent, out var articles))
return; return;
if (msg.Session.AttachedEntity is not { } author) if (!_accessReader.FindStationRecordKeys(msg.Actor, out _))
return;
if (!_accessReader.FindStationRecordKeys(author, out _))
return; return;
string? authorName = null; string? authorName = null;
if (_idCardSystem.TryFindIdCard(author, out var idCard)) if (_idCardSystem.TryFindIdCard(msg.Actor, out var idCard))
authorName = idCard.Comp.FullName; authorName = idCard.Comp.FullName;
var title = msg.Title.Trim(); var title = msg.Title.Trim();
@@ -164,7 +158,7 @@ public sealed class NewsSystem : SharedNewsSystem
_adminLogger.Add( _adminLogger.Add(
LogType.Chat, LogType.Chat,
LogImpact.Medium, LogImpact.Medium,
$"{ToPrettyString(author):actor} created news article {article.Title} by {article.Author}: {article.Content}" $"{ToPrettyString(msg.Actor):actor} created news article {article.Title} by {article.Author}: {article.Content}"
); );
articles.Add(article); articles.Add(article);
@@ -248,14 +242,14 @@ public sealed class NewsSystem : SharedNewsSystem
private void UpdateWriterUi(Entity<NewsWriterComponent> ent) private void UpdateWriterUi(Entity<NewsWriterComponent> ent)
{ {
if (!_ui.TryGetUi(ent, NewsWriterUiKey.Key, out var ui)) if (!_ui.HasUi(ent, NewsWriterUiKey.Key))
return; return;
if (!TryGetArticles(ent, out var articles)) if (!TryGetArticles(ent, out var articles))
return; return;
var state = new NewsWriterBoundUserInterfaceState(articles.ToArray(), ent.Comp.PublishEnabled, ent.Comp.NextPublish); var state = new NewsWriterBoundUserInterfaceState(articles.ToArray(), ent.Comp.PublishEnabled, ent.Comp.NextPublish);
_ui.SetUiState(ui, state); _ui.SetUiState(ent.Owner, NewsWriterUiKey.Key, state);
} }
private void UpdateReaderUi(Entity<NewsReaderCartridgeComponent> ent, EntityUid loaderUid) private void UpdateReaderUi(Entity<NewsReaderCartridgeComponent> ent, EntityUid loaderUid)

View File

@@ -303,15 +303,14 @@ public sealed partial class MechSystem : SharedMechSystem
{ {
EquipmentStates = ev.States EquipmentStates = ev.States
}; };
var ui = _ui.GetUi(uid, MechUiKey.Key); _ui.SetUiState(uid, MechUiKey.Key, state);
_ui.SetUiState(ui, state);
} }
public override void BreakMech(EntityUid uid, MechComponent? component = null) public override void BreakMech(EntityUid uid, MechComponent? component = null)
{ {
base.BreakMech(uid, component); base.BreakMech(uid, component);
_ui.TryCloseAll(uid, MechUiKey.Key); _ui.CloseUi(uid, MechUiKey.Key);
_actionBlocker.UpdateCanMove(uid); _actionBlocker.UpdateCanMove(uid);
} }

View File

@@ -58,7 +58,7 @@ public sealed class CrewMonitoringConsoleSystem : EntitySystem
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
if (!_uiSystem.TryGetUi(uid, CrewMonitoringUIKey.Key, out var bui)) if (!_uiSystem.IsUiOpen(uid, CrewMonitoringUIKey.Key))
return; return;
// The grid must have a NavMapComponent to visualize the map in the UI // The grid must have a NavMapComponent to visualize the map in the UI
@@ -69,6 +69,6 @@ public sealed class CrewMonitoringConsoleSystem : EntitySystem
// Update all sensors info // Update all sensors info
var allSensors = component.ConnectedSensors.Values.ToList(); var allSensors = component.ConnectedSensors.Values.ToList();
_uiSystem.SetUiState(bui, new CrewMonitoringState(allSensors)); _uiSystem.SetUiState(uid, CrewMonitoringUIKey.Key, new CrewMonitoringState(allSensors));
} }
} }

View File

@@ -193,7 +193,8 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
healthAnalyzer.ScannedEntity = entity.Comp.BodyContainer.ContainedEntity; healthAnalyzer.ScannedEntity = entity.Comp.BodyContainer.ContainedEntity;
} }
_userInterfaceSystem.TrySendUiMessage( // TODO: This should be a state my dude
_userInterfaceSystem.ServerSendUiMessage(
entity.Owner, entity.Owner,
HealthAnalyzerUiKey.Key, HealthAnalyzerUiKey.Key,
new HealthAnalyzerScannedUserMessage(GetNetEntity(entity.Comp.BodyContainer.ContainedEntity), new HealthAnalyzerScannedUserMessage(GetNetEntity(entity.Comp.BodyContainer.ContainedEntity),
@@ -246,7 +247,7 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
else else
{ {
RemComp<ActiveCryoPodComponent>(entity); RemComp<ActiveCryoPodComponent>(entity);
_uiSystem.TryCloseAll(entity.Owner, HealthAnalyzerUiKey.Key); _uiSystem.CloseUi(entity.Owner, HealthAnalyzerUiKey.Key);
} }
UpdateAppearance(entity.Owner, entity.Comp); UpdateAppearance(entity.Owner, entity.Comp);
} }
@@ -297,7 +298,7 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
} }
// if body is ejected - no need to display health-analyzer // if body is ejected - no need to display health-analyzer
_uiSystem.TryCloseAll(cryoPod.Owner, HealthAnalyzerUiKey.Key); _uiSystem.CloseUi(cryoPod.Owner, HealthAnalyzerUiKey.Key);
} }
#endregion #endregion

View File

@@ -128,10 +128,10 @@ public sealed class HealthAnalyzerSystem : EntitySystem
private void OpenUserInterface(EntityUid user, EntityUid analyzer) private void OpenUserInterface(EntityUid user, EntityUid analyzer)
{ {
if (!TryComp<ActorComponent>(user, out var actor) || !_uiSystem.TryGetUi(analyzer, HealthAnalyzerUiKey.Key, out var ui)) if (!_uiSystem.HasUi(analyzer, HealthAnalyzerUiKey.Key))
return; return;
_uiSystem.OpenUi(ui, actor.PlayerSession); _uiSystem.OpenUi(analyzer, HealthAnalyzerUiKey.Key, user);
} }
/// <summary> /// <summary>
@@ -172,7 +172,7 @@ public sealed class HealthAnalyzerSystem : EntitySystem
/// <param name="scanMode">True makes the UI show ACTIVE, False makes the UI show INACTIVE</param> /// <param name="scanMode">True makes the UI show ACTIVE, False makes the UI show INACTIVE</param>
public void UpdateScannedUser(EntityUid healthAnalyzer, EntityUid target, bool scanMode) public void UpdateScannedUser(EntityUid healthAnalyzer, EntityUid target, bool scanMode)
{ {
if (!_uiSystem.TryGetUi(healthAnalyzer, HealthAnalyzerUiKey.Key, out var ui)) if (!_uiSystem.HasUi(healthAnalyzer, HealthAnalyzerUiKey.Key))
return; return;
if (!HasComp<DamageableComponent>(target)) if (!HasComp<DamageableComponent>(target))
@@ -194,9 +194,7 @@ public sealed class HealthAnalyzerSystem : EntitySystem
bleeding = bloodstream.BleedAmount > 0; bleeding = bloodstream.BleedAmount > 0;
} }
_uiSystem.ServerSendUiMessage(healthAnalyzer, HealthAnalyzerUiKey.Key, new HealthAnalyzerScannedUserMessage(
_uiSystem.SendUiMessage(ui, new HealthAnalyzerScannedUserMessage(
GetNetEntity(target), GetNetEntity(target),
bodyTemperature, bodyTemperature,
bloodAmount, bloodAmount,

View File

@@ -187,7 +187,7 @@ public sealed class NukeSystem : EntitySystem
continue; continue;
var msg = Loc.GetString("nuke-component-cant-anchor-floor"); var msg = Loc.GetString("nuke-component-cant-anchor-floor");
_popups.PopupEntity(msg, uid, args.Session, PopupType.MediumCaution); _popups.PopupEntity(msg, uid, args.Actor, PopupType.MediumCaution);
return; return;
} }
@@ -243,10 +243,7 @@ public sealed class NukeSystem : EntitySystem
else else
{ {
if (args.Session.AttachedEntity is not { } user) DisarmBombDoafter(uid, args.Actor, component);
return;
DisarmBombDoafter(uid, user, component);
} }
} }
@@ -366,8 +363,7 @@ public sealed class NukeSystem : EntitySystem
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
var ui = _ui.GetUiOrNull(uid, NukeUiKey.Key); if (!_ui.HasUi(uid, NukeUiKey.Key))
if (ui == null)
return; return;
var anchored = Transform(uid).Anchored; var anchored = Transform(uid).Anchored;
@@ -388,7 +384,7 @@ public sealed class NukeSystem : EntitySystem
CooldownTime = (int) component.CooldownTime CooldownTime = (int) component.CooldownTime
}; };
_ui.SetUiState(ui, state); _ui.SetUiState(uid, NukeUiKey.Key, state);
} }
private void PlayNukeKeypadSound(EntityUid uid, int number, NukeComponent? component = null) private void PlayNukeKeypadSound(EntityUid uid, int number, NukeComponent? component = null)

View File

@@ -55,9 +55,6 @@ public sealed class WarDeclaratorSystem : EntitySystem
private void OnActivated(Entity<WarDeclaratorComponent> ent, ref WarDeclaratorActivateMessage args) private void OnActivated(Entity<WarDeclaratorComponent> ent, ref WarDeclaratorActivateMessage args)
{ {
if (args.Session.AttachedEntity is not {} playerEntity)
return;
var ev = new WarDeclaredEvent(ent.Comp.CurrentStatus, ent); var ev = new WarDeclaredEvent(ent.Comp.CurrentStatus, ent);
RaiseLocalEvent(ref ev); RaiseLocalEvent(ref ev);
@@ -75,7 +72,7 @@ public sealed class WarDeclaratorSystem : EntitySystem
{ {
var title = Loc.GetString(ent.Comp.SenderTitle); var title = Loc.GetString(ent.Comp.SenderTitle);
_chat.DispatchGlobalAnnouncement(ent.Comp.Message, title, true, ent.Comp.Sound, ent.Comp.Color); _chat.DispatchGlobalAnnouncement(ent.Comp.Message, title, true, ent.Comp.Sound, ent.Comp.Color);
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(playerEntity):player} has declared war with this text: {ent.Comp.Message}"); _adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(args.Actor):player} has declared war with this text: {ent.Comp.Message}");
} }
UpdateUI(ent, ev.Status); UpdateUI(ent, ev.Status);
@@ -83,8 +80,8 @@ public sealed class WarDeclaratorSystem : EntitySystem
private void UpdateUI(Entity<WarDeclaratorComponent> ent, WarConditionStatus? status = null) private void UpdateUI(Entity<WarDeclaratorComponent> ent, WarConditionStatus? status = null)
{ {
_userInterfaceSystem.TrySetUiState( _userInterfaceSystem.SetUiState(
ent, ent.Owner,
WarDeclaratorUiKey.Key, WarDeclaratorUiKey.Key,
new WarDeclaratorBoundUserInterfaceState(status, ent.Comp.DisableAt, ent.Comp.ShuttleDisabledTime)); new WarDeclaratorBoundUserInterfaceState(status, ent.Comp.DisableAt, ent.Comp.ShuttleDisabledTime));
} }

View File

@@ -102,13 +102,15 @@ public sealed class PAISystem : SharedPAISystem
{ {
// Close the instrument interface if it was open // Close the instrument interface if it was open
// before closing // before closing
if (HasComp<ActiveInstrumentComponent>(uid) && TryComp<ActorComponent>(uid, out var actor)) if (HasComp<ActiveInstrumentComponent>(uid))
{ {
_instrumentSystem.ToggleInstrumentUi(uid, actor.PlayerSession); _instrumentSystem.ToggleInstrumentUi(uid, uid);
} }
// Stop instrument // Stop instrument
if (TryComp<InstrumentComponent>(uid, out var instrument)) _instrumentSystem.Clean(uid, instrument); if (TryComp<InstrumentComponent>(uid, out var instrument))
_instrumentSystem.Clean(uid, instrument);
if (TryComp<MetaDataComponent>(uid, out var metadata)) if (TryComp<MetaDataComponent>(uid, out var metadata))
{ {
var proto = metadata.EntityPrototype; var proto = metadata.EntityPrototype;

View File

@@ -41,6 +41,7 @@ namespace Content.Server.PDA
SubscribeLocalEvent<PdaComponent, LightToggleEvent>(OnLightToggle); SubscribeLocalEvent<PdaComponent, LightToggleEvent>(OnLightToggle);
// UI Events: // UI Events:
SubscribeLocalEvent<PdaComponent, BoundUIOpenedEvent>(OnPdaOpen);
SubscribeLocalEvent<PdaComponent, PdaRequestUpdateInterfaceMessage>(OnUiMessage); SubscribeLocalEvent<PdaComponent, PdaRequestUpdateInterfaceMessage>(OnUiMessage);
SubscribeLocalEvent<PdaComponent, PdaToggleFlashlightMessage>(OnUiMessage); SubscribeLocalEvent<PdaComponent, PdaToggleFlashlightMessage>(OnUiMessage);
SubscribeLocalEvent<PdaComponent, PdaShowRingtoneMessage>(OnUiMessage); SubscribeLocalEvent<PdaComponent, PdaShowRingtoneMessage>(OnUiMessage);
@@ -145,7 +146,7 @@ namespace Content.Server.PDA
if (!Resolve(uid, ref pda, false)) if (!Resolve(uid, ref pda, false))
return; return;
if (!_ui.TryGetUi(uid, PdaUiKey.Key, out var ui)) if (!_ui.HasUi(uid, PdaUiKey.Key))
return; return;
var address = GetDeviceNetAddress(uid); var address = GetDeviceNetAddress(uid);
@@ -182,7 +183,15 @@ namespace Content.Server.PDA
hasInstrument, hasInstrument,
address); address);
_ui.SetUiState(ui, state); _ui.SetUiState(uid, PdaUiKey.Key, state);
}
private void OnPdaOpen(Entity<PdaComponent> ent, ref BoundUIOpenedEvent args)
{
if (!PdaUiKey.Key.Equals(args.UiKey))
return;
UpdatePdaUi(ent.Owner, ent.Comp);
} }
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaRequestUpdateInterfaceMessage msg) private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaRequestUpdateInterfaceMessage msg)
@@ -208,7 +217,7 @@ namespace Content.Server.PDA
return; return;
if (HasComp<RingerComponent>(uid)) if (HasComp<RingerComponent>(uid))
_ringer.ToggleRingerUI(uid, msg.Session); _ringer.ToggleRingerUI(uid, msg.Actor);
} }
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowMusicMessage msg) private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowMusicMessage msg)
@@ -217,7 +226,7 @@ namespace Content.Server.PDA
return; return;
if (TryComp<InstrumentComponent>(uid, out var instrument)) if (TryComp<InstrumentComponent>(uid, out var instrument))
_instrument.ToggleInstrumentUi(uid, msg.Session, instrument); _instrument.ToggleInstrumentUi(uid, msg.Actor, instrument);
} }
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowUplinkMessage msg) private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowUplinkMessage msg)
@@ -227,7 +236,7 @@ namespace Content.Server.PDA
// check if its locked again to prevent malicious clients opening locked uplinks // check if its locked again to prevent malicious clients opening locked uplinks
if (TryComp<StoreComponent>(uid, out var store) && IsUnlocked(uid)) if (TryComp<StoreComponent>(uid, out var store) && IsUnlocked(uid))
_store.ToggleUi(msg.Session.AttachedEntity!.Value, uid, store); _store.ToggleUi(msg.Actor, uid, store);
} }
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaLockUplinkMessage msg) private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaLockUplinkMessage msg)

View File

@@ -81,7 +81,10 @@ namespace Content.Server.PDA.Ringer
private void OnSetRingtone(EntityUid uid, RingerComponent ringer, RingerSetRingtoneMessage args) private void OnSetRingtone(EntityUid uid, RingerComponent ringer, RingerSetRingtoneMessage args)
{ {
ref var lastSetAt = ref CollectionsMarshal.GetValueRefOrAddDefault(_lastSetRingtoneAt, args.Session.UserId, out var exists); if (!TryComp(args.Actor, out ActorComponent? actorComp))
return;
ref var lastSetAt = ref CollectionsMarshal.GetValueRefOrAddDefault(_lastSetRingtoneAt, actorComp.PlayerSession.UserId, out var exists);
// Delay on the client is 0.333, 0.25 is still enough and gives some leeway in case of small time differences // Delay on the client is 0.333, 0.25 is still enough and gives some leeway in case of small time differences
if (exists && lastSetAt > _gameTiming.CurTime - TimeSpan.FromMilliseconds(250)) if (exists && lastSetAt > _gameTiming.CurTime - TimeSpan.FromMilliseconds(250))
@@ -111,7 +114,7 @@ namespace Content.Server.PDA.Ringer
// can't keep store open after locking it // can't keep store open after locking it
if (!uplink.Unlocked) if (!uplink.Unlocked)
_ui.TryCloseAll(uid, StoreUiKey.Key); _ui.CloseUi(uid, StoreUiKey.Key);
// no saving the code to prevent meta click set on sus guys pda -> wewlad // no saving the code to prevent meta click set on sus guys pda -> wewlad
args.Handled = true; args.Handled = true;
@@ -130,7 +133,7 @@ namespace Content.Server.PDA.Ringer
return; return;
uplink.Unlocked = false; uplink.Unlocked = false;
_ui.TryCloseAll(uid, StoreUiKey.Key); _ui.CloseUi(uid, StoreUiKey.Key);
} }
public void RandomizeRingtone(EntityUid uid, RingerComponent ringer, MapInitEvent args) public void RandomizeRingtone(EntityUid uid, RingerComponent ringer, MapInitEvent args)
@@ -181,14 +184,12 @@ namespace Content.Server.PDA.Ringer
private void UpdateRingerUserInterface(EntityUid uid, RingerComponent ringer, bool isPlaying) private void UpdateRingerUserInterface(EntityUid uid, RingerComponent ringer, bool isPlaying)
{ {
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui)) _ui.SetUiState(uid, RingerUiKey.Key, new RingerUpdateState(isPlaying, ringer.Ringtone));
_ui.SetUiState(bui, new RingerUpdateState(isPlaying, ringer.Ringtone));
} }
public bool ToggleRingerUI(EntityUid uid, ICommonSession session) public bool ToggleRingerUI(EntityUid uid, EntityUid actor)
{ {
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui)) _ui.TryToggleUi(uid, RingerUiKey.Key, actor);
_ui.ToggleUi(bui, session);
return true; return true;
} }

View File

@@ -3,7 +3,7 @@ using Robust.Shared.GameStates;
namespace Content.Server.Paper; namespace Content.Server.Paper;
[NetworkedComponent, RegisterComponent] [RegisterComponent]
public sealed partial class PaperComponent : SharedPaperComponent public sealed partial class PaperComponent : SharedPaperComponent
{ {
public PaperAction Mode; public PaperAction Mode;

View File

@@ -67,11 +67,7 @@ namespace Content.Server.Paper
private void BeforeUIOpen(EntityUid uid, PaperComponent paperComp, BeforeActivatableUIOpenEvent args) private void BeforeUIOpen(EntityUid uid, PaperComponent paperComp, BeforeActivatableUIOpenEvent args)
{ {
paperComp.Mode = PaperAction.Read; paperComp.Mode = PaperAction.Read;
UpdateUserInterface(uid, paperComp);
if (!TryComp<ActorComponent>(args.User, out var actor))
return;
UpdateUserInterface(uid, paperComp, actor.PlayerSession);
} }
private void OnExamined(EntityUid uid, PaperComponent paperComp, ExaminedEvent args) private void OnExamined(EntityUid uid, PaperComponent paperComp, ExaminedEvent args)
@@ -108,12 +104,10 @@ namespace Content.Server.Paper
{ {
var writeEvent = new PaperWriteEvent(uid, args.User); var writeEvent = new PaperWriteEvent(uid, args.User);
RaiseLocalEvent(args.Used, ref writeEvent); RaiseLocalEvent(args.Used, ref writeEvent);
if (!TryComp<ActorComponent>(args.User, out var actor))
return;
paperComp.Mode = PaperAction.Write; paperComp.Mode = PaperAction.Write;
_uiSystem.TryOpen(uid, PaperUiKey.Key, actor.PlayerSession); _uiSystem.OpenUi(uid, PaperUiKey.Key, args.User);
UpdateUserInterface(uid, paperComp, actor.PlayerSession); UpdateUserInterface(uid, paperComp);
args.Handled = true; args.Handled = true;
return; return;
} }
@@ -157,9 +151,8 @@ namespace Content.Server.Paper
if (TryComp<MetaDataComponent>(uid, out var meta)) if (TryComp<MetaDataComponent>(uid, out var meta))
_metaSystem.SetEntityDescription(uid, "", meta); _metaSystem.SetEntityDescription(uid, "", meta);
if (args.Session.AttachedEntity != null)
_adminLogger.Add(LogType.Chat, LogImpact.Low, _adminLogger.Add(LogType.Chat, LogImpact.Low,
$"{ToPrettyString(args.Session.AttachedEntity.Value):player} has written on {ToPrettyString(uid):entity} the following text: {args.Text}"); $"{ToPrettyString(args.Actor):player} has written on {ToPrettyString(uid):entity} the following text: {args.Text}");
_audio.PlayPvs(paperComp.Sound, uid); _audio.PlayPvs(paperComp.Sound, uid);
} }
@@ -213,13 +206,12 @@ namespace Content.Server.Paper
_appearance.SetData(uid, PaperVisuals.Status, status, appearance); _appearance.SetData(uid, PaperVisuals.Status, status, appearance);
} }
public void UpdateUserInterface(EntityUid uid, PaperComponent? paperComp = null, ICommonSession? session = null) public void UpdateUserInterface(EntityUid uid, PaperComponent? paperComp = null)
{ {
if (!Resolve(uid, ref paperComp)) if (!Resolve(uid, ref paperComp))
return; return;
if (_uiSystem.TryGetUi(uid, PaperUiKey.Key, out var bui)) _uiSystem.SetUiState(uid, PaperUiKey.Key, new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode));
_uiSystem.SetUiState(bui, new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode), session);
} }
} }

View File

@@ -67,7 +67,7 @@ public sealed partial class ParticleAcceleratorSystem
FireEmitter(comp.StarboardEmitter!.Value, strength); FireEmitter(comp.StarboardEmitter!.Value, strength);
} }
public void SwitchOn(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) public void SwitchOn(EntityUid uid, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{ {
if (!Resolve(uid, ref comp)) if (!Resolve(uid, ref comp))
return; return;
@@ -77,7 +77,7 @@ public sealed partial class ParticleAcceleratorSystem
if (comp.Enabled || !comp.CanBeEnabled) if (comp.Enabled || !comp.CanBeEnabled)
return; return;
if (user?.AttachedEntity is { } player) if (user is { } player)
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} on"); _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} on");
comp.Enabled = true; comp.Enabled = true;
@@ -90,14 +90,14 @@ public sealed partial class ParticleAcceleratorSystem
UpdateUI(uid, comp); UpdateUI(uid, comp);
} }
public void SwitchOff(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) public void SwitchOff(EntityUid uid, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{ {
if (!Resolve(uid, ref comp)) if (!Resolve(uid, ref comp))
return; return;
if (!comp.Enabled) if (!comp.Enabled)
return; return;
if (user?.AttachedEntity is { } player) if (user is { } player)
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} off"); _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} off");
comp.Enabled = false; comp.Enabled = false;
@@ -138,7 +138,7 @@ public sealed partial class ParticleAcceleratorSystem
UpdateUI(uid, comp); UpdateUI(uid, comp);
} }
public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{ {
if (!Resolve(uid, ref comp)) if (!Resolve(uid, ref comp))
return; return;
@@ -154,7 +154,7 @@ public sealed partial class ParticleAcceleratorSystem
if (strength == comp.SelectedStrength) if (strength == comp.SelectedStrength)
return; return;
if (user?.AttachedEntity is { } player) if (user is { } player)
{ {
var impact = strength switch var impact = strength switch
{ {
@@ -235,7 +235,8 @@ public sealed partial class ParticleAcceleratorSystem
{ {
if (!Resolve(uid, ref comp)) if (!Resolve(uid, ref comp))
return; return;
if (!_uiSystem.TryGetUi(uid, ParticleAcceleratorControlBoxUiKey.Key, out var bui))
if (!_uiSystem.HasUi(uid, ParticleAcceleratorControlBoxUiKey.Key))
return; return;
var draw = 0f; var draw = 0f;
@@ -247,7 +248,7 @@ public sealed partial class ParticleAcceleratorSystem
receive = powerConsumer.ReceivedPower; receive = powerConsumer.ReceivedPower;
} }
_uiSystem.SetUiState(bui, new ParticleAcceleratorUIState( _uiSystem.SetUiState(uid, ParticleAcceleratorControlBoxUiKey.Key, new ParticleAcceleratorUIState(
comp.Assembled, comp.Assembled,
comp.Enabled, comp.Enabled,
comp.SelectedStrength, comp.SelectedStrength,
@@ -346,7 +347,7 @@ public sealed partial class ParticleAcceleratorSystem
UpdateAppearance(uid, comp); UpdateAppearance(uid, comp);
if (!args.Powered) if (!args.Powered)
_uiSystem.TryCloseAll(uid, ParticleAcceleratorControlBoxUiKey.Key); _uiSystem.CloseUi(uid, ParticleAcceleratorControlBoxUiKey.Key);
} }
private void OnUISetEnableMessage(EntityUid uid, ParticleAcceleratorControlBoxComponent comp, ParticleAcceleratorSetEnableMessage msg) private void OnUISetEnableMessage(EntityUid uid, ParticleAcceleratorControlBoxComponent comp, ParticleAcceleratorSetEnableMessage msg)
@@ -361,10 +362,10 @@ public sealed partial class ParticleAcceleratorSystem
if (msg.Enabled) if (msg.Enabled)
{ {
if (comp.Assembled) if (comp.Assembled)
SwitchOn(uid, msg.Session, comp); SwitchOn(uid, msg.Actor, comp);
} }
else else
SwitchOff(uid, msg.Session, comp); SwitchOff(uid, msg.Actor, comp);
UpdateUI(uid, comp); UpdateUI(uid, comp);
} }
@@ -378,7 +379,7 @@ public sealed partial class ParticleAcceleratorSystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered) if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered)
return; return;
SetStrength(uid, msg.State, msg.Session, comp); SetStrength(uid, msg.State, msg.Actor, comp);
UpdateUI(uid, comp); UpdateUI(uid, comp);
} }
@@ -392,7 +393,7 @@ public sealed partial class ParticleAcceleratorSystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered) if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered)
return; return;
RescanParts(uid, msg.Session, comp); RescanParts(uid, msg.Actor, comp);
UpdateUI(uid, comp); UpdateUI(uid, comp);
} }

View File

@@ -18,7 +18,7 @@ public sealed partial class ParticleAcceleratorSystem
SubscribeLocalEvent<ParticleAcceleratorPartComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged); SubscribeLocalEvent<ParticleAcceleratorPartComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
} }
public void RescanParts(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? controller = null) public void RescanParts(EntityUid uid, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? controller = null)
{ {
if (!Resolve(uid, ref controller)) if (!Resolve(uid, ref controller))
return; return;

View File

@@ -48,8 +48,7 @@ public sealed partial class ParticleAcceleratorLimiterWireAction : ComponentWire
// Yes, it's a feature that mending this wire WON'T WORK if the strength wire is also cut. // Yes, it's a feature that mending this wire WON'T WORK if the strength wire is also cut.
// Since that blocks SetStrength(). // Since that blocks SetStrength().
var paSystem = EntityManager.System<ParticleAcceleratorSystem>(); var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null; paSystem.SetStrength(wire.Owner, controller.MaxStrength, user, controller);
paSystem.SetStrength(wire.Owner, controller.MaxStrength, userSession, controller);
return true; return true;
} }

View File

@@ -33,7 +33,6 @@ public sealed partial class ParticleAcceleratorStrengthWireAction : ComponentWir
public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller) public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
{ {
var paSystem = EntityManager.System<ParticleAcceleratorSystem>(); var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null; paSystem.SetStrength(wire.Owner, (ParticleAcceleratorPowerState) ((int) controller.SelectedStrength + 1), user, controller);
paSystem.SetStrength(wire.Owner, (ParticleAcceleratorPowerState) ((int) controller.SelectedStrength + 1), userSession, controller);
} }
} }

View File

@@ -23,10 +23,9 @@ public sealed partial class ParticleAcceleratorPowerWireAction : ComponentWireAc
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller) public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
{ {
var paSystem = EntityManager.System<ParticleAcceleratorSystem>(); var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null;
controller.CanBeEnabled = false; controller.CanBeEnabled = false;
paSystem.SwitchOff(wire.Owner, userSession, controller); paSystem.SwitchOff(wire.Owner, user, controller);
return true; return true;
} }
@@ -39,11 +38,10 @@ public sealed partial class ParticleAcceleratorPowerWireAction : ComponentWireAc
public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller) public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
{ {
var paSystem = EntityManager.System<ParticleAcceleratorSystem>(); var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null;
if (controller.Enabled) if (controller.Enabled)
paSystem.SwitchOff(wire.Owner, userSession, controller); paSystem.SwitchOff(wire.Owner, user, controller);
else if (controller.Assembled) else if (controller.Assembled)
paSystem.SwitchOn(wire.Owner, userSession, controller); paSystem.SwitchOn(wire.Owner, user, controller);
} }
} }

View File

@@ -155,9 +155,6 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
private void OnConfigureMessage(Entity<ConfigurableNavMapBeaconComponent> ent, ref NavMapBeaconConfigureBuiMessage args) private void OnConfigureMessage(Entity<ConfigurableNavMapBeaconComponent> ent, ref NavMapBeaconConfigureBuiMessage args)
{ {
if (args.Session.AttachedEntity is not { } user)
return;
if (!TryComp<NavMapBeaconComponent>(ent, out var beacon)) if (!TryComp<NavMapBeaconComponent>(ent, out var beacon))
return; return;
@@ -167,7 +164,7 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
return; return;
_adminLog.Add(LogType.Action, LogImpact.Medium, _adminLog.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(user):player} configured NavMapBeacon \'{ToPrettyString(ent):entity}\' with text \'{args.Text}\', color {args.Color.ToHexNoAlpha()}, and {(args.Enabled ? "enabled" : "disabled")} it."); $"{ToPrettyString(args.Actor):player} configured NavMapBeacon \'{ToPrettyString(ent):entity}\' with text \'{args.Text}\', color {args.Color.ToHexNoAlpha()}, and {(args.Enabled ? "enabled" : "disabled")} it.");
if (TryComp<WarpPointComponent>(ent, out var warpPoint)) if (TryComp<WarpPointComponent>(ent, out var warpPoint))
{ {

View File

@@ -24,29 +24,23 @@ public sealed class StationMapSystem : EntitySystem
private void OnStationMapClosed(EntityUid uid, StationMapComponent component, BoundUIClosedEvent args) private void OnStationMapClosed(EntityUid uid, StationMapComponent component, BoundUIClosedEvent args)
{ {
if (!Equals(args.UiKey, StationMapUiKey.Key) || args.Session.AttachedEntity == null) if (!Equals(args.UiKey, StationMapUiKey.Key))
return; return;
RemCompDeferred<StationMapUserComponent>(args.Session.AttachedEntity.Value); RemCompDeferred<StationMapUserComponent>(args.Actor);
} }
private void OnUserParentChanged(EntityUid uid, StationMapUserComponent component, ref EntParentChangedMessage args) private void OnUserParentChanged(EntityUid uid, StationMapUserComponent component, ref EntParentChangedMessage args)
{ {
if (TryComp<ActorComponent>(uid, out var actor)) _ui.CloseUi(component.Map, StationMapUiKey.Key, uid);
{
_ui.TryClose(component.Map, StationMapUiKey.Key, actor.PlayerSession);
}
} }
private void OnStationMapOpened(EntityUid uid, StationMapComponent component, BoundUIOpenedEvent args) private void OnStationMapOpened(EntityUid uid, StationMapComponent component, BoundUIOpenedEvent args)
{ {
if (args.Session.AttachedEntity == null)
return;
if (!_cell.TryUseActivatableCharge(uid)) if (!_cell.TryUseActivatableCharge(uid))
return; return;
var comp = EnsureComp<StationMapUserComponent>(args.Session.AttachedEntity.Value); var comp = EnsureComp<StationMapUserComponent>(args.Actor);
comp.Map = uid; comp.Map = uid;
} }
} }

View File

@@ -1,8 +0,0 @@
namespace Content.Server.Power.Components
{
[RegisterComponent]
public sealed partial class ActivatableUIRequiresPowerComponent : Component
{
}
}

View File

@@ -4,11 +4,12 @@ using Content.Shared.UserInterface;
using JetBrains.Annotations; using JetBrains.Annotations;
using Content.Shared.Wires; using Content.Shared.Wires;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.Power.Components;
using ActivatableUISystem = Content.Shared.UserInterface.ActivatableUISystem;
namespace Content.Server.Power.EntitySystems; namespace Content.Server.Power.EntitySystems;
[UsedImplicitly] public sealed class ActivatableUIRequiresPowerSystem : EntitySystem
internal sealed class ActivatableUIRequiresPowerSystem : EntitySystem
{ {
[Dependency] private readonly ActivatableUISystem _activatableUI = default!; [Dependency] private readonly ActivatableUISystem _activatableUI = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;

View File

@@ -66,11 +66,8 @@ public sealed class ApcSystem : EntitySystem
//Update the HasAccess var for UI to read //Update the HasAccess var for UI to read
private void OnBoundUiOpen(EntityUid uid, ApcComponent component, BoundUIOpenedEvent args) private void OnBoundUiOpen(EntityUid uid, ApcComponent component, BoundUIOpenedEvent args)
{ {
if (args.Session.AttachedEntity == null)
return;
// TODO: this should be per-player not stored on the apc // TODO: this should be per-player not stored on the apc
component.HasAccess = _accessReader.IsAllowed(args.Session.AttachedEntity.Value, uid); component.HasAccess = _accessReader.IsAllowed(args.Actor, uid);
UpdateApcState(uid, component); UpdateApcState(uid, component);
} }
@@ -81,21 +78,18 @@ public sealed class ApcSystem : EntitySystem
if (attemptEv.Cancelled) if (attemptEv.Cancelled)
{ {
_popup.PopupCursor(Loc.GetString("apc-component-on-toggle-cancel"), _popup.PopupCursor(Loc.GetString("apc-component-on-toggle-cancel"),
args.Session, PopupType.Medium); args.Actor, PopupType.Medium);
return; return;
} }
if (args.Session.AttachedEntity == null) if (_accessReader.IsAllowed(args.Actor, uid))
return;
if (_accessReader.IsAllowed(args.Session.AttachedEntity.Value, uid))
{ {
ApcToggleBreaker(uid, component); ApcToggleBreaker(uid, component);
} }
else else
{ {
_popup.PopupCursor(Loc.GetString("apc-component-insufficient-access"), _popup.PopupCursor(Loc.GetString("apc-component-insufficient-access"),
args.Session, PopupType.Medium); args.Actor, PopupType.Medium);
} }
} }
@@ -158,7 +152,7 @@ public sealed class ApcSystem : EntitySystem
(int) MathF.Ceiling(battery.CurrentSupply), apc.LastExternalState, (int) MathF.Ceiling(battery.CurrentSupply), apc.LastExternalState,
battery.CurrentStorage / battery.Capacity); battery.CurrentStorage / battery.Capacity);
_ui.TrySetUiState(uid, ApcUiKey.Key, state, ui: ui); _ui.SetUiState((uid, ui), ApcUiKey.Key, state);
} }
private ApcChargeState CalcChargeState(EntityUid uid, PowerState.Battery battery) private ApcChargeState CalcChargeState(EntityUid uid, PowerState.Battery battery)

View File

@@ -286,20 +286,17 @@ internal sealed partial class PowerMonitoringConsoleSystem : SharedPowerMonitori
var query = AllEntityQuery<PowerMonitoringConsoleComponent>(); var query = AllEntityQuery<PowerMonitoringConsoleComponent>();
while (query.MoveNext(out var ent, out var console)) while (query.MoveNext(out var ent, out var console))
{ {
if (!_userInterfaceSystem.TryGetUi(ent, PowerMonitoringConsoleUiKey.Key, out var bui)) if (!_userInterfaceSystem.IsUiOpen(ent, PowerMonitoringConsoleUiKey.Key))
continue; continue;
foreach (var session in bui.SubscribedSessions) UpdateUIState(ent, console);
UpdateUIState(ent, console, session);
} }
} }
} }
public void UpdateUIState(EntityUid uid, PowerMonitoringConsoleComponent component, ICommonSession session) private void UpdateUIState(EntityUid uid, PowerMonitoringConsoleComponent component)
{ {
if (!_userInterfaceSystem.TryGetUi(uid, PowerMonitoringConsoleUiKey.Key, out var bui))
return;
var consoleXform = Transform(uid); var consoleXform = Transform(uid);
if (consoleXform?.GridUid == null) if (consoleXform?.GridUid == null)
@@ -422,15 +419,15 @@ internal sealed partial class PowerMonitoringConsoleSystem : SharedPowerMonitori
} }
// Set the UI state // Set the UI state
_userInterfaceSystem.SetUiState(bui, _userInterfaceSystem.SetUiState(uid,
PowerMonitoringConsoleUiKey.Key,
new PowerMonitoringConsoleBoundInterfaceState new PowerMonitoringConsoleBoundInterfaceState
(totalSources, (totalSources,
totalBatteryUsage, totalBatteryUsage,
totalLoads, totalLoads,
allEntries.ToArray(), allEntries.ToArray(),
sourcesForFocus.ToArray(), sourcesForFocus.ToArray(),
loadsForFocus.ToArray()), loadsForFocus.ToArray()));
session);
} }
private double GetPrimaryPowerValues(EntityUid uid, PowerMonitoringDeviceComponent device, out double powerSupplied, out double powerUsage, out double batteryUsage) private double GetPrimaryPowerValues(EntityUid uid, PowerMonitoringDeviceComponent device, out double powerSupplied, out double powerUsage, out double batteryUsage)

Some files were not shown because too many files have changed in this diff Show More