Merge remote-tracking branch 'refs/remotes/upstream/master' into ed-27-04-2024-displacement-upstream

# Conflicts:
#	Resources/Prototypes/Entities/Mobs/Customization/Markings/human_hair.yml
This commit is contained in:
Ed
2024-04-27 10:45:35 +03:00
471 changed files with 9993 additions and 9391 deletions

View File

@@ -2,6 +2,4 @@
namespace Content.Client.Access;
public sealed class IdCardSystem : SharedIdCardSystem
{
}
public sealed class IdCardSystem : SharedIdCardSystem;

View File

@@ -40,9 +40,9 @@ namespace Content.Client.Access.UI
SendMessage(new AgentIDCardJobChangedMessage(newJob));
}
public void OnJobIconChanged(string newJobIcon)
public void OnJobIconChanged(string newJobIconId)
{
SendMessage(new AgentIDCardJobIconChangedMessage(newJobIcon));
SendMessage(new AgentIDCardJobIconChangedMessage(newJobIconId));
}
/// <summary>
@@ -57,7 +57,7 @@ namespace Content.Client.Access.UI
_window.SetCurrentName(cast.CurrentName);
_window.SetCurrentJob(cast.CurrentJob);
_window.SetAllowedIcons(cast.Icons);
_window.SetAllowedIcons(cast.Icons, cast.CurrentJobIconId);
}
protected override void Dispose(bool disposing)

View File

@@ -38,7 +38,7 @@ namespace Content.Client.Access.UI
JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text);
}
public void SetAllowedIcons(HashSet<string> icons)
public void SetAllowedIcons(HashSet<string> icons, string currentJobIconId)
{
IconGrid.DisposeAllChildren();
@@ -79,6 +79,10 @@ namespace Content.Client.Access.UI
jobIconButton.AddChild(jobIconTexture);
jobIconButton.OnPressed += _ => _bui.OnJobIconChanged(jobIcon.ID);
IconGrid.AddChild(jobIconButton);
if (jobIconId.Equals(currentJobIconId))
jobIconButton.Pressed = true;
i++;
}
}

View File

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

View File

@@ -3,6 +3,5 @@ using Robust.Shared.GameStates;
namespace Content.Client.Administration.Components;
[NetworkedComponent, RegisterComponent]
public sealed partial class KillSignComponent : SharedKillSignComponent
{ }
[RegisterComponent]
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 AnimationPlayerSystem _animationPlayer = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
@@ -35,13 +36,10 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
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;
}
bui.PopulateMusic();
}
@@ -49,15 +47,9 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
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;
if (!ui.OpenInterfaces.TryGetValue(JukeboxUiKey.Key, out var baseBui) ||
baseBui is not JukeboxBoundUserInterface bui)
{
return;
}
bui.Reload();
}

View File

@@ -11,6 +11,7 @@ using Content.Shared.Item;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Utility;
using static Robust.Client.GameObjects.SpriteComponent;
@@ -53,6 +54,7 @@ public sealed class ClientClothingSystem : ClothingSystem
};
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
public override void Initialize()
@@ -272,6 +274,7 @@ public sealed class ClientClothingSystem : ClothingSystem
// temporary, until layer draw depths get added. Basically: a layer with the key "slot" is being used as a
// bookmark to determine where in the list of layers we should insert the clothing layers.
bool slotLayerExists = sprite.LayerMapTryGet(slot, out var index);
var displacementData = inventory.Displacements.GetValueOrDefault(slot);
// add the new layers
foreach (var (key, layerData) in ev.Layers)
@@ -311,10 +314,29 @@ public sealed class ClientClothingSystem : ClothingSystem
// Sprite layer redactor when
// Sprite "redactor" just a week away.
if (slot == Jumpsuit)
layerData.Shader ??= "StencilDraw";
layerData.Shader ??= inventory.JumpsuitShader;
sprite.LayerSetData(index, layerData);
layer.Offset += slotDef.Offset;
if (displacementData != null)
{
var displacementKey = $"{key}-displacement";
if (!revealedLayers.Add(displacementKey))
{
Log.Warning($"Duplicate key for clothing visuals DISPLACEMENT: {displacementKey}.");
continue;
}
var displacementLayer = _serialization.CreateCopy(displacementData.Layer, notNullableOverride: true);
displacementLayer.CopyToShaderParameters!.LayerKey = key;
// Add before main layer for this item.
sprite.AddLayer(displacementLayer, index);
sprite.LayerMapSet(displacementKey, index);
revealedLayers.Add(displacementKey);
}
}
RaiseLocalEvent(equipment, new EquipmentVisualsUpdatedEvent(equipee, slot, revealedLayers), true);

View File

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

View File

@@ -7,7 +7,7 @@ using Content.Shared.GameWindow;
using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Client.State;
using Robust.Shared.Utility;
using Robust.Client.UserInterface;
namespace Content.Client.GameTicking.Managers
{
@@ -18,16 +18,11 @@ namespace Content.Client.GameTicking.Managers
[Dependency] private readonly IClientAdminManager _admin = default!;
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[ViewVariables] private bool _initialized;
private Dictionary<NetEntity, Dictionary<string, uint?>> _jobsAvailable = new();
private Dictionary<NetEntity, string> _stationNames = new();
/// <summary>
/// The current round-end window. Could be used to support re-opening the window after closing it.
/// </summary>
private RoundEndSummaryWindow? _window;
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? RestartSound { get; private set; }
@@ -152,12 +147,7 @@ namespace Content.Client.GameTicking.Managers
// Force an update in the event of this song being the same as the last.
RestartSound = message.RestartSound;
// Don't open duplicate windows (mainly for replays).
if (_window?.RoundId == message.RoundId)
return;
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
_window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, EntityManager);
_userInterfaceManager.GetUIController<RoundEndSummaryUIController>().OpenRoundEndSummaryWindow(message);
}
}
}

View File

@@ -38,6 +38,7 @@ namespace Content.Client.Input
common.AddFunction(ContentKeyFunctions.ZoomIn);
common.AddFunction(ContentKeyFunctions.ResetZoom);
common.AddFunction(ContentKeyFunctions.InspectEntity);
common.AddFunction(ContentKeyFunctions.ToggleRoundEndSummaryWindow);
// Not in engine, because engine cannot check for sanbox/admin status before starting placement.
common.AddFunction(ContentKeyFunctions.EditorCopyObject);

View File

@@ -72,9 +72,6 @@ public sealed class MagicMirrorBoundUserInterface : BoundUserInterface
if (!disposing)
return;
if (_window != null)
_window.OnClose -= Close;
_window?.Dispose();
}
}

View File

@@ -0,0 +1,8 @@
using Content.Shared.MagicMirror;
namespace Content.Client.MagicMirror;
public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
{
}

View File

@@ -88,6 +88,7 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface
base.Dispose(disposing);
if (!disposing) return;
_linkMenu?.Dispose();
_listMenu?.Dispose();
_configurationMenu?.Dispose();
}

View File

@@ -215,6 +215,7 @@ namespace Content.Client.Options.UI.Tabs
AddButton(ContentKeyFunctions.OpenInventoryMenu);
AddButton(ContentKeyFunctions.OpenAHelp);
AddButton(ContentKeyFunctions.OpenActionsMenu);
AddButton(ContentKeyFunctions.ToggleRoundEndSummaryWindow);
AddButton(ContentKeyFunctions.OpenEntitySpawnWindow);
AddButton(ContentKeyFunctions.OpenSandboxWindow);
AddButton(ContentKeyFunctions.OpenTileSpawnWindow);

View File

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

View File

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

@@ -697,6 +697,20 @@ namespace Content.Client.Preferences.UI
var color = SkinColor.TintedHues(_rgbSkinColorSelector.Color);
CMarkings.CurrentSkinColor = color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));
break;
}
case HumanoidSkinColor.VoxFeathers:
{
if (!_rgbSkinColorContainer.Visible)
{
_skinColor.Visible = false;
_rgbSkinColorContainer.Visible = true;
}
var color = SkinColor.ClosestVoxColor(_rgbSkinColorSelector.Color);
CMarkings.CurrentSkinColor = color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));
break;
@@ -908,6 +922,18 @@ namespace Content.Client.Preferences.UI
_rgbSkinColorSelector.Color = Profile.Appearance.SkinColor;
break;
}
case HumanoidSkinColor.VoxFeathers:
{
if (!_rgbSkinColorContainer.Visible)
{
_skinColor.Visible = false;
_rgbSkinColorContainer.Visible = true;
}
_rgbSkinColorSelector.Color = SkinColor.ClosestVoxColor(Profile.Appearance.SkinColor);
break;
}
}
}

View File

@@ -198,6 +198,13 @@ public sealed partial class ReplaySpectatorSystem
if (args.Transform.MapUid != null || args.OldMapId == MapId.Nullspace)
return;
if (_spectatorData != null)
{
// Currently scrubbing/setting the replay tick
// the observer will get respawned once the state was applied
return;
}
// The entity being spectated from was moved to null-space.
// This was probably because they were spectating some entity in a client-side replay that left PVS range.
// Simple respawn the ghost.

View File

@@ -0,0 +1,51 @@
using Content.Client.GameTicking.Managers;
using Content.Shared.GameTicking;
using Content.Shared.Input;
using JetBrains.Annotations;
using Robust.Client.Input;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Input.Binding;
using Robust.Shared.Player;
namespace Content.Client.RoundEnd;
[UsedImplicitly]
public sealed class RoundEndSummaryUIController : UIController,
IOnSystemLoaded<ClientGameTicker>
{
[Dependency] private readonly IInputManager _input = default!;
private RoundEndSummaryWindow? _window;
private void ToggleScoreboardWindow(ICommonSession? session = null)
{
if (_window == null)
return;
if (_window.IsOpen)
{
_window.Close();
}
else
{
_window.OpenCenteredRight();
_window.MoveToFront();
}
}
public void OpenRoundEndSummaryWindow(RoundEndMessageEvent message)
{
// Don't open duplicate windows (mainly for replays).
if (_window?.RoundId == message.RoundId)
return;
_window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText,
message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, EntityManager);
}
public void OnSystemLoaded(ClientGameTicker system)
{
_input.SetInputCommand(ContentKeyFunctions.ToggleRoundEndSummaryWindow,
InputCmdHandler.FromDelegate(ToggleScoreboardWindow));
}
}

