* Fix ActivatableUIRequiresPowerCellComponent stopping power draw when one of two people closes the UI.
Also fixes it to check UiKey properly.
* Remove unnecessary CrewManifestViewer on PDAs
This is for a pop-up crew manifest UI, which the PDA doesn't use.
* Fix BoundUIClosedEvents that didn't check UI key/not correctly at least.
Uses the new helper method in engine.
* Fix drone (cargo shuttle) pilot console UI breaking if two people open it and one person closes it.
* Fixes for disposal router/tagger UI.
Code was badly copy pasted without changing identifiers, never worked.
Also cleaned up some of the logic (text trimming, sounds).
Also removed the "refuse to work if you have something in your active hand" check like why.
* Avoid running most ActivatableUIComponent logic when closing a UI via toggle
Activating the UI while it's already open closes it via toggle. Except it still ran 99% of the "attempting to open" logic which makes no sense.
This probably fixes a bug or some other dumb behavior somewhere.
* Bitch
{
base.Initialize();
- SubscribeLocalEvent<AccessOverriderComponent, WriteToTargetAccessReaderIdMessage>(OnWriteToTargetAccessReaderIdMessage);
SubscribeLocalEvent<AccessOverriderComponent, ComponentStartup>(UpdateUserInterface);
SubscribeLocalEvent<AccessOverriderComponent, EntInsertedIntoContainerMessage>(UpdateUserInterface);
SubscribeLocalEvent<AccessOverriderComponent, EntRemovedFromContainerMessage>(UpdateUserInterface);
SubscribeLocalEvent<AccessOverriderComponent, AfterInteractEvent>(AfterInteractOn);
SubscribeLocalEvent<AccessOverriderComponent, AccessOverriderDoAfterEvent>(OnDoAfter);
- SubscribeLocalEvent<AccessOverriderComponent, BoundUIOpenedEvent>(UpdateUserInterface);
- SubscribeLocalEvent<AccessOverriderComponent, BoundUIClosedEvent>(OnClose);
+
+ Subs.BuiEvents<AccessOverriderComponent>(AccessOverriderUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIOpenedEvent>(UpdateUserInterface);
+ subs.Event<BoundUIClosedEvent>(OnClose);
+ subs.Event<WriteToTargetAccessReaderIdMessage>(OnWriteToTargetAccessReaderIdMessage);
+ });
}
private void AfterInteractOn(EntityUid uid, AccessOverriderComponent component, AfterInteractEvent args)
SubscribeLocalEvent<BlockGameArcadeComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<BlockGameArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpen);
- SubscribeLocalEvent<BlockGameArcadeComponent, BoundUIClosedEvent>(OnAfterUiClose);
SubscribeLocalEvent<BlockGameArcadeComponent, PowerChangedEvent>(OnBlockPowerChanged);
- SubscribeLocalEvent<BlockGameArcadeComponent, BlockGameMessages.BlockGamePlayerActionMessage>(OnPlayerAction);
+
+ Subs.BuiEvents<BlockGameArcadeComponent>(BlockGameUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIClosedEvent>(OnAfterUiClose);
+ subs.Event<BlockGameMessages.BlockGamePlayerActionMessage>(OnPlayerAction);
+ });
}
public override void Update(float frameTime)
SubscribeLocalEvent<AirAlarmComponent, AtmosDeviceUpdateEvent>(OnAtmosUpdate);
SubscribeLocalEvent<AirAlarmComponent, AtmosAlarmEvent>(OnAtmosAlarm);
SubscribeLocalEvent<AirAlarmComponent, PowerChangedEvent>(OnPowerChanged);
- SubscribeLocalEvent<AirAlarmComponent, AirAlarmResyncAllDevicesMessage>(OnResyncAll);
- SubscribeLocalEvent<AirAlarmComponent, AirAlarmUpdateAlarmModeMessage>(OnUpdateAlarmMode);
- SubscribeLocalEvent<AirAlarmComponent, AirAlarmUpdateAutoModeMessage>(OnUpdateAutoMode);
- SubscribeLocalEvent<AirAlarmComponent, AirAlarmUpdateAlarmThresholdMessage>(OnUpdateThreshold);
- SubscribeLocalEvent<AirAlarmComponent, AirAlarmUpdateDeviceDataMessage>(OnUpdateDeviceData);
- SubscribeLocalEvent<AirAlarmComponent, AirAlarmCopyDeviceDataMessage>(OnCopyDeviceData);
- SubscribeLocalEvent<AirAlarmComponent, AirAlarmTabSetMessage>(OnTabChange);
SubscribeLocalEvent<AirAlarmComponent, DeviceListUpdateEvent>(OnDeviceListUpdate);
- SubscribeLocalEvent<AirAlarmComponent, BoundUIClosedEvent>(OnClose);
SubscribeLocalEvent<AirAlarmComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<AirAlarmComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<AirAlarmComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<AirAlarmComponent, ActivateInWorldEvent>(OnActivate);
+
+ Subs.BuiEvents<AirAlarmComponent>(SharedAirAlarmInterfaceKey.Key, subs =>
+ {
+ subs.Event<BoundUIClosedEvent>(OnClose);
+ subs.Event<AirAlarmResyncAllDevicesMessage>(OnResyncAll);
+ subs.Event<AirAlarmUpdateAlarmModeMessage>(OnUpdateAlarmMode);
+ subs.Event<AirAlarmUpdateAutoModeMessage>(OnUpdateAutoMode);
+ subs.Event<AirAlarmUpdateAlarmThresholdMessage>(OnUpdateThreshold);
+ subs.Event<AirAlarmUpdateDeviceDataMessage>(OnUpdateDeviceData);
+ subs.Event<AirAlarmCopyDeviceDataMessage>(OnCopyDeviceData);
+ subs.Event<AirAlarmTabSetMessage>(OnTabChange);
+ });
}
private void OnDeviceListUpdate(EntityUid uid, AirAlarmComponent component, DeviceListUpdateEvent args)
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Player;
+using Robust.Shared.Utility;
namespace Content.Server.CrewManifest;
SubscribeLocalEvent<AfterGeneralRecordCreatedEvent>(AfterGeneralRecordCreated);
SubscribeLocalEvent<RecordModifiedEvent>(OnRecordModified);
SubscribeLocalEvent<RecordRemovedEvent>(OnRecordRemoved);
- SubscribeLocalEvent<CrewManifestViewerComponent, BoundUIClosedEvent>(OnBoundUiClose);
- SubscribeLocalEvent<CrewManifestViewerComponent, CrewManifestOpenUiMessage>(OpenEuiFromBui);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
SubscribeNetworkEvent<RequestCrewManifestMessage>(OnRequestCrewManifest);
+
+ SubscribeLocalEvent<CrewManifestViewerComponent, BoundUIClosedEvent>(OnBoundUiClose);
+ SubscribeLocalEvent<CrewManifestViewerComponent, CrewManifestOpenUiMessage>(OpenEuiFromBui);
}
private void OnRoundRestart(RoundRestartCleanupEvent ev)
private void OnBoundUiClose(EntityUid uid, CrewManifestViewerComponent component, BoundUIClosedEvent ev)
{
+ if (!Equals(ev.UiKey, component.OwnerKey))
+ return;
+
var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || ev.Session is not { } session)
{
private void OpenEuiFromBui(EntityUid uid, CrewManifestViewerComponent component, CrewManifestOpenUiMessage msg)
{
+ if (!msg.UiKey.Equals(component.OwnerKey))
+ {
+ Log.Error(
+ "{User} tried to open crew manifest from wrong UI: {Key}. Correct owned is {ExpectedKey}",
+ msg.Session, msg.UiKey, component.OwnerKey);
+ return;
+ }
+
var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || msg.Session is not { } session)
{
+using Content.Shared.CCVar;
+
namespace Content.Server.CrewManifest;
[RegisterComponent]
{
/// <summary>
/// If this manifest viewer is unsecure or not. If it is,
- /// CCVars.CrewManifestUnsecure being false will
+ /// <see cref="CCVars.CrewManifestUnsecure"/> being false will
/// not allow this entity to be processed by CrewManifestSystem.
/// </summary>
[DataField("unsecure")] public bool Unsecure;
+
+ /// <summary>
+ /// The owner interface of this crew manifest viewer. When it closes, so too will an opened crew manifest.
+ /// </summary>
+ [DataField(required: true)]
+ public Enum OwnerKey { get; private set; } = default!;
}
/// </summary>
private void OnUiClosed(EntityUid uid, NetworkConfiguratorComponent component, BoundUIClosedEvent args)
{
+ if (!args.UiKey.Equals(NetworkConfiguratorUiKey.Configure)
+ && !args.UiKey.Equals(NetworkConfiguratorUiKey.Link)
+ && !args.UiKey.Equals(NetworkConfiguratorUiKey.List))
+ {
+ return;
+ }
+
if (TryComp(component.ActiveDeviceList, out DeviceListComponent? list))
{
list.Configurators.Remove(uid);
SubscribeLocalEvent<DisposalJunctionComponent, GetDisposalsConnectableDirectionsEvent>(OnGetJunctionConnectableDirections);
SubscribeLocalEvent<DisposalJunctionComponent, GetDisposalsNextDirectionEvent>(OnGetJunctionNextDirection);
- SubscribeLocalEvent<DisposalRouterComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<DisposalRouterComponent, GetDisposalsConnectableDirectionsEvent>(OnGetRouterConnectableDirections);
SubscribeLocalEvent<DisposalRouterComponent, GetDisposalsNextDirectionEvent>(OnGetRouterNextDirection);
SubscribeLocalEvent<DisposalTransitComponent, GetDisposalsConnectableDirectionsEvent>(OnGetTransitConnectableDirections);
SubscribeLocalEvent<DisposalTransitComponent, GetDisposalsNextDirectionEvent>(OnGetTransitNextDirection);
- SubscribeLocalEvent<DisposalTaggerComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<DisposalTaggerComponent, GetDisposalsConnectableDirectionsEvent>(OnGetTaggerConnectableDirections);
SubscribeLocalEvent<DisposalTaggerComponent, GetDisposalsNextDirectionEvent>(OnGetTaggerNextDirection);
- SubscribeLocalEvent<DisposalRouterComponent, ActivatableUIOpenAttemptEvent>(OnOpenRouterUIAttempt);
- SubscribeLocalEvent<DisposalTaggerComponent, ActivatableUIOpenAttemptEvent>(OnOpenTaggerUIAttempt);
+ Subs.BuiEvents<DisposalRouterComponent>(DisposalRouterUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIOpenedEvent>(OnOpenRouterUI);
+ subs.Event<SharedDisposalRouterComponent.UiActionMessage>(OnUiAction);
+ });
- SubscribeLocalEvent<DisposalRouterComponent, SharedDisposalRouterComponent.UiActionMessage>(OnUiAction);
- SubscribeLocalEvent<DisposalTaggerComponent, SharedDisposalTaggerComponent.UiActionMessage>(OnUiAction);
+ Subs.BuiEvents<DisposalTaggerComponent>(DisposalTaggerUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIOpenedEvent>(OnOpenTaggerUI);
+ subs.Event<SharedDisposalTaggerComponent.UiActionMessage>(OnUiAction);
+ });
}
/// <param name="msg">A user interface message from the client.</param>
private void OnUiAction(EntityUid uid, DisposalTaggerComponent tagger, SharedDisposalTaggerComponent.UiActionMessage msg)
{
- if (!DisposalTaggerUiKey.Key.Equals(msg.UiKey))
- return;
if (TryComp<PhysicsComponent>(uid, out var physBody) && physBody.BodyType != BodyType.Static)
return;
//Check for correct message and ignore maleformed strings
if (msg.Action == SharedDisposalTaggerComponent.UiAction.Ok && SharedDisposalTaggerComponent.TagRegex.IsMatch(msg.Tag))
{
- tagger.Tag = msg.Tag;
+ tagger.Tag = msg.Tag.Trim();
_audioSystem.PlayPvs(tagger.ClickSound, uid, AudioParams.Default.WithVolume(-2f));
}
}
/// <param name="msg">A user interface message from the client.</param>
private void OnUiAction(EntityUid uid, DisposalRouterComponent router, SharedDisposalRouterComponent.UiActionMessage msg)
{
- if (!DisposalRouterUiKey.Key.Equals(msg.UiKey))
- return;
if (!EntityManager.EntityExists(msg.Session.AttachedEntity))
return;
if (TryComp<PhysicsComponent>(uid, out var physBody) && physBody.BodyType != BodyType.Static)
router.Tags.Clear();
foreach (var tag in msg.Tags.Split(',', StringSplitOptions.RemoveEmptyEntries))
{
+ var trimmed = tag.Trim();
+ if (trimmed == "")
+ continue;
+
router.Tags.Add(tag.Trim());
- _audioSystem.PlayPvs(router.ClickSound, uid, AudioParams.Default.WithVolume(-2f));
}
+
+ _audioSystem.PlayPvs(router.ClickSound, uid, AudioParams.Default.WithVolume(-2f));
}
}
DisconnectTube(uid, tube);
}
- private void OnComponentRemove(EntityUid uid, DisposalTaggerComponent tagger, ComponentRemove args)
- {
- _uiSystem.TryCloseAll(uid, DisposalTaggerUiKey.Key);
- }
-
- private void OnComponentRemove(EntityUid uid, DisposalRouterComponent tagger, ComponentRemove args)
- {
- _uiSystem.TryCloseAll(uid, DisposalRouterUiKey.Key);
- }
-
private void OnGetBendConnectableDirections(EntityUid uid, DisposalBendComponent component, ref GetDisposalsConnectableDirectionsEvent args)
{
var direction = Transform(uid).LocalRotation;
DisconnectTube(uid, component);
}
- private void OnOpenRouterUIAttempt(EntityUid uid, DisposalRouterComponent router, ActivatableUIOpenAttemptEvent args)
+ private void OnOpenRouterUI(EntityUid uid, DisposalRouterComponent router, BoundUIOpenedEvent args)
{
- if (!TryComp<HandsComponent>(args.User, out var hands))
- {
- _popups.PopupClient(Loc.GetString("disposal-router-window-tag-input-activate-no-hands"), uid, args.User);
- return;
- }
-
- var activeHandEntity = hands.ActiveHandEntity;
- if (activeHandEntity != null)
- {
- args.Cancel();
- }
-
UpdateRouterUserInterface(uid, router);
}
- private void OnOpenTaggerUIAttempt(EntityUid uid, DisposalTaggerComponent tagger, ActivatableUIOpenAttemptEvent args)
+ private void OnOpenTaggerUI(EntityUid uid, DisposalTaggerComponent tagger, BoundUIOpenedEvent args)
{
- if (!TryComp<HandsComponent>(args.User, out var hands))
- {
- _popups.PopupClient(Loc.GetString("disposal-tagger-window-activate-no-hands"), uid, args.User);
- return;
- }
-
- var activeHandEntity = hands.ActiveHandEntity;
- if (activeHandEntity != null)
- {
- args.Cancel();
- }
-
if (_uiSystem.TryGetUi(uid, DisposalTaggerUiKey.Key, out var bui))
+ {
_uiSystem.SetUiState(bui,
new DisposalTaggerUserInterfaceState(tagger.Tag));
+ }
}
/// <summary>
/// <returns>Returns a <see cref="SharedDisposalRouterComponent.DisposalRouterUserInterfaceState"/></returns>
private void UpdateRouterUserInterface(EntityUid uid, DisposalRouterComponent router)
{
- var bui = _uiSystem.GetUiOrNull(uid, DisposalTaggerUiKey.Key);
+ var bui = _uiSystem.GetUiOrNull(uid, DisposalRouterUiKey.Key);
+ if (bui == null)
+ return;
+
if (router.Tags.Count <= 0)
{
- if (bui is not null)
- _uiSystem.SetUiState(bui, new DisposalTaggerUserInterfaceState(""));
+ _uiSystem.SetUiState(bui, new DisposalRouterUserInterfaceState(""));
return;
}
taglist.Remove(taglist.Length - 2, 2);
- if (bui is not null)
- _uiSystem.SetUiState(bui, new DisposalTaggerUserInterfaceState(taglist.ToString()));
+ _uiSystem.SetUiState(bui, new DisposalRouterUserInterfaceState(taglist.ToString()));
}
private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args)
SubscribeNetworkEvent<InstrumentSetMasterEvent>(OnMidiSetMaster);
SubscribeNetworkEvent<InstrumentSetFilteredChannelEvent>(OnMidiSetFilteredChannel);
- SubscribeLocalEvent<InstrumentComponent, BoundUIClosedEvent>(OnBoundUIClosed);
- SubscribeLocalEvent<InstrumentComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
- SubscribeLocalEvent<InstrumentComponent, InstrumentBandRequestBuiMessage>(OnBoundUIRequestBands);
+ Subs.BuiEvents<InstrumentComponent>(InstrumentUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIClosedEvent>(OnBoundUIClosed);
+ subs.Event<BoundUIOpenedEvent>(OnBoundUIOpened);
+ subs.Event<InstrumentBandRequestBuiMessage>(OnBoundUIRequestBands);
+ });
SubscribeLocalEvent<InstrumentComponent, ComponentGetState>(OnStrumentGetState);
private void OnBoundUIClosed(EntityUid uid, InstrumentComponent component, BoundUIClosedEvent args)
{
- if (args.UiKey is not InstrumentUiKey)
- return;
-
if (HasComp<ActiveInstrumentComponent>(uid)
&& _bui.TryGetUi(uid, args.UiKey, out var bui)
&& bui.SubscribedSessions.Count == 0)
private void OnBoundUIOpened(EntityUid uid, InstrumentComponent component, BoundUIOpenedEvent args)
{
- if (args.UiKey is not InstrumentUiKey)
- return;
-
EnsureComp<ActiveInstrumentComponent>(uid);
Clean(uid, component);
}
{
base.Initialize();
SubscribeLocalEvent<MagicMirrorComponent, ActivatableUIOpenAttemptEvent>(OnOpenUIAttempt);
- SubscribeLocalEvent<MagicMirrorComponent, BoundUIClosedEvent>(OnUIClosed);
- SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorSelectMessage>(OnMagicMirrorSelect);
- SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorChangeColorMessage>(OnTryMagicMirrorChangeColor);
- SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorAddSlotMessage>(OnTryMagicMirrorAddSlot);
- SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorRemoveSlotMessage>(OnTryMagicMirrorRemoveSlot);
+
+ Subs.BuiEvents<MagicMirrorComponent>(MagicMirrorUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIClosedEvent>(OnUIClosed);
+ subs.Event<MagicMirrorSelectMessage>(OnMagicMirrorSelect);
+ subs.Event<MagicMirrorChangeColorMessage>(OnTryMagicMirrorChangeColor);
+ subs.Event<MagicMirrorAddSlotMessage>(OnTryMagicMirrorAddSlot);
+ subs.Event<MagicMirrorRemoveSlotMessage>(OnTryMagicMirrorRemoveSlot);
+ });
SubscribeLocalEvent<MagicMirrorComponent, AfterInteractEvent>(OnMagicMirrorInteract);
{
base.Initialize();
SubscribeLocalEvent<StationMapUserComponent, EntParentChangedMessage>(OnUserParentChanged);
- SubscribeLocalEvent<StationMapComponent, BoundUIOpenedEvent>(OnStationMapOpened);
- SubscribeLocalEvent<StationMapComponent, BoundUIClosedEvent>(OnStationMapClosed);
+
+ Subs.BuiEvents<StationMapComponent>(StationMapUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIOpenedEvent>(OnStationMapOpened);
+ subs.Event<BoundUIClosedEvent>(OnStationMapClosed);
+ });
}
private void OnStationMapClosed(EntityUid uid, StationMapComponent component, BoundUIClosedEvent args)
{
private void InitUI()
{
- SubscribeLocalEvent<SensorMonitoringConsoleComponent, BoundUIClosedEvent>(ConsoleUIClosed);
+ Subs.BuiEvents<SensorMonitoringConsoleComponent>(SensorMonitoringConsoleUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIClosedEvent>(ConsoleUIClosed);
+ });
}
private void UpdateConsoleUI(EntityUid uid, SensorMonitoringConsoleComponent comp)
private void OnDronePilotConsoleClose(EntityUid uid, DroneConsoleComponent component, BoundUIClosedEvent args)
{
- component.Entity = null;
+ // Only if last person closed UI.
+ if (!_ui.IsUiOpen(uid, args.UiKey))
+ component.Entity = null;
}
private void OnCargoGetConsole(EntityUid uid, DroneConsoleComponent component, ref ConsoleShuttleEvent args)
SubscribeLocalEvent<ShuttleConsoleComponent, PowerChangedEvent>(OnConsolePowerChange);
SubscribeLocalEvent<ShuttleConsoleComponent, AnchorStateChangedEvent>(OnConsoleAnchorChange);
SubscribeLocalEvent<ShuttleConsoleComponent, ActivatableUIOpenAttemptEvent>(OnConsoleUIOpenAttempt);
- SubscribeLocalEvent<ShuttleConsoleComponent, ShuttleConsoleFTLRequestMessage>(OnDestinationMessage);
- SubscribeLocalEvent<ShuttleConsoleComponent, BoundUIClosedEvent>(OnConsoleUIClose);
+ Subs.BuiEvents<ShuttleConsoleComponent>(ShuttleConsoleUiKey.Key, subs =>
+ {
+ subs.Event<ShuttleConsoleFTLRequestMessage>(OnDestinationMessage);
+ subs.Event<BoundUIClosedEvent>(OnConsoleUIClose);
+ });
SubscribeLocalEvent<DroneConsoleComponent, ConsoleShuttleEvent>(OnCargoGetConsole);
SubscribeLocalEvent<DroneConsoleComponent, AfterActivatableUIOpenEvent>(OnDronePilotConsoleOpen);
- SubscribeLocalEvent<DroneConsoleComponent, BoundUIClosedEvent>(OnDronePilotConsoleClose);
+ Subs.BuiEvents<DroneConsoleComponent>(ShuttleConsoleUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIClosedEvent>(OnDronePilotConsoleClose);
+ });
SubscribeLocalEvent<DockEvent>(OnDock);
SubscribeLocalEvent<UndockEvent>(OnUndock);
{
base.Initialize();
SubscribeLocalEvent<StorageComponent, GetVerbsEvent<ActivationVerb>>(AddUiVerb);
- SubscribeLocalEvent<StorageComponent, BoundUIClosedEvent>(OnBoundUIClosed);
+ Subs.BuiEvents<StorageComponent>(StorageComponent.StorageUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIClosedEvent>(OnBoundUIClosed);
+ });
SubscribeLocalEvent<StorageComponent, BeforeExplodeEvent>(OnExploded);
SubscribeLocalEvent<StorageFillComponent, MapInitEvent>(OnStorageFillMapInit);
public override void Initialize()
{
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, SurveillanceCameraDeactivateEvent>(OnSurveillanceCameraDeactivate);
- SubscribeLocalEvent<SurveillanceCameraMonitorComponent, BoundUIClosedEvent>(OnBoundUiClose);
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, PowerChangedEvent>(OnPowerChanged);
- SubscribeLocalEvent<SurveillanceCameraMonitorComponent, SurveillanceCameraMonitorSwitchMessage>(OnSwitchMessage);
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
- SubscribeLocalEvent<SurveillanceCameraMonitorComponent, SurveillanceCameraMonitorSubnetRequestMessage>(OnSubnetRequest);
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, AfterActivatableUIOpenEvent>(OnToggleInterface);
- SubscribeLocalEvent<SurveillanceCameraMonitorComponent, SurveillanceCameraRefreshCamerasMessage>(OnRefreshCamerasMessage);
- SubscribeLocalEvent<SurveillanceCameraMonitorComponent, SurveillanceCameraRefreshSubnetsMessage>(OnRefreshSubnetsMessage);
- SubscribeLocalEvent<SurveillanceCameraMonitorComponent, SurveillanceCameraDisconnectMessage>(OnDisconnectMessage);
+ Subs.BuiEvents<SurveillanceCameraMonitorComponent>(SurveillanceCameraMonitorUiKey.Key, subs =>
+ {
+ subs.Event<SurveillanceCameraRefreshCamerasMessage>(OnRefreshCamerasMessage);
+ subs.Event<SurveillanceCameraRefreshSubnetsMessage>(OnRefreshSubnetsMessage);
+ subs.Event<SurveillanceCameraDisconnectMessage>(OnDisconnectMessage);
+ subs.Event<SurveillanceCameraMonitorSubnetRequestMessage>(OnSubnetRequest);
+ subs.Event<SurveillanceCameraMonitorSwitchMessage>(OnSwitchMessage);
+ subs.Event<BoundUIClosedEvent>(OnBoundUiClose);
+ });
}
private const float _maxHeartbeatTime = 300f;
private void OnBatteryOpened(EntityUid uid, ActivatableUIRequiresPowerCellComponent component, BoundUIOpenedEvent args)
{
+ var activatable = Comp<ActivatableUIComponent>(uid);
+
+ if (!args.UiKey.Equals(activatable.Key))
+ return;
+
_cell.SetPowerCellDrawEnabled(uid, true);
}
private void OnBatteryClosed(EntityUid uid, ActivatableUIRequiresPowerCellComponent component, BoundUIClosedEvent args)
{
- _cell.SetPowerCellDrawEnabled(uid, false);
+ var activatable = Comp<ActivatableUIComponent>(uid);
+
+ if (!args.UiKey.Equals(activatable.Key))
+ return;
+
+ // Stop drawing power if this was the last person with the UI open.
+ if (!_uiSystem.IsUiOpen(uid, activatable.Key))
+ _cell.SetPowerCellDrawEnabled(uid, false);
}
/// <summary>
private bool InteractUI(EntityUid user, EntityUid uiEntity, ActivatableUIComponent aui)
{
- if (!_blockerSystem.CanInteract(user, uiEntity) && (!aui.AllowSpectator || !HasComp<GhostComponent>(user)))
+ if (!TryComp(user, out ActorComponent? actor))
return false;
- if (aui.RequireHands && !HasComp<HandsComponent>(user))
+ if (aui.Key == null)
return false;
- if (!EntityManager.TryGetComponent(user, out ActorComponent? actor))
+ if (!_uiSystem.TryGetUi(uiEntity, aui.Key, out var ui))
return false;
- if (aui.AdminOnly && !_adminManager.IsAdmin(actor.PlayerSession))
+ if (ui.SubscribedSessions.Contains(actor.PlayerSession))
+ {
+ _uiSystem.CloseUi(ui, actor.PlayerSession);
+ return true;
+ }
+
+ if (!_blockerSystem.CanInteract(user, uiEntity) && (!aui.AllowSpectator || !HasComp<GhostComponent>(user)))
return false;
- if (aui.Key == null)
+ if (aui.RequireHands && !HasComp<HandsComponent>(user))
return false;
- if (!_uiSystem.TryGetUi(uiEntity, aui.Key, out var ui))
+ if (aui.AdminOnly && !_adminManager.IsAdmin(actor.PlayerSession))
return false;
if (aui.SingleUser && (aui.CurrentSingleUser != null) && (actor.PlayerSession != aui.CurrentSingleUser))
RaiseLocalEvent(uiEntity, bae);
SetCurrentSingleUser(uiEntity, actor.PlayerSession, aui);
- _uiSystem.ToggleUi(ui, actor.PlayerSession);
+ _uiSystem.OpenUi(ui, actor.PlayerSession);
//Let the component know a user opened it so it can do whatever it needs to do
var aae = new AfterActivatableUIOpenEvent(user, actor.PlayerSession);
SubscribeLocalEvent<VendingMachineComponent, EmpPulseEvent>(OnEmpPulse);
SubscribeLocalEvent<VendingMachineComponent, ActivatableUIOpenAttemptEvent>(OnActivatableUIOpenAttempt);
- SubscribeLocalEvent<VendingMachineComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
- SubscribeLocalEvent<VendingMachineComponent, BoundUIClosedEvent>(OnBoundUIClosed);
- SubscribeLocalEvent<VendingMachineComponent, VendingMachineEjectMessage>(OnInventoryEjectMessage);
+
+ Subs.BuiEvents<VendingMachineComponent>(VendingMachineUiKey.Key, subs =>
+ {
+ subs.Event<BoundUIOpenedEvent>(OnBoundUIOpened);
+ subs.Event<BoundUIClosedEvent>(OnBoundUIClosed);
+ subs.Event<VendingMachineEjectMessage>(OnInventoryEjectMessage);
+ });
SubscribeLocalEvent<VendingMachineComponent, VendingMachineSelfDispenseEvent>(OnSelfDispense);
private void OnBoundUIClosed(EntityUid uid, VendingMachineComponent component, BoundUIClosedEvent args)
{
- if (args.UiKey is not VendingMachineUiKey)
- return;
-
- if ((VendingMachineUiKey) args.UiKey != VendingMachineUiKey.Key)
- return;
-
// Only vendors that advertise will send message after dispensing
if (component.ShouldSayThankYou && TryComp<AdvertiseComponent>(uid, out var advertise))
{
disposal-router-window-tags-label = Tags:
disposal-router-window-tag-input-tooltip = A comma separated list of tags
disposal-router-window-tag-input-confirm-button = Confirm
-disposal-router-window-tag-input-activate-no-hands = You have no hands
## ConfigureVerb
disposal-tagger-window-title = Disposal Tagger
disposal-tagger-window-tag-input-label = Tag:
disposal-tagger-window-tag-confirm-button = Confirm
-disposal-tagger-window-activate-no-hands = You have no hands.
## ConfigureVerb
configure-verb-get-data-text = Open Configuration
type: InstrumentBoundUserInterface
- key: enum.HealthAnalyzerUiKey.Key
type: HealthAnalyzerBoundUserInterface
- - type: CrewManifestViewer
- unsecure: true
- type: Tag
tags:
- DoorBumpOpener
energy: 1.6
color: "#c94242"
- type: Computer
- board: CargoShuttleConsoleCircuitboard
+ board: CargoShuttleConsoleCircuitboard
- type: StealTarget
stealGroup: CargoShuttleConsoleCircuitboard
board: SalvageShuttleConsoleCircuitboard
- type: StealTarget
stealGroup: SalvageShuttleConsoleCircuitboard
-
+
- type: entity
parent: BaseComputer
id: ComputerIFF
- key: enum.IdCardConsoleUiKey.Key
type: IdCardConsoleBoundUserInterface
- type: CrewManifestViewer
+ ownerKey: enum.IdCardConsoleUiKey.Key
- type: Sprite
layers:
- map: ["computerLayerBody"]
access: [["Salvage"]]
- type: StealTarget
stealGroup: SalvageExpeditionsComputerCircuitboard
-
+
- type: entity
parent: BaseComputer
id: ComputerSurveillanceCameraMonitor