View File

@@ -2,7 +2,6 @@ using System.Linq;
using System.Numerics;
using Content.Client.Message;
using Content.Shared.GameTicking;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Utility;

View File

@@ -17,6 +17,14 @@ public sealed class StorageBoundUserInterface : BoundUserInterface
_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)
{
base.Dispose(disposing);
@@ -25,16 +33,5 @@ public sealed class StorageBoundUserInterface : BoundUserInterface
_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))
return;
if (entity.Comp.OpenInterfaces.GetValueOrDefault(StorageComponent.StorageUiKey.Key) is not { } bui)
if (entity.Comp.ClientOpenInterfaces.GetValueOrDefault(StorageComponent.StorageUiKey.Key) is not { } bui)
return;
bui.Close();

View File

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

View File

@@ -117,8 +117,7 @@ namespace Content.Client.UserInterface.Systems.Alerts.Controls
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_entityManager.DeleteEntity(_spriteViewEntity);
_entityManager.QueueDeleteEntity(_spriteViewEntity);
}
}

View File

@@ -97,7 +97,8 @@ public sealed partial class AlertsUI : UIWidget
}
else
{
if (existingAlertControl != null) AlertContainer.Children.Remove(existingAlertControl);
if (existingAlertControl != null)
AlertContainer.Children.Remove(existingAlertControl);
// this is a new alert + alert key or just a different alert with the same
// key, create the control and add it in the appropriate order

View File

@@ -22,6 +22,7 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
[Dependency] private readonly IPlayerManager _player = default!;
[UISystemDependency] private readonly HandsSystem _handsSystem = default!;
[UISystemDependency] private readonly UseDelaySystem _useDelay = default!;
private readonly List<HandsContainer> _handsContainers = new();
private readonly Dictionary<string, int> _handContainerIndices = new();
@@ -450,15 +451,15 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
foreach (var hand in container.GetButtons())
{
if (!_entities.TryGetComponent(hand.Entity, out UseDelayComponent? useDelay) ||
useDelay is not { DelayStartTime: var start, DelayEndTime: var end })
if (!_entities.TryGetComponent(hand.Entity, out UseDelayComponent? useDelay))
{
hand.CooldownDisplay.Visible = false;
continue;
}
var delay = _useDelay.GetLastEndingDelay((hand.Entity.Value, useDelay));
hand.CooldownDisplay.Visible = true;
hand.CooldownDisplay.FromTime(start, end);
hand.CooldownDisplay.FromTime(delay.StartTime, delay.EndTime);
}
}
}

View File

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

View File

@@ -0,0 +1,152 @@
#nullable enable
using Content.Server.GameTicking;
using Content.Server.GameTicking.Components;
using Content.Server.GameTicking.Presets;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.GameRules;
[TestFixture]
public sealed class FailAndStartPresetTest
{
[TestPrototypes]
private const string Prototypes = @"
- type: gamePreset
id: TestPreset
alias:
- nukeops
name: Test Preset
description: """"
showInVote: false
rules:
- TestRule
- type: gamePreset
id: TestPresetTenPlayers
alias:
- nukeops
name: Test Preset 10 players
description: """"
showInVote: false
rules:
- TestRuleTenPlayers
- type: entity
id: TestRule
parent: BaseGameRule
noSpawn: true
components:
- type: GameRule
minPlayers: 0
- type: TestRule
- type: entity
id: TestRuleTenPlayers
parent: BaseGameRule
noSpawn: true
components:
- type: GameRule
minPlayers: 10
- type: TestRule
";
/// <summary>
/// Test that a nuke ops gamemode can start after failing to start once.
/// </summary>
[Test]
public async Task FailAndStartTest()
{
await using var pair = await PoolManager.GetServerClient(new PoolSettings
{
Dirty = true,
DummyTicker = false,
Connected = true,
InLobby = true
});
var server = pair.Server;
var client = pair.Client;
var entMan = server.EntMan;
var ticker = server.System<GameTicker>();
server.System<TestRuleSystem>().Run = true;
Assert.That(server.CfgMan.GetCVar(CCVars.GridFill), Is.False);
Assert.That(server.CfgMan.GetCVar(CCVars.GameLobbyFallbackEnabled), Is.True);
Assert.That(server.CfgMan.GetCVar(CCVars.GameLobbyDefaultPreset), Is.EqualTo("secret"));
server.CfgMan.SetCVar(CCVars.GridFill, true);
server.CfgMan.SetCVar(CCVars.GameLobbyFallbackEnabled, false);
server.CfgMan.SetCVar(CCVars.GameLobbyDefaultPreset, "TestPreset");
// Initially in the lobby
Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
Assert.That(client.AttachedEntity, Is.Null);
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.NotReadyToPlay));
// Try to start nukeops without readying up
await pair.WaitCommand("setgamepreset TestPresetTenPlayers");
await pair.WaitCommand("startround");
await pair.RunTicksSync(10);
// Game should not have started
Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.NotReadyToPlay));
Assert.That(!client.EntMan.EntityExists(client.AttachedEntity));
var player = pair.Player!.AttachedEntity;
Assert.That(!entMan.EntityExists(player));
// Ready up and start nukeops
await pair.WaitClientCommand("toggleready True");
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.ReadyToPlay));
await pair.WaitCommand("setgamepreset TestPreset");
await pair.WaitCommand("startround");
await pair.RunTicksSync(10);
// Game should have started
Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.JoinedGame));
Assert.That(client.EntMan.EntityExists(client.AttachedEntity));
player = pair.Player!.AttachedEntity!.Value;
Assert.That(entMan.EntityExists(player));
ticker.SetGamePreset((GamePresetPrototype?)null);
server.CfgMan.SetCVar(CCVars.GridFill, false);
server.CfgMan.SetCVar(CCVars.GameLobbyFallbackEnabled, true);
server.CfgMan.SetCVar(CCVars.GameLobbyDefaultPreset, "secret");
server.System<TestRuleSystem>().Run = false;
await pair.CleanReturnAsync();
}
}
public sealed class TestRuleSystem : EntitySystem
{
public bool Run;
public override void Initialize()
{
SubscribeLocalEvent<RoundStartAttemptEvent>(OnRoundStartAttempt);
}
private void OnRoundStartAttempt(RoundStartAttemptEvent args)
{
if (!Run)
return;
if (args.Forced || args.Cancelled)
return;
var query = EntityQueryEnumerator<TestRuleComponent, GameRuleComponent>();
while (query.MoveNext(out _, out _, out var gameRule))
{
var minPlayers = gameRule.MinPlayers;
if (args.Players.Length >= minPlayers)
continue;
args.Cancel();
}
}
}
[RegisterComponent]
public sealed partial class TestRuleComponent : Component;

View File

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

View File

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

View File

@@ -68,16 +68,13 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem
private void OnDoAfter(EntityUid uid, AccessOverriderComponent component, AccessOverriderDoAfterEvent args)
{
if (!TryComp(args.User, out ActorComponent? actor))
return;
if (args.Handled || args.Cancelled)
return;
if (args.Args.Target != null)
{
component.TargetAccessReaderId = args.Args.Target.Value;
_userInterface.TryOpen(uid, AccessOverriderUiKey.Key, actor.PlayerSession);
_userInterface.OpenUi(uid, AccessOverriderUiKey.Key, args.User);
UpdateUserInterface(uid, component, args);
}
@@ -94,7 +91,7 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem
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;
TryWriteToTargetAccessReaderId(uid, args.AccessList, player, component);
@@ -154,22 +151,19 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem
targetLabel,
targetLabelColor);
_userInterface.TrySetUiState(uid, AccessOverriderUiKey.Key, newState);
_userInterface.SetUiState(uid, AccessOverriderUiKey.Key, newState);
}
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)
{
foreach (ProtoId<AccessLevelPrototype> hash in hashSet.ToArray())
{
accessList.Add(hash);
}
}
accessList.AddRange(hashSet);
}
return accessList;

View File

@@ -61,14 +61,14 @@ namespace Content.Server.Access.Systems
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;
if (!TryComp<IdCardComponent>(uid, out var idCard))
return;
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", component.Icons);
_uiSystem.SetUiState(ui, state, args.Session);
var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", idCard.JobIcon ?? "", component.Icons);
_uiSystem.SetUiState(uid, AgentIDCardUiKey.Key, state);
}
private void OnJobChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobChangedMessage args)
@@ -94,7 +94,7 @@ namespace Content.Server.Access.Systems
return;
}
if (!_prototypeManager.TryIndex<StatusIconPrototype>(args.JobIcon, out var jobIcon))
if (!_prototypeManager.TryIndex<StatusIconPrototype>(args.JobIconId, out var jobIcon))
{
return;
}

View File

@@ -41,7 +41,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
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;
TryWriteToTargetId(uid, args.FullName, args.JobTitle, args.AccessList, args.JobPrototype, player, component);
@@ -104,7 +104,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
Name(targetId));
}
_userInterface.TrySetUiState(uid, IdCardConsoleUiKey.Key, newState);
_userInterface.SetUiState(uid, IdCardConsoleUiKey.Key, newState);
}
/// <summary>

View File

@@ -7,8 +7,6 @@ using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Database;
using Content.Shared.Popups;
using Content.Shared.Roles;
using Content.Shared.StatusIcon;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -20,20 +18,13 @@ public sealed class IdCardSystem : SharedIdCardSystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<IdCardComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<IdCardComponent, BeingMicrowavedEvent>(OnMicrowaved);
}
private void OnMapInit(EntityUid uid, IdCardComponent id, MapInitEvent args)
{
UpdateEntityName(uid, id);
}
private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowavedEvent args)
{
if (TryComp<AccessComponent>(uid, out var access))
@@ -81,143 +72,4 @@ public sealed class IdCardSystem : SharedIdCardSystem
$"{ToPrettyString(args.Microwave)} added {random.ID} access to {ToPrettyString(uid):entity}");
}
}
/// <summary>
/// Attempts to change the job title of a card.
/// Returns true/false.
/// </summary>
/// <remarks>
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
/// </remarks>
public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent? id = null, EntityUid? player = null)
{
if (!Resolve(uid, ref id))
return false;
if (!string.IsNullOrWhiteSpace(jobTitle))
{
jobTitle = jobTitle.Trim();
if (jobTitle.Length > IdCardConsoleComponent.MaxJobTitleLength)
jobTitle = jobTitle[..IdCardConsoleComponent.MaxJobTitleLength];
}
else
{
jobTitle = null;
}
if (id.JobTitle == jobTitle)
return true;
id.JobTitle = jobTitle;
Dirty(uid, id);
UpdateEntityName(uid, id);
if (player != null)
{
_adminLogger.Add(LogType.Identity, LogImpact.Low,
$"{ToPrettyString(player.Value):player} has changed the job title of {ToPrettyString(uid):entity} to {jobTitle} ");
}
return true;
}
public bool TryChangeJobIcon(EntityUid uid, StatusIconPrototype jobIcon, IdCardComponent? id = null, EntityUid? player = null)
{
if (!Resolve(uid, ref id))
{
return false;
}
if (id.JobIcon == jobIcon.ID)
{
return true;
}
id.JobIcon = jobIcon.ID;
Dirty(uid, id);
if (player != null)
{
_adminLogger.Add(LogType.Identity, LogImpact.Low,
$"{ToPrettyString(player.Value):player} has changed the job icon of {ToPrettyString(uid):entity} to {jobIcon} ");
}
return true;
}
public bool TryChangeJobDepartment(EntityUid uid, JobPrototype job, IdCardComponent? id = null)
{
if (!Resolve(uid, ref id))
return false;
id.JobDepartments.Clear();
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
if (department.Roles.Contains(job.ID))
id.JobDepartments.Add("department-" + department.ID);
}
Dirty(uid, id);
return true;
}
/// <summary>
/// Attempts to change the full name of a card.
/// Returns true/false.
/// </summary>
/// <remarks>
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
/// </remarks>
public bool TryChangeFullName(EntityUid uid, string? fullName, IdCardComponent? id = null, EntityUid? player = null)
{
if (!Resolve(uid, ref id))
return false;
if (!string.IsNullOrWhiteSpace(fullName))
{
fullName = fullName.Trim();
if (fullName.Length > IdCardConsoleComponent.MaxFullNameLength)
fullName = fullName[..IdCardConsoleComponent.MaxFullNameLength];
}
else
{
fullName = null;
}
if (id.FullName == fullName)
return true;
id.FullName = fullName;
Dirty(uid, id);
UpdateEntityName(uid, id);
if (player != null)
{
_adminLogger.Add(LogType.Identity, LogImpact.Low,
$"{ToPrettyString(player.Value):player} has changed the name of {ToPrettyString(uid):entity} to {fullName} ");
}
return true;
}
/// <summary>
/// Changes the name of the id's owner.
/// </summary>
/// <remarks>
/// If either <see cref="FullName"/> or <see cref="JobTitle"/> is empty, it's replaced by placeholders.
/// If both are empty, the original entity's name is restored.
/// </remarks>
private void UpdateEntityName(EntityUid uid, IdCardComponent? id = null)
{
if (!Resolve(uid, ref id))
return;
var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
var val = string.IsNullOrWhiteSpace(id.FullName)
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
("jobSuffix", jobSuffix))
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
("fullName", id.FullName),
("jobSuffix", jobSuffix));
_metaSystem.SetEntityName(uid, val);
}
}

View File

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

View File

@@ -3,6 +3,5 @@ using Robust.Shared.GameStates;
namespace Content.Server.Administration.Components;
[NetworkedComponent, RegisterComponent]
public sealed partial class KillSignComponent : SharedKillSignComponent
{ }
[RegisterComponent]
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"),
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
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);
}

View File

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

View File

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

View File

@@ -31,7 +31,8 @@ public sealed partial class AnomalySystem
{
if (component.ScannedAnomaly != args.Anomaly)
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);
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;
}
@@ -123,7 +124,7 @@ public sealed partial class AnomalySystem
nextPulse = anomalyComponent.NextPulseTime;
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)

View File

@@ -5,15 +5,13 @@ using Robust.Shared.Random;
namespace Content.Server.Antag;
public sealed class AntagSelectionPlayerPool(params List<ICommonSession>[] sessions)
public sealed class AntagSelectionPlayerPool (List<List<ICommonSession>> orderedPools)
{
private readonly List<List<ICommonSession>> _orderedPools = sessions.ToList();
public bool TryPickAndTake(IRobustRandom random, [NotNullWhen(true)] out ICommonSession? session)
{
session = null;
foreach (var pool in _orderedPools)
foreach (var pool in orderedPools)
{
if (pool.Count == 0)
continue;
@@ -25,5 +23,5 @@ public sealed class AntagSelectionPlayerPool(params List<ICommonSession>[] sessi
return session != null;
}
public int Count => _orderedPools.Sum(p => p.Count);
public int Count => orderedPools.Sum(p => p.Count);
}

View File

@@ -35,7 +35,6 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly GhostRoleSystem _ghostRole = default!;
[Dependency] private readonly JobSystem _jobs = default!;
[Dependency] private readonly MapSystem _map = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly RoleSystem _role = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
@@ -133,7 +132,8 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
if (!TryGetNextAvailableDefinition((uid, antag), out var def))
continue;
MakeAntag((uid, antag), args.Player, def.Value);
if (TryMakeAntag((uid, antag), args.Player, def.Value))
break;
}
}
@@ -218,6 +218,21 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
}
}
/// <summary>
/// Tries to makes a given player into the specified antagonist.
/// </summary>
public bool TryMakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? session, AntagSelectionDefinition def, bool ignoreSpawner = false)
{
if (!IsSessionValid(ent, session, def) ||
!IsEntityValid(session?.AttachedEntity, def))
{
return false;
}
MakeAntag(ent, session, def, ignoreSpawner);
return true;
}
/// <summary>
/// Makes a given player into the specified antagonist.
/// </summary>
@@ -262,7 +277,6 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
{
var playerXform = Transform(player);
var pos = RobustRandom.Pick(getPosEv.Coordinates);
var mapEnt = _map.GetMap(pos.MapId);
_transform.SetMapCoordinates((player, playerXform), pos);
}
@@ -291,8 +305,8 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
_mind.SetUserId(curMind.Value, session.UserId);
}
EntityManager.AddComponents(curMind.Value, def.MindComponents);
_mind.TransferTo(curMind.Value, antagEnt, ghostCheckOverride: true);
_role.MindAddRoles(curMind.Value, def.MindComponents);
ent.Comp.SelectedMinds.Add((curMind.Value, Name(player)));
}
@@ -310,42 +324,45 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
/// </summary>
public AntagSelectionPlayerPool GetPlayerPool(Entity<AntagSelectionComponent> ent, List<ICommonSession> sessions, AntagSelectionDefinition def)
{
var primaryList = new List<ICommonSession>();
var secondaryList = new List<ICommonSession>();
var fallbackList = new List<ICommonSession>();
var rawList = new List<ICommonSession>();
var preferredList = new List<ICommonSession>();
var secondBestList = new List<ICommonSession>();
var unwantedList = new List<ICommonSession>();
var invalidList = new List<ICommonSession>();
foreach (var session in sessions)
{
if (!IsSessionValid(ent, session, def) ||
!IsEntityValid(session.AttachedEntity, def))
{
rawList.Add(session);
invalidList.Add(session);
continue;
}
var pref = (HumanoidCharacterProfile) _pref.GetPreferences(session.UserId).SelectedCharacter;
if (def.PrefRoles.Count == 0 || pref.AntagPreferences.Any(p => def.PrefRoles.Contains(p)))
if (def.PrefRoles.Count != 0 && pref.AntagPreferences.Any(p => def.PrefRoles.Contains(p)))
{
primaryList.Add(session);
preferredList.Add(session);
}
else if (def.PrefRoles.Count == 0 || pref.AntagPreferences.Any(p => def.FallbackRoles.Contains(p)))
else if (def.FallbackRoles.Count != 0 && pref.AntagPreferences.Any(p => def.FallbackRoles.Contains(p)))
{
secondaryList.Add(session);
secondBestList.Add(session);
}
else
{
fallbackList.Add(session);
unwantedList.Add(session);
}
}
return new AntagSelectionPlayerPool(primaryList, secondaryList, fallbackList, rawList);
return new AntagSelectionPlayerPool(new() { preferredList, secondBestList, unwantedList, invalidList });
}
/// <summary>
/// Checks if a given session is valid for an antagonist.
/// </summary>
public bool IsSessionValid(Entity<AntagSelectionComponent> ent, ICommonSession session, AntagSelectionDefinition def, EntityUid? mind = null)
public bool IsSessionValid(Entity<AntagSelectionComponent> ent, ICommonSession? session, AntagSelectionDefinition def, EntityUid? mind = null)
{
if (session == null)
return true;
mind ??= session.GetMind();
if (session.Status is SessionStatus.Disconnected or SessionStatus.Zombie)

View File

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

View File

@@ -13,10 +13,10 @@ public sealed partial class BlockGameArcadeComponent : Component
/// <summary>
/// The player currently playing the active session of NT-BG.
/// </summary>
public ICommonSession? Player = null;
public EntityUid? Player = null;
/// <summary>
/// The players currently viewing (but not playing) the active session of NT-BG.
/// </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))
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)
@@ -54,33 +52,21 @@ public sealed class BlockGameArcadeSystem : EntitySystem
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)
component.Player = session;
component.Player = args.Actor;
else
component.Spectators.Add(session);
component.Spectators.Add(args.Actor);
UpdatePlayerStatus(uid, session, bui, component);
component.Game?.UpdateNewPlayerUI(session);
UpdatePlayerStatus(uid, args.Actor, component);
component.Game?.UpdateNewPlayerUI(args.Actor);
}
private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args)
{
if (args.Session is not { } session)
return;
if (component.Player != session)
if (component.Player != args.Actor)
{
component.Spectators.Remove(session);
UpdatePlayerStatus(uid, session, blockGame: component);
component.Spectators.Remove(args.Actor);
UpdatePlayerStatus(uid, args.Actor, blockGame: component);
return;
}
@@ -88,11 +74,11 @@ public sealed class BlockGameArcadeSystem : EntitySystem
if (component.Spectators.Count > 0)
{
component.Player = component.Spectators[0];
component.Spectators.Remove(component.Player);
UpdatePlayerStatus(uid, component.Player, blockGame: component);
component.Spectators.Remove(component.Player.Value);
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)
@@ -100,8 +86,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
if (args.Powered)
return;
if (_uiSystem.TryGetUi(uid, BlockGameUiKey.Key, out var bui))
_uiSystem.CloseAll(bui);
_uiSystem.CloseUi(uid, BlockGameUiKey.Key);
component.Player = null;
component.Spectators.Clear();
}
@@ -112,7 +97,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
return;
if (!BlockGameUiKey.Key.Equals(msg.UiKey))
return;
if (msg.Session != component.Player)
if (msg.Actor != component.Player)
return;
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));
component.Game = new SpaceVillainGame(uid, component, this);
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out var bui))
_uiSystem.SendUiMessage(bui, component.Game.GenerateMetaDataMessage());
_uiSystem.ServerSendUiMessage(uid, SpaceVillainArcadeUiKey.Key, component.Game.GenerateMetaDataMessage());
break;
case PlayerAction.RequestData:
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out bui))
_uiSystem.SendUiMessage(bui, component.Game.GenerateMetaDataMessage());
_uiSystem.ServerSendUiMessage(uid, SpaceVillainArcadeUiKey.Key, component.Game.GenerateMetaDataMessage());
break;
}
}
@@ -110,7 +108,6 @@ public sealed partial class SpaceVillainArcadeSystem : EntitySystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var power) && power.Powered)
return;
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out var bui))
_uiSystem.CloseAll(bui);
_uiSystem.CloseUi(uid, SpaceVillainArcadeUiKey.Key);
}
}

View File

@@ -9,8 +9,7 @@ public sealed partial class SpaceVillainGame
/// </summary>
private void UpdateUi(EntityUid uid, bool metadata = false)
{
if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out var bui))
_uiSystem.SendUiMessage(bui, metadata ? GenerateMetaDataMessage() : GenerateUpdateMessage());
_uiSystem.ServerSendUiMessage(uid, SpaceVillainArcadeUiKey.Key, metadata ? GenerateMetaDataMessage() : GenerateUpdateMessage());
}
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))
return;
if (user != null && TryComp<ActorComponent>(user, out var actor))
_userInterface.TryClose(uid, GasAnalyzerUiKey.Key, actor.PlayerSession);
_userInterface.CloseUi(uid, GasAnalyzerUiKey.Key, user);
component.Enabled = false;
Dirty(uid, component);
@@ -132,8 +131,6 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
private void OnDisabledMessage(EntityUid uid, GasAnalyzerComponent component, GasAnalyzerDisableMessage message)
{
if (message.Session.AttachedEntity is not { Valid: true })
return;
DisableAnalyzer(uid, component);
}
@@ -142,10 +139,7 @@ namespace Content.Server.Atmos.EntitySystems
if (!Resolve(uid, ref component, false))
return;
if (!TryComp<ActorComponent>(user, out var actor))
return;
_userInterface.TryOpen(uid, GasAnalyzerUiKey.Key, actor.PlayerSession);
_userInterface.OpenUi(uid, GasAnalyzerUiKey.Key, user);
}
/// <summary>
@@ -242,7 +236,7 @@ namespace Content.Server.Atmos.EntitySystems
if (gasMixList.Count == 0)
return false;
_userInterface.TrySendUiMessage(uid, GasAnalyzerUiKey.Key,
_userInterface.ServerSendUiMessage(uid, GasAnalyzerUiKey.Key,
new GasAnalyzerUserMessage(gasMixList.ToArray(),
component.Target != null ? Name(component.Target.Value) : string.Empty,
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)
{
var (owner, component) = ent;
_ui.TrySetUiState(owner, SharedGasTankUiKey.Key,
_ui.SetUiState(owner, SharedGasTankUiKey.Key,
new GasTankBoundUserInterfaceState
{
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, AtmosSensorData> SensorData = new();
public HashSet<NetUserId> ActivePlayers = new();
public bool CanSync = true;
/// <summary>

View File

@@ -223,8 +223,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnClose(EntityUid uid, AirAlarmComponent component, BoundUIClosedEvent args)
{
component.ActivePlayers.Remove(args.Session.UserId);
if (component.ActivePlayers.Count == 0)
if (!_ui.IsUiOpen(uid, SharedAirAlarmInterfaceKey.Key))
RemoveActiveInterface(uid);
}
@@ -247,9 +246,6 @@ public sealed class AirAlarmSystem : EntitySystem
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)
{
args.Handled = false;
@@ -259,10 +255,7 @@ public sealed class AirAlarmSystem : EntitySystem
if (!this.IsPowered(uid, EntityManager))
return;
var ui = _ui.GetUiOrNull(uid, SharedAirAlarmInterfaceKey.Key);
if (ui != null)
_ui.OpenUi(ui, actor.PlayerSession);
component.ActivePlayers.Add(actor.PlayerSession.UserId);
_ui.OpenUi(uid, SharedAirAlarmInterfaceKey.Key, args.User);
AddActiveInterface(uid);
SyncAllDevices(uid);
UpdateUI(uid, component);
@@ -270,7 +263,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnResyncAll(EntityUid uid, AirAlarmComponent component, AirAlarmResyncAllDevicesMessage args)
{
if (!AccessCheck(uid, args.Session.AttachedEntity, component))
if (!AccessCheck(uid, args.Actor, component))
{
return;
}
@@ -285,7 +278,7 @@ public sealed class AirAlarmSystem : EntitySystem
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;
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)
{
if (AccessCheck(uid, args.Session.AttachedEntity, component))
if (AccessCheck(uid, args.Actor, component))
SetThreshold(uid, args.Address, args.Type, args.Threshold, args.Gas);
else
UpdateUI(uid, component);
@@ -317,7 +310,7 @@ public sealed class AirAlarmSystem : EntitySystem
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))
{
SetDeviceData(uid, args.Address, args.Data);
@@ -330,7 +323,7 @@ public sealed class AirAlarmSystem : EntitySystem
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);
return;
@@ -377,7 +370,7 @@ public sealed class AirAlarmSystem : EntitySystem
private void OnAtmosAlarm(EntityUid uid, AirAlarmComponent component, AtmosAlarmEvent args)
{
if (component.ActivePlayers.Count != 0)
if (_ui.IsUiOpen(uid, SharedAirAlarmInterfaceKey.Key))
{
SyncAllDevices(uid);
}
@@ -571,7 +564,7 @@ public sealed class AirAlarmSystem : EntitySystem
/// </summary>
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)
@@ -639,7 +632,7 @@ public sealed class AirAlarmSystem : EntitySystem
highestAlarm = AtmosAlarmType.Normal;
}
_ui.TrySetUiState(
_ui.SetUiState(
uid,
SharedAirAlarmInterfaceKey.Key,
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);
DirtyUI(uid, pump);
_userInterfaceSystem.TryCloseAll(uid, GasPressurePumpUiKey.Key);
_userInterfaceSystem.CloseUi(uid, GasPressurePumpUiKey.Key);
}
private void OnPumpActivate(EntityUid uid, GasPressurePumpComponent pump, ActivateInWorldEvent args)
@@ -108,7 +108,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (Transform(uid).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasPressurePumpUiKey.Key, actor.PlayerSession);
_userInterfaceSystem.OpenUi(uid, GasPressurePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, pump);
}
else
@@ -123,7 +123,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
pump.Enabled = args.Enabled;
_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);
UpdateAppearance(uid, pump);
}
@@ -132,7 +132,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
pump.TargetPressure = Math.Clamp(args.Pressure, 0f, Atmospherics.MaxOutputPressure);
_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);
}
@@ -142,7 +142,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (!Resolve(uid, ref pump))
return;
_userInterfaceSystem.TrySetUiState(uid, GasPressurePumpUiKey.Key,
_userInterfaceSystem.SetUiState(uid, GasPressurePumpUiKey.Key,
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);
DirtyUI(uid, pump);
_userInterfaceSystem.TryCloseAll(uid, GasVolumePumpUiKey.Key);
_userInterfaceSystem.CloseUi(uid, GasVolumePumpUiKey.Key);
}
private void OnPumpActivate(EntityUid uid, GasVolumePumpComponent pump, ActivateInWorldEvent args)
@@ -138,7 +138,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (Transform(uid).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasVolumePumpUiKey.Key, actor.PlayerSession);
_userInterfaceSystem.OpenUi(uid, GasVolumePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, pump);
}
else
@@ -153,7 +153,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
pump.Enabled = args.Enabled;
_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);
UpdateAppearance(uid, pump);
}
@@ -162,7 +162,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
pump.TransferRate = Math.Clamp(args.TransferRate, 0f, pump.MaxTransferRate);
_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);
}
@@ -171,7 +171,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (!Resolve(uid, ref pump))
return;
_userInterfaceSystem.TrySetUiState(uid, GasVolumePumpUiKey.Key,
_userInterfaceSystem.SetUiState(uid, GasVolumePumpUiKey.Key,
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);
DirtyUI(uid, filter);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key);
_userInterfaceSystem.CloseUi(uid, GasFilterUiKey.Key);
}
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)
{
_userInterfaceSystem.TryOpen(uid, GasFilterUiKey.Key, actor.PlayerSession);
_userInterfaceSystem.OpenUi(uid, GasFilterUiKey.Key, actor.PlayerSession);
DirtyUI(uid, filter);
}
else
@@ -120,7 +120,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (!Resolve(uid, ref filter))
return;
_userInterfaceSystem.TrySetUiState(uid, GasFilterUiKey.Key,
_userInterfaceSystem.SetUiState(uid, GasFilterUiKey.Key,
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;
_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);
UpdateAppearance(uid, filter);
}
@@ -145,7 +145,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{
filter.TransferRate = Math.Clamp(args.Rate, 0f, filter.MaxTransferRate);
_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);
}
@@ -158,7 +158,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{
filter.FilteredGas = parsedGas;
_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);
}
else
@@ -170,7 +170,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{
filter.FilteredGas = null;
_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);
}
}

View File

@@ -134,7 +134,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
DirtyUI(uid, mixer);
UpdateAppearance(uid, mixer);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key);
_userInterfaceSystem.CloseUi(uid, GasFilterUiKey.Key);
}
private void OnMixerActivate(EntityUid uid, GasMixerComponent mixer, ActivateInWorldEvent args)
@@ -144,7 +144,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (Transform(uid).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasMixerUiKey.Key, actor.PlayerSession);
_userInterfaceSystem.OpenUi(uid, GasMixerUiKey.Key, actor.PlayerSession);
DirtyUI(uid, mixer);
}
else
@@ -160,7 +160,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (!Resolve(uid, ref mixer))
return;
_userInterfaceSystem.TrySetUiState(uid, GasMixerUiKey.Key,
_userInterfaceSystem.SetUiState(uid, GasMixerUiKey.Key,
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;
_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);
UpdateAppearance(uid, mixer);
}
@@ -185,7 +185,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
{
mixer.TargetPressure = Math.Clamp(args.Pressure, 0f, mixer.MaxTargetPressure);
_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);
}
@@ -196,7 +196,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
mixer.InletOneConcentration = nodeOne;
mixer.InletTwoConcentration = 1.0f - mixer.InletOneConcentration;
_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);
}

View File

@@ -96,7 +96,7 @@ public sealed class GasCanisterSystem : EntitySystem
tankPressure = tankComponent.Air.Pressure;
}
_ui.TrySetUiState(uid, GasCanisterUiKey.Key,
_ui.SetUiState(uid, GasCanisterUiKey.Key,
new GasCanisterBoundUserInterfaceState(Name(uid),
canister.Air.Pressure, portStatus, tankLabel, tankPressure, canister.ReleasePressure,
canister.ReleaseValve, canister.MinReleasePressure, canister.MaxReleasePressure));
@@ -104,19 +104,19 @@ public sealed class GasCanisterSystem : EntitySystem
private void OnHoldingTankEjectMessage(EntityUid uid, GasCanisterComponent canister, GasCanisterHoldingTankEjectMessage args)
{
if (canister.GasTankSlot.Item == null || args.Session.AttachedEntity == null)
if (canister.GasTankSlot.Item == null)
return;
var item = canister.GasTankSlot.Item;
_slots.TryEjectToHands(uid, canister.GasTankSlot, args.Session.AttachedEntity);
_adminLogger.Add(LogType.CanisterTankEjected, LogImpact.Medium, $"Player {ToPrettyString(args.Session.AttachedEntity.GetValueOrDefault()):player} ejected tank {ToPrettyString(item):tank} from {ToPrettyString(uid):canister}");
_slots.TryEjectToHands(uid, canister.GasTankSlot, args.Actor);
_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)
{
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;
DirtyUI(uid, canister);
@@ -129,14 +129,14 @@ public sealed class GasCanisterSystem : EntitySystem
impact = canister.GasTankSlot.HasItem ? LogImpact.Medium : LogImpact.High;
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++)
{
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;
DirtyUI(uid, canister);
@@ -212,7 +212,7 @@ public sealed class GasCanisterSystem : EntitySystem
if (args.Handled)
return;
_ui.TryOpen(uid, GasCanisterUiKey.Key, actor.PlayerSession);
_ui.OpenUi(uid, GasCanisterUiKey.Key, actor.PlayerSession);
args.Handled = true;
}
@@ -224,7 +224,7 @@ public sealed class GasCanisterSystem : EntitySystem
if (CheckLocked(uid, component, args.User))
return;
_ui.TryOpen(uid, GasCanisterUiKey.Key, actor.PlayerSession);
_ui.OpenUi(uid, GasCanisterUiKey.Key, actor.PlayerSession);
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)
{
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);
}
@@ -155,7 +155,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
else
thermoMachine.TargetTemperature = MathF.Max(args.Temperature, thermoMachine.MinTemperature);
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);
}
@@ -168,8 +168,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!Resolve(uid, ref powerReceiver))
return;
_userInterfaceSystem.TrySetUiState(uid, ThermomachineUiKey.Key,
new GasThermomachineBoundUserInterfaceState(thermoMachine.MinTemperature, thermoMachine.MaxTemperature, thermoMachine.TargetTemperature, !powerReceiver.PowerDisabled, IsHeater(thermoMachine)), null, ui);
_userInterfaceSystem.SetUiState(uid, ThermomachineUiKey.Key,
new GasThermomachineBoundUserInterfaceState(thermoMachine.MinTemperature, thermoMachine.MaxTemperature, thermoMachine.TargetTemperature, !powerReceiver.PowerDisabled, IsHeater(thermoMachine)));
}
private void OnExamined(EntityUid uid, GasThermoMachineComponent thermoMachine, ExaminedEvent args)

View File

@@ -163,7 +163,7 @@ public sealed class SpaceHeaterSystem : EntitySystem
{
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));
}

View File

@@ -5,6 +5,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using JukeboxComponent = Content.Shared.Audio.Jukebox.JukeboxComponent;
@@ -66,8 +67,11 @@ public sealed class JukeboxSystem : SharedJukeboxSystem
private void OnJukeboxSetTime(EntityUid uid, JukeboxComponent component, JukeboxSetTimeMessage args)
{
var offset = (args.Session.Channel.Ping * 1.5f) / 1000f;
Audio.SetPlaybackPosition(component.AudioStream, args.SongTime + offset);
if (TryComp(args.Actor, out ActorComponent? actorComp))
{
var offset = actorComp.PlayerSession.Channel.Ping * 1.5f / 1000f;
Audio.SetPlaybackPosition(component.AudioStream, args.SongTime + offset);
}
}
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)
{
var (_, comp) = ent;
if (args.Session.AttachedEntity is not { } attachedEntity)
return;
var attachedEntity = args.Actor;
var cryoContained = GetEntity(args.StoredEntity);
if (!comp.StoredPlayers.Contains(cryoContained) || !IsInPausedMap(cryoContained))
@@ -114,6 +112,7 @@ public sealed class CryostorageSystem : SharedCryostorageSystem
AdminLog.Add(LogType.Action, LogImpact.High,
$"{ToPrettyString(attachedEntity):player} removed item {ToPrettyString(entity)} from cryostorage-contained player " +
$"{ToPrettyString(cryoContained):player}, stored in cryostorage {ToPrettyString(ent)}");
_container.TryRemoveFromContainer(entity.Value);
_transform.SetCoordinates(entity.Value, Transform(attachedEntity).Coordinates);
_hands.PickupOrDrop(attachedEntity, entity.Value);
@@ -122,8 +121,8 @@ public sealed class CryostorageSystem : SharedCryostorageSystem
private void UpdateCryostorageUIState(Entity<CryostorageComponent> ent)
{
var state = new CryostorageBuiState(GetAllContainedData(ent).ToList());
_ui.TrySetUiState(ent, CryostorageUIKey.Key, state);
var state = new CryostorageBuiState(GetAllContainedData(ent));
_ui.SetUiState(ent.Owner, CryostorageUIKey.Key, state);
}
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);
}
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)
{
yield return GetContainedData(contained);
data.Add(GetContainedData(contained));
}
return data;
}
private CryostorageContainedPlayerData GetContainedData(EntityUid uid)

View File

@@ -52,7 +52,7 @@ public sealed partial class CargoSystem
return;
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)
@@ -83,7 +83,7 @@ public sealed partial class CargoSystem
if (!TryGetBountyFromId(station, args.BountyId, out var bounty))
return;
if (args.Session.AttachedEntity is not { Valid: true } mob)
if (args.Actor is not { Valid: true } mob)
return;
if (TryComp<AccessReaderComponent>(uid, out var accessReaderComponent) &&
@@ -99,7 +99,7 @@ public sealed partial class CargoSystem
FillBountyDatabase(station);
db.NextSkipTime = _timing.CurTime + db.SkipDelay;
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);
}
@@ -462,10 +462,12 @@ public sealed partial class CargoSystem
{
if (_station.GetOwningStation(uid) is not { } station ||
!TryComp<StationCargoBountyDatabaseComponent>(station, out var db))
{
continue;
}
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)
{
if (args.Session.AttachedEntity is not { Valid: true } player)
if (args.Actor is not { Valid: true } player)
return;
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);
return;
}
@@ -119,7 +119,7 @@ namespace Content.Server.Cargo.Systems
!TryComp(station, out StationDataComponent? stationData) ||
!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);
return;
}
@@ -134,7 +134,7 @@ namespace Content.Server.Cargo.Systems
// Invalid order
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);
return;
}
@@ -145,7 +145,7 @@ namespace Content.Server.Cargo.Systems
// Too many orders, avoid them getting spammed in the UI.
if (amount >= capacity)
{
ConsolePopup(args.Session, Loc.GetString("cargo-console-too-many"));
ConsolePopup(args.Actor, Loc.GetString("cargo-console-too-many"));
PlayDenySound(uid, component);
return;
}
@@ -156,7 +156,7 @@ namespace Content.Server.Cargo.Systems
if (cappedAmount != order.OrderQuantity)
{
order.OrderQuantity = cappedAmount;
ConsolePopup(args.Session, Loc.GetString("cargo-console-snip-snip"));
ConsolePopup(args.Actor, Loc.GetString("cargo-console-snip-snip"));
PlayDenySound(uid, component);
}
@@ -165,7 +165,7 @@ namespace Content.Server.Cargo.Systems
// Not enough 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);
return;
}
@@ -180,7 +180,7 @@ namespace Content.Server.Cargo.Systems
if (ev.FulfillmentEntity == null)
{
ConsolePopup(args.Session, Loc.GetString("cargo-console-unfulfilled"));
ConsolePopup(args.Actor, Loc.GetString("cargo-console-unfulfilled"));
PlayDenySound(uid, component);
return;
}
@@ -200,7 +200,7 @@ namespace Content.Server.Cargo.Systems
("approverJob", approverJob),
("cost", cost));
_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
_adminLogger.Add(LogType.Action, LogImpact.Low,
@@ -271,7 +271,7 @@ namespace Content.Server.Cargo.Systems
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;
if (args.Amount <= 0)
@@ -319,9 +319,9 @@ namespace Content.Server.Cargo.Systems
!TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase) ||
!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,
GetOutstandingOrderCount(orderDatabase),
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)

View File

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

View File

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

View File

@@ -80,7 +80,7 @@ namespace Content.Server.Chemistry.EntitySystems
chemMaster.Mode, BuildInputContainerInfo(inputContainer), BuildOutputContainerInfo(outputContainer),
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)
@@ -179,7 +179,7 @@ namespace Content.Server.Chemistry.EntitySystems
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);
if (maybeContainer is not { Valid: true } container
|| !TryComp(container, out StorageComponent? storage))
@@ -218,18 +218,9 @@ namespace Content.Server.Chemistry.EntitySystems
pill.PillType = chemMaster.Comp.PillType;
Dirty(item, pill);
if (user.HasValue)
{
// Log pill creation by a user
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user.Value):user} printed {ToPrettyString(item):pill} {SolutionContainerSystem.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)}");
}
// Log pill creation by a user
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user):user} printed {ToPrettyString(item):pill} {SharedSolutionContainerSystem.ToPrettyString(itemSolution.Comp.Solution)}");
}
UpdateUiState(chemMaster);
@@ -238,7 +229,7 @@ namespace Content.Server.Chemistry.EntitySystems
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);
if (maybeContainer is not { Valid: true } container
|| !_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);
_solutionContainerSystem.TryAddSolution(soln.Value, withdrawal);
if (user.HasValue)
{
// Log bottle creation by a user
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user.Value):user} bottled {ToPrettyString(container):bottle} {SolutionContainerSystem.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)}");
}
// Log bottle creation by a user
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user):user} bottled {ToPrettyString(container):bottle} {SharedSolutionContainerSystem.ToPrettyString(solution)}");
UpdateUiState(chemMaster);
ClickSound(chemMaster);

View File

@@ -62,7 +62,7 @@ namespace Content.Server.Chemistry.EntitySystems
var inventory = GetInventory(reagentDispenser);
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)

View File

@@ -135,17 +135,17 @@ namespace Content.Server.Cloning
public void UpdateUserInterface(EntityUid consoleUid, CloningConsoleComponent consoleComponent)
{
if (!_uiSystem.TryGetUi(consoleUid, CloningConsoleUiKey.Key, out var ui))
if (!_uiSystem.HasUi(consoleUid, CloningConsoleUiKey.Key))
return;
if (!_powerReceiverSystem.IsPowered(consoleUid))
{
_uiSystem.CloseAll(ui);
_uiSystem.CloseUis(consoleUid);
return;
}
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)

View File

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

View File

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

View File

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

View File

@@ -41,6 +41,18 @@ namespace Content.Server.Construction
component.Node == component.DeconstructionNode)
return;
if (!_prototypeManager.TryIndex(component.Graph, out ConstructionGraphPrototype? graph))
return;
if (component.DeconstructionNode == null)
return;
if (GetCurrentNode(uid, component) is not {} currentNode)
return;
if (graph.Path(currentNode.Name, component.DeconstructionNode) is not {} path || path.Length == 0)
return;
Verb verb = new();
//verb.Category = VerbCategories.Construction;
//TODO VERBS add more construction verbs? Until then, removing construction category

View File

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

View File

@@ -100,12 +100,12 @@ public sealed class CrewManifestSystem : EntitySystem
return;
var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || ev.Session is not { } session)
if (owningStation == null || !TryComp(ev.Actor, out ActorComponent? actorComp))
{
return;
}
CloseEui(owningStation.Value, session, uid);
CloseEui(owningStation.Value, actorComp.PlayerSession, uid);
}
/// <summary>
@@ -136,12 +136,12 @@ public sealed class CrewManifestSystem : EntitySystem
{
Log.Error(
"{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;
}
var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || msg.Session is not { } session)
if (owningStation == null || !TryComp(msg.Actor, out ActorComponent? actorComp))
{
return;
}
@@ -151,7 +151,7 @@ public sealed class CrewManifestSystem : EntitySystem
return;
}
OpenEui(owningStation.Value, session, uid);
OpenEui(owningStation.Value, actorComp.PlayerSession, uid);
}
/// <summary>

View File

@@ -77,7 +77,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
msg.Status == SecurityStatus.Suspected != (msg.Reason != null))
return;
if (!CheckSelected(ent, msg.Session, out var mob, out var key))
if (!CheckSelected(ent, msg.Actor, out var mob, out var key))
return;
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)
{
if (!CheckSelected(ent, msg.Session, out _, out var key))
if (!CheckSelected(ent, msg.Actor, out _, out var key))
return;
var line = msg.Line.Trim();
@@ -167,7 +167,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
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;
if (!_criminalRecords.TryDeleteHistory(key.Value, msg.Index))
@@ -185,7 +185,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
if (!TryComp<StationRecordsComponent>(owningStation, out var stationRecords))
{
_ui.TrySetUiState(uid, CriminalRecordsConsoleKey.Key, new CriminalRecordsConsoleState());
_ui.SetUiState(uid, CriminalRecordsConsoleKey.Key, new CriminalRecordsConsoleState());
return;
}
@@ -201,24 +201,22 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
state.SelectedKey = id;
}
_ui.TrySetUiState(uid, CriminalRecordsConsoleKey.Key, state);
_ui.SetUiState(uid, CriminalRecordsConsoleKey.Key, state);
}
/// <summary>
/// Boilerplate that most actions use, if they require that a record be selected.
/// Obviously shouldn't be used for selecting records.
/// </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)
{
key = null;
mob = null;
if (session.AttachedEntity is not { } user)
return false;
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;
}

View File

@@ -48,9 +48,9 @@ public sealed class SignalTimerSystem : EntitySystem
{
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).Seconds.ToString("D2"),
component.CanEditLabel,
@@ -70,9 +70,9 @@ public sealed class SignalTimerSystem : EntitySystem
_audio.PlayPvs(signalTimer.DoneSound, uid);
_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).Seconds.ToString("D2"),
signalTimer.CanEditLabel,
@@ -117,10 +117,7 @@ public sealed class SignalTimerSystem : EntitySystem
/// <param name="uid">The entity that is interacted with.</param>
private bool IsMessageValid(EntityUid uid, BoundUserInterfaceMessage message)
{
if (message.Session.AttachedEntity is not { Valid: true } mob)
return false;
if (!_accessReader.IsAllowed(mob, uid))
if (!_accessReader.IsAllowed(message.Actor, uid))
return false;
return true;

View File

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

View File

@@ -159,8 +159,7 @@ public sealed class MailingUnitSystem : EntitySystem
args.Handled = true;
UpdateTargetList(uid, component);
if (_userInterfaceSystem.TryGetUi(uid, MailingUnitUiKey.Key, out var bui))
_userInterfaceSystem.OpenUi(bui, actor.PlayerSession);
_userInterfaceSystem.OpenUi(uid, MailingUnitUiKey.Key, actor.PlayerSession);
}
/// <summary>
@@ -178,8 +177,7 @@ public sealed class MailingUnitSystem : EntitySystem
return;
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag);
if (_userInterfaceSystem.TryGetUi(uid, MailingUnitUiKey.Key, out var bui))
_userInterfaceSystem.SetUiState(bui, state);
_userInterfaceSystem.SetUiState(uid, MailingUnitUiKey.Key, state);
}
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>
private void OnUiAction(EntityUid uid, DisposalRouterComponent router, SharedDisposalRouterComponent.UiActionMessage msg)
{
if (!EntityManager.EntityExists(msg.Session.AttachedEntity))
if (!EntityManager.EntityExists(msg.Actor))
return;
if (TryComp<PhysicsComponent>(uid, out var physBody) && physBody.BodyType != BodyType.Static)
return;
@@ -279,9 +280,9 @@ namespace Content.Server.Disposal.Tube
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));
}
}
@@ -292,13 +293,9 @@ namespace Content.Server.Disposal.Tube
/// <returns>Returns a <see cref="SharedDisposalRouterComponent.DisposalRouterUserInterfaceState"/></returns>
private void UpdateRouterUserInterface(EntityUid uid, DisposalRouterComponent router)
{
var bui = _uiSystem.GetUiOrNull(uid, DisposalRouterUiKey.Key);
if (bui == null)
return;
if (router.Tags.Count <= 0)
{
_uiSystem.SetUiState(bui, new DisposalRouterUserInterfaceState(""));
_uiSystem.SetUiState(uid, DisposalRouterUiKey.Key, new DisposalRouterUserInterfaceState(""));
return;
}
@@ -312,7 +309,7 @@ namespace Content.Server.Disposal.Tube
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)

View File

@@ -143,6 +143,9 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
return;
}
if (!CanInsert(uid, component, args.User))
return;
// Add verb to climb inside of the unit,
Verb verb = new()
{
@@ -219,7 +222,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
#region UI Handlers
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;
}
@@ -235,7 +238,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")}");
break;
case SharedDisposalUnitComponent.UiButton.Power:
_power.TogglePower(uid, user: args.Session.AttachedEntity);
_power.TogglePower(uid, user: args.Actor);
break;
default:
throw new ArgumentOutOfRangeException($"{ToPrettyString(player):player} attempted to hit a nonexistant button on {ToPrettyString(uid)}");
@@ -268,7 +271,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
}
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)
@@ -597,7 +600,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
var compState = GetState(uid, component);
var stateString = Loc.GetString($"disposal-unit-state-{compState}");
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);
RaiseLocalEvent(uid, stateUpdatedEvent);
@@ -802,10 +805,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
QueueAutomaticEngage(uid, component);
if (TryComp(inserted, out ActorComponent? actor))
{
_ui.TryClose(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, actor.PlayerSession);
}
_ui.CloseUi(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, inserted);
// Maybe do pullable instead? Eh still fine.
Joints.RecursiveClearJoints(inserted);

View File

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

View File

@@ -3,7 +3,7 @@ using Robust.Shared.GameStates;
namespace Content.Server.Extinguisher;
[NetworkedComponent, RegisterComponent]
[RegisterComponent]
[Access(typeof(FireExtinguisherSystem))]
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 Robust.Shared.Player;
using Robust.Server.GameObjects;
using Robust.Shared.Collections;
namespace Content.Server.Eye.Blinding;
@@ -37,24 +38,19 @@ public sealed class ActivatableUIRequiresVisionSystem : EntitySystem
if (!args.Blind)
return;
if (!TryComp<ActorComponent>(uid, out var actor))
return;
var toClose = new ValueList<(EntityUid Entity, Enum Key)>();
var uiList = _userInterfaceSystem.GetAllUIsForSession(actor.PlayerSession);
if (uiList == null)
return;
Queue<PlayerBoundUserInterface> closeList = new(); // foreach collection modified moment
foreach (var ui in uiList)
foreach (var bui in _userInterfaceSystem.GetActorUis(uid))
{
if (HasComp<ActivatableUIRequiresVisionComponent>(ui.Owner))
closeList.Enqueue(ui);
if (HasComp<ActivatableUIRequiresVisionComponent>(bui.Entity))
{
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

@@ -51,7 +51,7 @@ public sealed class FaxSystem : EntitySystem
/// </summary>
[ValidatePrototypeId<EntityPrototype>]
private const string DefaultPaperPrototypeId = "Paper";
[ValidatePrototypeId<EntityPrototype>]
private const string OfficePaperPrototypeId = "PaperOffice";
@@ -318,7 +318,7 @@ public sealed class FaxSystem : EntitySystem
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)
@@ -358,7 +358,7 @@ public sealed class FaxSystem : EntitySystem
component.SendTimeoutRemaining <= 0 &&
component.InsertingTimeRemaining <= 0;
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>
@@ -410,19 +410,15 @@ public sealed class FaxSystem : EntitySystem
prototype = DefaultPaperPrototypeId;
var name = Loc.GetString("fax-machine-printed-paper-name");
var printout = new FaxPrintout(args.Content, name, prototype);
component.PrintingQueue.Enqueue(printout);
component.SendTimeoutRemaining += component.SendTimeout;
UpdateUserInterface(uid, component);
if (args.Session.AttachedEntity != null)
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(args.Session.AttachedEntity.Value):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}");
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(args.Actor):actor} added print job to {ToPrettyString(uid):tool} with text: {args.Content}");
}
/// <summary>
@@ -457,9 +453,8 @@ public sealed class FaxSystem : EntitySystem
UpdateUserInterface(uid, component);
if (args.Session.AttachedEntity != null)
_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}");
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(args.Actor):actor} added copy job to {ToPrettyString(uid):tool} with text: {ToPrettyString(component.PaperSlot.Item):subject}");
}
/// <summary>

View File

@@ -144,7 +144,7 @@ public sealed class SpraySystem : EntitySystem
_audio.PlayPvs(entity.Comp.SpraySound, entity, entity.Comp.SpraySound.Params.WithVariation(0.125f));
_useDelay.SetDelay((entity, useDelay), TimeSpan.FromSeconds(cooldownTime));
_useDelay.SetLength((entity, useDelay), TimeSpan.FromSeconds(cooldownTime));
_useDelay.TryResetDelay((entity, useDelay));
}
}

View File

@@ -52,8 +52,7 @@ namespace Content.Server.Forensics
component.PrintCooldown,
component.PrintReadyAt);
if (!_uiSystem.TrySetUiState(uid, ForensicScannerUiKey.Key, state))
Log.Warning($"{ToPrettyString(uid)} was unable to set UI state.");
_uiSystem.SetUiState(uid, ForensicScannerUiKey.Key, state);
}
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)
{
if (!TryComp<ActorComponent>(user, out var actor))
return;
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)
{
if (!args.Session.AttachedEntity.HasValue)
{
Log.Warning($"{ToPrettyString(uid)} got OnPrint without Session.AttachedEntity");
return;
}
var user = args.Session.AttachedEntity.Value;
var user = args.Actor;
if (_gameTiming.CurTime < component.PrintReadyAt)
{
@@ -191,7 +181,7 @@ namespace Content.Server.Forensics
// Spawn a piece of paper.
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))
{
@@ -240,9 +230,6 @@ namespace Content.Server.Forensics
private void OnClear(EntityUid uid, ForensicScannerComponent component, ForensicScannerClearMessage args)
{
if (!args.Session.AttachedEntity.HasValue)
return;
component.Fingerprints = new();
component.Fibers = new();
component.DNAs = new();

View File

@@ -245,7 +245,10 @@ namespace Content.Server.GameTicking
var origReadyPlayers = readyPlayers.ToArray();
if (!StartPreset(origReadyPlayers, force))
{
_startingRound = false;
return;
}
// MapInitialize *before* spawning players, our codebase is too shit to do it afterwards...
_mapManager.DoMapInitialize(DefaultMap);

View File

@@ -71,5 +71,5 @@ public sealed partial class TraitorRuleComponent : Component
public int StartingBalance = 20;
[DataField]
public int MaxDifficulty = 20;
public int MaxDifficulty = 5;
}

View File

@@ -16,6 +16,14 @@ public abstract partial class GameRuleSystem<T> where T: IComponent
return EntityQueryEnumerator<ActiveGameRuleComponent, T, GameRuleComponent>();
}
/// <summary>
/// Queries all gamerules, regardless of if they're active or not.
/// </summary>
protected EntityQueryEnumerator<T, GameRuleComponent> QueryAllRules()
{
return EntityQueryEnumerator<T, GameRuleComponent>();
}
/// <summary>
/// Utility function for finding a random event-eligible station entity
/// </summary>

View File

@@ -34,8 +34,8 @@ public abstract partial class GameRuleSystem<T> : EntitySystem where T : ICompon
if (args.Forced || args.Cancelled)
return;
var query = QueryActiveRules();
while (query.MoveNext(out var uid, out _, out _, out var gameRule))
var query = QueryAllRules();
while (query.MoveNext(out var uid, out _, out var gameRule))
{
var minPlayers = gameRule.MinPlayers;
if (args.Players.Length >= minPlayers)

View File

@@ -344,7 +344,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
var timeRemain = nukeops.WarNukieArriveDelay + Timing.CurTime;
ev.DeclaratorEntity.Comp.ShuttleDisabledTime = timeRemain;
DistributeExtraTc(nukeops);
DistributeExtraTc((uid, nukeops));
}
}
}
@@ -371,7 +371,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
return WarConditionStatus.YesWar;
}
private void DistributeExtraTc(NukeopsRuleComponent nukieRule)
private void DistributeExtraTc(Entity<NukeopsRuleComponent> nukieRule)
{
var enumerator = EntityQueryEnumerator<StoreComponent>();
while (enumerator.MoveNext(out var uid, out var component))
@@ -379,13 +379,13 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
if (!_tag.HasTag(uid, NukeOpsUplinkTagPrototype))
continue;
if (GetOutpost(uid) is not {} outpost)
if (GetOutpost(nukieRule.Owner) is not { } outpost)
continue;
if (Transform(uid).MapID != Transform(outpost).MapID) // Will receive bonus TC only on their start outpost
continue;
_store.TryAddCurrency(new () { { TelecrystalCurrencyPrototype, nukieRule.WarTcAmountPerNukie } }, uid, component);
_store.TryAddCurrency(new () { { TelecrystalCurrencyPrototype, nukieRule.Comp.WarTcAmountPerNukie } }, uid, component);
var msg = Loc.GetString("store-currency-war-boost-given", ("target", uid));
_popupSystem.PopupEntity(msg, uid);
@@ -510,7 +510,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
if (!Resolve(ent, ref ent.Comp, false))
return null;
return ent.Comp.MapGrids.FirstOrNull();
return ent.Comp.MapGrids.Where(e => HasComp<StationMemberComponent>(e) && !HasComp<NukeOpsShuttleComponent>(e)).FirstOrNull();
}
/// <remarks>

View File

@@ -34,6 +34,7 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
//Generate objectives
GenerateObjectives(mindId, mind, ent);
_antag.SendBriefing(args.EntityUid, MakeBriefing(args.EntityUid), null, null);
}
private void GenerateObjectives(EntityUid mindId, MindComponent mind, ThiefRuleComponent thiefRule)

View File

@@ -129,7 +129,7 @@ public sealed class GatewaySystem : EntitySystem
unlockTime
);
_ui.TrySetUiState(uid, GatewayUiKey.Key, state);
_ui.SetUiState(uid, GatewayUiKey.Key, state);
}
private void UpdateAppearance(EntityUid uid)
@@ -139,12 +139,14 @@ public sealed class GatewaySystem : EntitySystem
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)
{
return;
}
// 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))
return;

View File

@@ -1,5 +1,4 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Ghost.Roles.Components
{
@@ -10,17 +9,22 @@ namespace Content.Server.Ghost.Roles.Components
[Access(typeof(GhostRoleSystem))]
public sealed partial class GhostRoleMobSpawnerComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)] [DataField("deleteOnSpawn")]
[DataField]
public bool DeleteOnSpawn = true;
[ViewVariables(VVAccess.ReadWrite)] [DataField("availableTakeovers")]
[DataField]
public int AvailableTakeovers = 1;
[ViewVariables]
public int CurrentTakeovers = 0;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? Prototype { get; private set; }
[DataField]
public EntProtoId? Prototype;
/// <summary>
/// If this ghostrole spawner has multiple selectable ghostrole prototypes.
/// </summary>
[DataField]
public List<string> SelectablePrototypes = [];
}
}

View File

@@ -23,6 +23,10 @@ using Robust.Shared.Enums;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Server.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Prototypes;
using Robust.Shared.Collections;
namespace Content.Server.Ghost.Roles
{
@@ -37,6 +41,8 @@ namespace Content.Server.Ghost.Roles
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
private uint _nextRoleIdentifier;
private bool _needsUpdateGhostRoleCount = true;
@@ -63,6 +69,7 @@ namespace Content.Server.Ghost.Roles
SubscribeLocalEvent<GhostRoleComponent, EntityUnpausedEvent>(OnUnpaused);
SubscribeLocalEvent<GhostRoleMobSpawnerComponent, TakeGhostRoleEvent>(OnSpawnerTakeRole);
SubscribeLocalEvent<GhostTakeoverAvailableComponent, TakeGhostRoleEvent>(OnTakeoverTakeRole);
SubscribeLocalEvent<GhostRoleMobSpawnerComponent, GetVerbsEvent<Verb>>(OnVerb);
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
}
@@ -74,11 +81,11 @@ namespace Content.Server.Ghost.Roles
switch (args.NewMobState)
{
case MobState.Alive:
{
if (!ghostRole.Taken)
RegisterGhostRole((component, ghostRole));
break;
}
{
if (!ghostRole.Taken)
RegisterGhostRole((component, ghostRole));
break;
}
case MobState.Critical:
case MobState.Dead:
UnregisterGhostRole((component, ghostRole));
@@ -100,11 +107,11 @@ namespace Content.Server.Ghost.Roles
public void OpenEui(ICommonSession session)
{
if (session.AttachedEntity is not {Valid: true} attached ||
if (session.AttachedEntity is not { Valid: true } attached ||
!EntityManager.HasComponent<GhostComponent>(attached))
return;
if(_openUis.ContainsKey(session))
if (_openUis.ContainsKey(session))
CloseEui(session);
var eui = _openUis[session] = new GhostRolesEui();
@@ -250,7 +257,7 @@ namespace Content.Server.Ghost.Roles
if (metaQuery.GetComponent(uid).EntityPaused)
continue;
roles.Add(new GhostRoleInfo {Identifier = id, Name = role.RoleName, Description = role.RoleDescription, Rules = role.RoleRules, Requirements = role.Requirements});
roles.Add(new GhostRoleInfo { Identifier = id, Name = role.RoleName, Description = role.RoleDescription, Rules = role.RoleRules, Requirements = role.Requirements });
}
return roles.ToArray();
@@ -407,6 +414,63 @@ namespace Content.Server.Ghost.Roles
args.TookRole = true;
}
private void OnVerb(EntityUid uid, GhostRoleMobSpawnerComponent component, GetVerbsEvent<Verb> args)
{
var prototypes = component.SelectablePrototypes;
if (prototypes.Count < 1)
return;
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
return;
var verbs = new ValueList<Verb>();
foreach (var prototypeID in prototypes)
{
if (_prototype.TryIndex<GhostRolePrototype>(prototypeID, out var prototype))
{
var verb = CreateVerb(uid, component, args.User, prototype);
verbs.Add(verb);
}
}
args.Verbs.UnionWith(verbs);
}
private Verb CreateVerb(EntityUid uid, GhostRoleMobSpawnerComponent component, EntityUid userUid, GhostRolePrototype prototype)
{
var verbText = Loc.GetString(prototype.Name);
return new Verb()
{
Text = verbText,
Disabled = component.Prototype == prototype.EntityPrototype,
Category = VerbCategory.SelectType,
Act = () => SetMode(uid, prototype, verbText, component, userUid)
};
}
public void SetMode(EntityUid uid, GhostRolePrototype prototype, string verbText, GhostRoleMobSpawnerComponent? component, EntityUid? userUid = null)
{
if (!Resolve(uid, ref component))
return;
var ghostrolecomp = EnsureComp<GhostRoleComponent>(uid);
component.Prototype = prototype.EntityPrototype;
ghostrolecomp.RoleName = verbText;
ghostrolecomp.RoleDescription = prototype.Description;
ghostrolecomp.RoleRules = prototype.Rules;
// Dirty(ghostrolecomp);
if (userUid != null)
{
var msg = Loc.GetString("ghostrole-spawner-select", ("mode", verbText));
_popupSystem.PopupEntity(msg, uid, userUid.Value);
}
}
}
[AnyCommand]
@@ -417,7 +481,7 @@ namespace Content.Server.Ghost.Roles
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if(shell.Player != null)
if (shell.Player != null)
EntitySystem.Get<GhostRoleSystem>().OpenEui(shell.Player);
else
shell.WriteLine("You can only open the ghost roles UI on a client.");

View File

@@ -131,13 +131,13 @@ namespace Content.Server.Gravity
}
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))
return;
if (session is { AttachedEntity: { } })
_adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{session:player} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}");
if (user != null)
_adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{ToPrettyString(user)} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}");
component.SwitchedOn = on;
UpdatePowerState(component, powerReceiver);
@@ -154,7 +154,7 @@ namespace Content.Server.Gravity
private void UpdateUI(Entity<GravityGeneratorComponent, ApcPowerReceiverComponent> ent, float chargeRate)
{
var (_, component, powerReceiver) = ent;
if (!_uiSystem.IsUiOpen(ent, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key))
if (!_uiSystem.IsUiOpen(ent.Owner, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key))
return;
var chargeTarget = chargeRate < 0 ? 0 : component.MaxCharge;
@@ -189,8 +189,8 @@ namespace Content.Server.Gravity
chargeEta
);
_uiSystem.TrySetUiState(
ent,
_uiSystem.SetUiState(
ent.Owner,
SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key,
state);
@@ -209,9 +209,6 @@ namespace Content.Server.Gravity
private void OnInteractHand(EntityUid uid, GravityGeneratorComponent component, InteractHandEvent args)
{
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
ApcPowerReceiverComponent? powerReceiver = default!;
if (!Resolve(uid, ref powerReceiver))
return;
@@ -220,7 +217,7 @@ namespace Content.Server.Gravity
if (!component.Intact || powerReceiver.PowerReceived < component.IdlePowerUse)
return;
_uiSystem.TryOpen(uid, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key, actor.PlayerSession);
_uiSystem.OpenUi(uid, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key, args.User);
component.NeedUIUpdate = true;
}
@@ -287,7 +284,7 @@ namespace Content.Server.Gravity
GravityGeneratorComponent component,
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"),
Act = () =>
{
_uiSystem.TryOpen(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession);
_uiSystem.TrySetUiState(
_uiSystem.OpenUi(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession);
_uiSystem.SetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.MarkingSet, component.Species,
@@ -48,8 +48,7 @@ public sealed partial class HumanoidAppearanceSystem
private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierBaseLayersSetMessage message)
{
if (message.Session is not { } player
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
if (!_adminManager.HasAdminFlag(message.Actor, AdminFlags.Fun))
{
return;
}
@@ -67,7 +66,7 @@ public sealed partial class HumanoidAppearanceSystem
if (message.ResendState)
{
_uiSystem.TrySetUiState(
_uiSystem.SetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.MarkingSet, component.Species,
@@ -81,8 +80,7 @@ public sealed partial class HumanoidAppearanceSystem
private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierMarkingSetMessage message)
{
if (message.Session is not { } player
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
if (!_adminManager.HasAdminFlag(message.Actor, AdminFlags.Fun))
{
return;
}
@@ -92,7 +90,7 @@ public sealed partial class HumanoidAppearanceSystem
if (message.ResendState)
{
_uiSystem.TrySetUiState(
_uiSystem.SetUiState(
uid,
HumanoidMarkingModifierKey.Key,
new HumanoidMarkingModifierState(component.MarkingSet, component.Species,

View File

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

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