Un-revert IPlayerManager refactor (#21244)

This commit is contained in:
Leon Friedrich
2023-10-28 09:59:53 +11:00
committed by GitHub
parent c55e1dcafd
commit e685cb626b
245 changed files with 781 additions and 943 deletions

View File

@@ -2,7 +2,6 @@ using System.IO;
using System.Linq; using System.Linq;
using Content.Shared.Actions; using Content.Shared.Actions;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.ContentPack; using Robust.Shared.ContentPack;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
@@ -41,8 +40,8 @@ namespace Content.Client.Actions
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<ActionsComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<ActionsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<ActionsComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<ActionsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<ActionsComponent, ComponentHandleState>(HandleComponentState); SubscribeLocalEvent<ActionsComponent, ComponentHandleState>(HandleComponentState);
SubscribeLocalEvent<InstantActionComponent, ComponentHandleState>(OnInstantHandleState); SubscribeLocalEvent<InstantActionComponent, ComponentHandleState>(OnInstantHandleState);
@@ -196,12 +195,12 @@ namespace Content.Client.Actions
return GetActions(user); return GetActions(user);
} }
private void OnPlayerAttached(EntityUid uid, ActionsComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, ActionsComponent component, LocalPlayerAttachedEvent args)
{ {
LinkAllActions(component); LinkAllActions(component);
} }
private void OnPlayerDetached(EntityUid uid, ActionsComponent component, PlayerDetachedEvent? args = null) private void OnPlayerDetached(EntityUid uid, ActionsComponent component, LocalPlayerDetachedEvent? args = null)
{ {
UnlinkAllActions(); UnlinkAllActions();
} }

View File

@@ -4,7 +4,7 @@ using Robust.Client.Console;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.ContentPack; using Robust.Shared.ContentPack;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Players; using Robust.Shared.Player;
using Robust.Shared.Utility; using Robust.Shared.Utility;
namespace Content.Client.Administration.Managers namespace Content.Client.Administration.Managers

View File

@@ -5,7 +5,6 @@ using Robust.Client.Console;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Players;
namespace Content.Client.Administration.UI.Tabs.AdminTab namespace Content.Client.Administration.UI.Tabs.AdminTab
{ {

View File

@@ -1,7 +1,6 @@
using System.Linq; using System.Linq;
using Content.Shared.Alert; using Content.Shared.Alert;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -22,8 +21,8 @@ public sealed class ClientAlertsSystem : AlertsSystem
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<AlertsComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<AlertsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<AlertsComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<AlertsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<AlertsComponent, AfterAutoHandleStateEvent>(ClientAlertsHandleState); SubscribeLocalEvent<AlertsComponent, AfterAutoHandleStateEvent>(ClientAlertsHandleState);
} }
@@ -69,7 +68,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
SyncAlerts?.Invoke(this, component.Alerts); SyncAlerts?.Invoke(this, component.Alerts);
} }
private void OnPlayerAttached(EntityUid uid, AlertsComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, AlertsComponent component, LocalPlayerAttachedEvent args)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity != uid) if (_playerManager.LocalPlayer?.ControlledEntity != uid)
return; return;
@@ -87,7 +86,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
ClearAlerts?.Invoke(this, EventArgs.Empty); ClearAlerts?.Invoke(this, EventArgs.Empty);
} }
private void OnPlayerDetached(EntityUid uid, AlertsComponent component, PlayerDetachedEvent args) private void OnPlayerDetached(EntityUid uid, AlertsComponent component, LocalPlayerDetachedEvent args)
{ {
ClearAlerts?.Invoke(this, EventArgs.Empty); ClearAlerts?.Invoke(this, EventArgs.Empty);
} }

View File

@@ -1,6 +1,5 @@
using Content.Shared.CharacterInfo; using Content.Shared.CharacterInfo;
using Content.Shared.Objectives; using Content.Shared.Objectives;
using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -11,14 +10,11 @@ public sealed class CharacterInfoSystem : EntitySystem
[Dependency] private readonly IPlayerManager _players = default!; [Dependency] private readonly IPlayerManager _players = default!;
public event Action<CharacterData>? OnCharacterUpdate; public event Action<CharacterData>? OnCharacterUpdate;
public event Action? OnCharacterDetached;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<PlayerAttachSysMessage>(OnPlayerAttached);
SubscribeNetworkEvent<CharacterInfoEvent>(OnCharacterInfoEvent); SubscribeNetworkEvent<CharacterInfoEvent>(OnCharacterInfoEvent);
} }
@@ -33,14 +29,6 @@ public sealed class CharacterInfoSystem : EntitySystem
RaiseNetworkEvent(new RequestCharacterInfoEvent(GetNetEntity(entity.Value))); RaiseNetworkEvent(new RequestCharacterInfoEvent(GetNetEntity(entity.Value)));
} }
private void OnPlayerAttached(PlayerAttachSysMessage msg)
{
if (msg.AttachedEntity == default)
{
OnCharacterDetached?.Invoke();
}
}
private void OnCharacterInfoEvent(CharacterInfoEvent msg, EntitySessionEventArgs args) private void OnCharacterInfoEvent(CharacterInfoEvent msg, EntitySessionEventArgs args)
{ {
var entity = GetEntity(msg.NetEntity); var entity = GetEntity(msg.NetEntity);

View File

@@ -38,7 +38,7 @@ namespace Content.Client.Construction
base.Initialize(); base.Initialize();
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
SubscribeLocalEvent<PlayerAttachSysMessage>(HandlePlayerAttached); SubscribeLocalEvent<LocalPlayerAttachedEvent>(HandlePlayerAttached);
SubscribeNetworkEvent<AckStructureConstructionMessage>(HandleAckStructure); SubscribeNetworkEvent<AckStructureConstructionMessage>(HandleAckStructure);
SubscribeNetworkEvent<ResponseConstructionGuide>(OnConstructionGuideReceived); SubscribeNetworkEvent<ResponseConstructionGuide>(OnConstructionGuideReceived);
@@ -110,9 +110,9 @@ namespace Content.Client.Construction
ClearGhost(msg.GhostId); ClearGhost(msg.GhostId);
} }
private void HandlePlayerAttached(PlayerAttachSysMessage msg) private void HandlePlayerAttached(LocalPlayerAttachedEvent msg)
{ {
var available = IsCraftingAvailable(msg.AttachedEntity); var available = IsCraftingAvailable(msg.Entity);
UpdateCraftingAvailability(available); UpdateCraftingAvailability(available);
} }

View File

@@ -1,5 +1,4 @@
using Content.Shared.Drugs; using Content.Shared.Drugs;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
@@ -24,18 +23,18 @@ public sealed class DrugOverlaySystem : EntitySystem
SubscribeLocalEvent<SeeingRainbowsComponent, ComponentInit>(OnInit); SubscribeLocalEvent<SeeingRainbowsComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<SeeingRainbowsComponent, ComponentShutdown>(OnShutdown); SubscribeLocalEvent<SeeingRainbowsComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<SeeingRainbowsComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<SeeingRainbowsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<SeeingRainbowsComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<SeeingRainbowsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
_overlay = new(); _overlay = new();
} }
private void OnPlayerAttached(EntityUid uid, SeeingRainbowsComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, SeeingRainbowsComponent component, LocalPlayerAttachedEvent args)
{ {
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnPlayerDetached(EntityUid uid, SeeingRainbowsComponent component, PlayerDetachedEvent args) private void OnPlayerDetached(EntityUid uid, SeeingRainbowsComponent component, LocalPlayerDetachedEvent args)
{ {
_overlay.Intoxication = 0; _overlay.Intoxication = 0;
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);

View File

@@ -1,5 +1,4 @@
using Content.Shared.Drunk; using Content.Shared.Drunk;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
@@ -19,18 +18,18 @@ public sealed class DrunkSystem : SharedDrunkSystem
SubscribeLocalEvent<DrunkComponent, ComponentInit>(OnDrunkInit); SubscribeLocalEvent<DrunkComponent, ComponentInit>(OnDrunkInit);
SubscribeLocalEvent<DrunkComponent, ComponentShutdown>(OnDrunkShutdown); SubscribeLocalEvent<DrunkComponent, ComponentShutdown>(OnDrunkShutdown);
SubscribeLocalEvent<DrunkComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<DrunkComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<DrunkComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<DrunkComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
_overlay = new(); _overlay = new();
} }
private void OnPlayerAttached(EntityUid uid, DrunkComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, DrunkComponent component, LocalPlayerAttachedEvent args)
{ {
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnPlayerDetached(EntityUid uid, DrunkComponent component, PlayerDetachedEvent args) private void OnPlayerDetached(EntityUid uid, DrunkComponent component, LocalPlayerDetachedEvent args)
{ {
_overlay.CurrentBoozePower = 0; _overlay.CurrentBoozePower = 0;
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);

View File

@@ -1,17 +1,7 @@
using Content.Shared.Eye.Blinding;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Administration;
using Content.Shared.Administration.Events;
using Content.Shared.Eye.Blinding.Components; using Content.Shared.Eye.Blinding.Components;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Robust.Shared.GameObjects;
using Robust.Shared.Network;
namespace Content.Client.Eye.Blinding; namespace Content.Client.Eye.Blinding;
@@ -31,20 +21,20 @@ public sealed class BlindingSystem : EntitySystem
SubscribeLocalEvent<BlindableComponent, ComponentInit>(OnBlindInit); SubscribeLocalEvent<BlindableComponent, ComponentInit>(OnBlindInit);
SubscribeLocalEvent<BlindableComponent, ComponentShutdown>(OnBlindShutdown); SubscribeLocalEvent<BlindableComponent, ComponentShutdown>(OnBlindShutdown);
SubscribeLocalEvent<BlindableComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<BlindableComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<BlindableComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<BlindableComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup); SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
_overlay = new(); _overlay = new();
} }
private void OnPlayerAttached(EntityUid uid, BlindableComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, BlindableComponent component, LocalPlayerAttachedEvent args)
{ {
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnPlayerDetached(EntityUid uid, BlindableComponent component, PlayerDetachedEvent args) private void OnPlayerDetached(EntityUid uid, BlindableComponent component, LocalPlayerDetachedEvent args)
{ {
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);
_lightManager.Enabled = true; _lightManager.Enabled = true;

View File

@@ -1,9 +1,6 @@
using Content.Shared.Eye.Blinding;
using Content.Shared.Eye.Blinding.Components; using Content.Shared.Eye.Blinding.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.GameStates;
namespace Content.Client.Eye.Blinding; namespace Content.Client.Eye.Blinding;
@@ -20,18 +17,18 @@ public sealed class BlurryVisionSystem : EntitySystem
SubscribeLocalEvent<BlurryVisionComponent, ComponentInit>(OnBlurryInit); SubscribeLocalEvent<BlurryVisionComponent, ComponentInit>(OnBlurryInit);
SubscribeLocalEvent<BlurryVisionComponent, ComponentShutdown>(OnBlurryShutdown); SubscribeLocalEvent<BlurryVisionComponent, ComponentShutdown>(OnBlurryShutdown);
SubscribeLocalEvent<BlurryVisionComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<BlurryVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<BlurryVisionComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<BlurryVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
_overlay = new(); _overlay = new();
} }
private void OnPlayerAttached(EntityUid uid, BlurryVisionComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, BlurryVisionComponent component, LocalPlayerAttachedEvent args)
{ {
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnPlayerDetached(EntityUid uid, BlurryVisionComponent component, PlayerDetachedEvent args) private void OnPlayerDetached(EntityUid uid, BlurryVisionComponent component, LocalPlayerDetachedEvent args)
{ {
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);
} }

View File

@@ -30,7 +30,7 @@ public sealed class EyeLerpingSystem : EntitySystem
SubscribeLocalEvent<EyeAttachedEvent>(OnAttached); SubscribeLocalEvent<EyeAttachedEvent>(OnAttached);
SubscribeLocalEvent<LerpingEyeComponent, EntParentChangedMessage>(HandleMapChange); SubscribeLocalEvent<LerpingEyeComponent, EntParentChangedMessage>(HandleMapChange);
SubscribeLocalEvent<LerpingEyeComponent, PlayerDetachedEvent>(OnDetached); SubscribeLocalEvent<LerpingEyeComponent, LocalPlayerDetachedEvent>(OnDetached);
UpdatesAfter.Add(typeof(TransformSystem)); UpdatesAfter.Add(typeof(TransformSystem));
UpdatesAfter.Add(typeof(PhysicsSystem)); UpdatesAfter.Add(typeof(PhysicsSystem));
@@ -94,7 +94,7 @@ public sealed class EyeLerpingSystem : EntitySystem
AddEye(ev.Entity, ev.Component, true); AddEye(ev.Entity, ev.Component, true);
} }
private void OnDetached(EntityUid uid, LerpingEyeComponent component, PlayerDetachedEvent args) private void OnDetached(EntityUid uid, LerpingEyeComponent component, LocalPlayerDetachedEvent args)
{ {
if (!component.ManuallyAdded) if (!component.ManuallyAdded)
RemCompDeferred(uid, component); RemCompDeferred(uid, component);

View File

@@ -4,7 +4,7 @@ using Robust.Client.Input;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared; using Robust.Shared;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Players; using Robust.Shared.Player;
namespace Content.Client.Fullscreen; namespace Content.Client.Fullscreen;
public sealed class FullscreenHook public sealed class FullscreenHook

View File

@@ -16,7 +16,7 @@ using Robust.Shared.Console;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Players; using Robust.Shared.Player;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Client.Gameplay namespace Content.Client.Gameplay

View File

@@ -58,10 +58,10 @@ namespace Content.Client.Ghost
SubscribeLocalEvent<GhostComponent, ComponentRemove>(OnGhostRemove); SubscribeLocalEvent<GhostComponent, ComponentRemove>(OnGhostRemove);
SubscribeLocalEvent<GhostComponent, AfterAutoHandleStateEvent>(OnGhostState); SubscribeLocalEvent<GhostComponent, AfterAutoHandleStateEvent>(OnGhostState);
SubscribeLocalEvent<GhostComponent, PlayerAttachedEvent>(OnGhostPlayerAttach); SubscribeLocalEvent<GhostComponent, LocalPlayerAttachedEvent>(OnGhostPlayerAttach);
SubscribeLocalEvent<GhostComponent, PlayerDetachedEvent>(OnGhostPlayerDetach); SubscribeLocalEvent<GhostComponent, LocalPlayerDetachedEvent>(OnGhostPlayerDetach);
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttach); SubscribeLocalEvent<LocalPlayerAttachedEvent>(OnPlayerAttach);
SubscribeNetworkEvent<GhostWarpsResponseEvent>(OnGhostWarpsResponse); SubscribeNetworkEvent<GhostWarpsResponseEvent>(OnGhostWarpsResponse);
SubscribeNetworkEvent<GhostUpdateGhostRoleCountEvent>(OnUpdateGhostRoleCount); SubscribeNetworkEvent<GhostUpdateGhostRoleCountEvent>(OnUpdateGhostRoleCount);
@@ -130,7 +130,7 @@ namespace Content.Client.Ghost
PlayerRemoved?.Invoke(component); PlayerRemoved?.Invoke(component);
} }
private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, PlayerAttachedEvent playerAttachedEvent) private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, LocalPlayerAttachedEvent localPlayerAttachedEvent)
{ {
if (uid != _playerManager.LocalPlayer?.ControlledEntity) if (uid != _playerManager.LocalPlayer?.ControlledEntity)
return; return;
@@ -161,13 +161,13 @@ namespace Content.Client.Ghost
return true; return true;
} }
private void OnGhostPlayerDetach(EntityUid uid, GhostComponent component, PlayerDetachedEvent args) private void OnGhostPlayerDetach(EntityUid uid, GhostComponent component, LocalPlayerDetachedEvent args)
{ {
if (PlayerDetach(uid)) if (PlayerDetach(uid))
component.IsAttached = false; component.IsAttached = false;
} }
private void OnPlayerAttach(PlayerAttachedEvent ev) private void OnPlayerAttach(LocalPlayerAttachedEvent ev)
{ {
if (!HasComp<GhostComponent>(ev.Entity)) if (!HasComp<GhostComponent>(ev.Entity))
PlayerDetach(ev.Entity); PlayerDetach(ev.Entity);

View File

@@ -42,8 +42,8 @@ namespace Content.Client.Hands.Systems
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<HandsComponent, PlayerAttachedEvent>(HandlePlayerAttached); SubscribeLocalEvent<HandsComponent, LocalPlayerAttachedEvent>(HandlePlayerAttached);
SubscribeLocalEvent<HandsComponent, PlayerDetachedEvent>(HandlePlayerDetached); SubscribeLocalEvent<HandsComponent, LocalPlayerDetachedEvent>(HandlePlayerDetached);
SubscribeLocalEvent<HandsComponent, ComponentStartup>(OnHandsStartup); SubscribeLocalEvent<HandsComponent, ComponentStartup>(OnHandsStartup);
SubscribeLocalEvent<HandsComponent, ComponentShutdown>(OnHandsShutdown); SubscribeLocalEvent<HandsComponent, ComponentShutdown>(OnHandsShutdown);
SubscribeLocalEvent<HandsComponent, ComponentHandleState>(HandleComponentState); SubscribeLocalEvent<HandsComponent, ComponentHandleState>(HandleComponentState);
@@ -361,12 +361,12 @@ namespace Content.Client.Hands.Systems
#region Gui #region Gui
private void HandlePlayerAttached(EntityUid uid, HandsComponent component, PlayerAttachedEvent args) private void HandlePlayerAttached(EntityUid uid, HandsComponent component, LocalPlayerAttachedEvent args)
{ {
OnPlayerHandsAdded?.Invoke(component); OnPlayerHandsAdded?.Invoke(component);
} }
private void HandlePlayerDetached(EntityUid uid, HandsComponent component, PlayerDetachedEvent args) private void HandlePlayerDetached(EntityUid uid, HandsComponent component, LocalPlayerDetachedEvent args)
{ {
OnPlayerHandsRemoved?.Invoke(); OnPlayerHandsRemoved?.Invoke();
} }

View File

@@ -3,8 +3,8 @@ using Content.Shared.Damage;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player;
namespace Content.Client.HealthOverlay namespace Content.Client.HealthOverlay
{ {
@@ -13,9 +13,9 @@ namespace Content.Client.HealthOverlay
{ {
[Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IEntityManager _entities = default!; [Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IPlayerManager _player = default!;
private readonly Dictionary<EntityUid, HealthOverlayGui> _guis = new(); private readonly Dictionary<EntityUid, HealthOverlayGui> _guis = new();
private EntityUid? _attachedEntity;
private bool _enabled; private bool _enabled;
public bool Enabled public bool Enabled
@@ -42,7 +42,6 @@ namespace Content.Client.HealthOverlay
base.Initialize(); base.Initialize();
SubscribeNetworkEvent<RoundRestartCleanupEvent>(Reset); SubscribeNetworkEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<PlayerAttachSysMessage>(HandlePlayerAttached);
} }
public void Reset(RoundRestartCleanupEvent ev) public void Reset(RoundRestartCleanupEvent ev)
@@ -53,12 +52,6 @@ namespace Content.Client.HealthOverlay
} }
_guis.Clear(); _guis.Clear();
_attachedEntity = default;
}
private void HandlePlayerAttached(PlayerAttachSysMessage message)
{
_attachedEntity = message.AttachedEntity;
} }
public override void FrameUpdate(float frameTime) public override void FrameUpdate(float frameTime)
@@ -70,7 +63,7 @@ namespace Content.Client.HealthOverlay
return; return;
} }
if (_attachedEntity is not {} ent || Deleted(ent)) if (_player.LocalEntity is not {} ent || Deleted(ent))
{ {
return; return;
} }

View File

@@ -10,7 +10,6 @@ using Content.Shared.Inventory;
using Content.Shared.Inventory.Events; using Content.Shared.Inventory.Events;
using Content.Shared.Storage; using Content.Shared.Storage;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -43,8 +42,8 @@ namespace Content.Client.Inventory
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
base.Initialize(); base.Initialize();
SubscribeLocalEvent<InventorySlotsComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InventorySlotsComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<InventoryComponent, ComponentShutdown>(OnShutdown); SubscribeLocalEvent<InventoryComponent, ComponentShutdown>(OnShutdown);
@@ -113,12 +112,12 @@ namespace Content.Client.Inventory
OnUnlinkInventory?.Invoke(); OnUnlinkInventory?.Invoke();
} }
private void OnPlayerDetached(EntityUid uid, InventorySlotsComponent component, PlayerDetachedEvent args) private void OnPlayerDetached(EntityUid uid, InventorySlotsComponent component, LocalPlayerDetachedEvent args)
{ {
OnUnlinkInventory?.Invoke(); OnUnlinkInventory?.Invoke();
} }
private void OnPlayerAttached(EntityUid uid, InventorySlotsComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, InventorySlotsComponent component, LocalPlayerAttachedEvent args)
{ {
if (TryGetSlots(uid, out var definitions)) if (TryGetSlots(uid, out var definitions))
{ {

View File

@@ -1,7 +1,6 @@
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Inventory.Events; using Content.Shared.Inventory.Events;
using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
namespace Content.Client.Overlays; namespace Content.Client.Overlays;
@@ -24,8 +23,8 @@ public abstract class EquipmentHudSystem<T> : EntitySystem where T : IComponent
SubscribeLocalEvent<T, ComponentStartup>(OnStartup); SubscribeLocalEvent<T, ComponentStartup>(OnStartup);
SubscribeLocalEvent<T, ComponentRemove>(OnRemove); SubscribeLocalEvent<T, ComponentRemove>(OnRemove);
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<T, GotEquippedEvent>(OnCompEquip); SubscribeLocalEvent<T, GotEquippedEvent>(OnCompEquip);
SubscribeLocalEvent<T, GotUnequippedEvent>(OnCompUnequip); SubscribeLocalEvent<T, GotUnequippedEvent>(OnCompUnequip);
@@ -65,12 +64,12 @@ public abstract class EquipmentHudSystem<T> : EntitySystem where T : IComponent
RefreshOverlay(uid); RefreshOverlay(uid);
} }
private void OnPlayerAttached(PlayerAttachedEvent args) private void OnPlayerAttached(LocalPlayerAttachedEvent args)
{ {
RefreshOverlay(args.Entity); RefreshOverlay(args.Entity);
} }
private void OnPlayerDetached(PlayerDetachedEvent args) private void OnPlayerDetached(LocalPlayerDetachedEvent args)
{ {
if (_player.LocalPlayer?.ControlledEntity == null) if (_player.LocalPlayer?.ControlledEntity == null)
Deactivate(); Deactivate();

View File

@@ -1,7 +1,6 @@
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Robust.Client.GameObjects;
using Robust.Client.Physics; using Robust.Client.Physics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
@@ -17,10 +16,10 @@ namespace Content.Client.Physics.Controllers
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<RelayInputMoverComponent, PlayerAttachedEvent>(OnRelayPlayerAttached); SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerAttachedEvent>(OnRelayPlayerAttached);
SubscribeLocalEvent<RelayInputMoverComponent, PlayerDetachedEvent>(OnRelayPlayerDetached); SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerDetachedEvent>(OnRelayPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, PlayerAttachedEvent>(OnPlayerAttached); SubscribeLocalEvent<InputMoverComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InputMoverComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<InputMoverComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, UpdateIsPredictedEvent>(OnUpdatePredicted); SubscribeLocalEvent<InputMoverComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
SubscribeLocalEvent<MovementRelayTargetComponent, UpdateIsPredictedEvent>(OnUpdateRelayTargetPredicted); SubscribeLocalEvent<MovementRelayTargetComponent, UpdateIsPredictedEvent>(OnUpdateRelayTargetPredicted);
@@ -54,7 +53,7 @@ namespace Content.Client.Physics.Controllers
// What if the entity is being pulled by a vehicle controlled by the player? // What if the entity is being pulled by a vehicle controlled by the player?
} }
private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, PlayerAttachedEvent args) private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, LocalPlayerAttachedEvent args)
{ {
Physics.UpdateIsPredicted(uid); Physics.UpdateIsPredicted(uid);
Physics.UpdateIsPredicted(component.RelayEntity); Physics.UpdateIsPredicted(component.RelayEntity);
@@ -62,7 +61,7 @@ namespace Content.Client.Physics.Controllers
SetMoveInput(inputMover, MoveButtons.None); SetMoveInput(inputMover, MoveButtons.None);
} }
private void OnRelayPlayerDetached(EntityUid uid, RelayInputMoverComponent component, PlayerDetachedEvent args) private void OnRelayPlayerDetached(EntityUid uid, RelayInputMoverComponent component, LocalPlayerDetachedEvent args)
{ {
Physics.UpdateIsPredicted(uid); Physics.UpdateIsPredicted(uid);
Physics.UpdateIsPredicted(component.RelayEntity); Physics.UpdateIsPredicted(component.RelayEntity);
@@ -70,12 +69,12 @@ namespace Content.Client.Physics.Controllers
SetMoveInput(inputMover, MoveButtons.None); SetMoveInput(inputMover, MoveButtons.None);
} }
private void OnPlayerAttached(EntityUid uid, InputMoverComponent component, PlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, InputMoverComponent component, LocalPlayerAttachedEvent args)
{ {
SetMoveInput(component, MoveButtons.None); SetMoveInput(component, MoveButtons.None);
} }
private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, PlayerDetachedEvent args) private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, LocalPlayerDetachedEvent args)
{ {
SetMoveInput(component, MoveButtons.None); SetMoveInput(component, MoveButtons.None);
} }

View File

@@ -1,11 +1,11 @@
using Content.Shared.Players; using Content.Shared.Players;
using Robust.Shared.Players; using Robust.Shared.Player;
namespace Content.Client.Players; namespace Content.Client.Players;
public sealed class PlayerSystem : SharedPlayerSystem public sealed class PlayerSystem : SharedPlayerSystem
{ {
public override PlayerData? ContentData(ICommonSession? session) public override ContentPlayerData? ContentData(ICommonSession? session)
{ {
return null; return null;
} }

View File

@@ -9,7 +9,6 @@ using Robust.Client.UserInterface;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Replays; using Robust.Shared.Replays;
using Robust.Shared.Timing; using Robust.Shared.Timing;

View File

@@ -2,7 +2,7 @@ using Content.Shared.Movement.Components;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Players; using Robust.Shared.Player;
namespace Content.Client.Replay.Spectator; namespace Content.Client.Replay.Spectator;

View File

@@ -1,5 +1,5 @@
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Robust.Client.GameObjects; using Robust.Client.Player;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -79,7 +79,7 @@ public sealed partial class ReplaySpectatorSystem
public void SetSpectatorPosition(SpectatorData data) public void SetSpectatorPosition(SpectatorData data)
{ {
if (_player.LocalPlayer == null) if (_player.LocalSession == null)
return; return;
if (data.Controller != null if (data.Controller != null
@@ -87,13 +87,13 @@ public sealed partial class ReplaySpectatorSystem
&& Exists(session.AttachedEntity) && Exists(session.AttachedEntity)
&& Transform(session.AttachedEntity.Value).MapID != MapId.Nullspace) && Transform(session.AttachedEntity.Value).MapID != MapId.Nullspace)
{ {
_player.LocalPlayer.AttachEntity(session.AttachedEntity.Value, EntityManager, _client); _player.SetAttachedEntity(_player.LocalSession, session.AttachedEntity);
return; return;
} }
if (Exists(data.Entity) && Transform(data.Entity).MapID != MapId.Nullspace) if (Exists(data.Entity) && Transform(data.Entity).MapID != MapId.Nullspace)
{ {
_player.LocalPlayer.AttachEntity(data.Entity, EntityManager, _client); _player.SetAttachedEntity(_player.LocalSession, data.Entity);
return; return;
} }
@@ -118,7 +118,7 @@ public sealed partial class ReplaySpectatorSystem
return; return;
} }
if (data.Eye != null && TryComp(_player.LocalPlayer.ControlledEntity, out InputMoverComponent? newMover)) if (data.Eye != null && TryComp(_player.LocalSession.AttachedEntity, out InputMoverComponent? newMover))
{ {
newMover.RelativeEntity = data.Eye.Value.Ent; newMover.RelativeEntity = data.Eye.Value.Ent;
newMover.TargetRelativeRotation = newMover.RelativeRotation = data.Eye.Value.Rot; newMover.TargetRelativeRotation = newMover.RelativeRotation = data.Eye.Value.Rot;
@@ -177,7 +177,7 @@ public sealed partial class ReplaySpectatorSystem
SetSpectatorPosition(default); SetSpectatorPosition(default);
} }
private void OnDetached(EntityUid uid, ReplaySpectatorComponent component, PlayerDetachedEvent args) private void OnDetached(EntityUid uid, ReplaySpectatorComponent component, LocalPlayerDetachedEvent args)
{ {
if (IsClientSide(uid)) if (IsClientSide(uid))
QueueDel(uid); QueueDel(uid);

View File

@@ -32,10 +32,10 @@ public sealed partial class ReplaySpectatorSystem
public void SpectateEntity(EntityUid target) public void SpectateEntity(EntityUid target)
{ {
if (_player.LocalPlayer == null) if (_player.LocalSession == null)
return; return;
var old = _player.LocalPlayer.ControlledEntity; var old = _player.LocalSession.AttachedEntity;
if (old == target) if (old == target)
{ {
@@ -44,7 +44,7 @@ public sealed partial class ReplaySpectatorSystem
return; return;
} }
_player.LocalPlayer.AttachEntity(target, EntityManager, _client); _player.SetAttachedEntity(_player.LocalSession, target);
EnsureComp<ReplaySpectatorComponent>(target); EnsureComp<ReplaySpectatorComponent>(target);
_stateMan.RequestStateChange<ReplaySpectateEntityState>(); _stateMan.RequestStateChange<ReplaySpectateEntityState>();
@@ -59,10 +59,10 @@ public sealed partial class ReplaySpectatorSystem
public TransformComponent SpawnSpectatorGhost(EntityCoordinates coords, bool gridAttach) public TransformComponent SpawnSpectatorGhost(EntityCoordinates coords, bool gridAttach)
{ {
if (_player.LocalPlayer == null) if (_player.LocalSession == null)
throw new InvalidOperationException(); throw new InvalidOperationException();
var old = _player.LocalPlayer.ControlledEntity; var old = _player.LocalSession.AttachedEntity;
var ent = Spawn("ReplayObserver", coords); var ent = Spawn("ReplayObserver", coords);
_eye.SetMaxZoom(ent, Vector2.One * 5); _eye.SetMaxZoom(ent, Vector2.One * 5);
@@ -73,7 +73,7 @@ public sealed partial class ReplaySpectatorSystem
if (gridAttach) if (gridAttach)
_transform.AttachToGridOrMap(ent); _transform.AttachToGridOrMap(ent);
_player.LocalPlayer.AttachEntity(ent, EntityManager, _client); _player.SetAttachedEntity(_player.LocalSession, ent);
if (old != null) if (old != null)
{ {
@@ -93,7 +93,7 @@ public sealed partial class ReplaySpectatorSystem
{ {
if (args.Length == 0) if (args.Length == 0)
{ {
if (_player.LocalPlayer?.ControlledEntity is { } current) if (_player.LocalSession?.AttachedEntity is { } current)
SpawnSpectatorGhost(new EntityCoordinates(current, default), true); SpawnSpectatorGhost(new EntityCoordinates(current, default), true);
else else
SpawnSpectatorGhost(default, true); SpawnSpectatorGhost(default, true);

View File

@@ -6,7 +6,6 @@ using Robust.Client.Player;
using Robust.Client.Replays.Playback; using Robust.Client.Replays.Playback;
using Robust.Client.State; using Robust.Client.State;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Network;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
namespace Content.Client.Replay.Spectator; namespace Content.Client.Replay.Spectator;
@@ -40,7 +39,7 @@ public sealed partial class ReplaySpectatorSystem : EntitySystem
SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerbs); SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerbs);
SubscribeLocalEvent<ReplaySpectatorComponent, EntityTerminatingEvent>(OnTerminating); SubscribeLocalEvent<ReplaySpectatorComponent, EntityTerminatingEvent>(OnTerminating);
SubscribeLocalEvent<ReplaySpectatorComponent, PlayerDetachedEvent>(OnDetached); SubscribeLocalEvent<ReplaySpectatorComponent, LocalPlayerDetachedEvent>(OnDetached);
SubscribeLocalEvent<ReplaySpectatorComponent, EntParentChangedMessage>(OnParentChanged); SubscribeLocalEvent<ReplaySpectatorComponent, EntParentChangedMessage>(OnParentChanged);
InitializeBlockers(); InitializeBlockers();

View File

@@ -5,7 +5,7 @@ using Robust.Client.Console;
using Robust.Client.Placement; using Robust.Client.Placement;
using Robust.Client.Placement.Modes; using Robust.Client.Placement.Modes;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Players; using Robust.Shared.Player;
namespace Content.Client.Sandbox namespace Content.Client.Sandbox
{ {

View File

@@ -1,8 +1,6 @@
using System.Numerics; using System.Numerics;
using Content.Shared.Traits.Assorted; using Content.Shared.Traits.Assorted;
using Content.Client.Camera;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -19,7 +17,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<ParacusiaComponent, ComponentStartup>(OnComponentStartup); SubscribeLocalEvent<ParacusiaComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<ParacusiaComponent, PlayerDetachedEvent>(OnPlayerDetach); SubscribeLocalEvent<ParacusiaComponent, LocalPlayerDetachedEvent>(OnPlayerDetach);
} }
public override void Update(float frameTime) public override void Update(float frameTime)
@@ -40,7 +38,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem
component.NextIncidentTime = _timing.CurTime + TimeSpan.FromSeconds(_random.NextFloat(component.MinTimeBetweenIncidents, component.MaxTimeBetweenIncidents)); component.NextIncidentTime = _timing.CurTime + TimeSpan.FromSeconds(_random.NextFloat(component.MinTimeBetweenIncidents, component.MaxTimeBetweenIncidents));
} }
private void OnPlayerDetach(EntityUid uid, ParacusiaComponent component, PlayerDetachedEvent args) private void OnPlayerDetach(EntityUid uid, ParacusiaComponent component, LocalPlayerDetachedEvent args)
{ {
component.Stream?.Stop(); component.Stream?.Stop();
} }

View File

@@ -8,6 +8,7 @@ using Content.Client.UserInterface.Systems.Objectives.Controls;
using Content.Shared.Input; using Content.Shared.Input;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers; using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
@@ -21,6 +22,7 @@ namespace Content.Client.UserInterface.Systems.Character;
[UsedImplicitly] [UsedImplicitly]
public sealed class CharacterUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CharacterInfoSystem> public sealed class CharacterUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CharacterInfoSystem>
{ {
[Dependency] private readonly IPlayerManager _player = default!;
[UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!; [UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!;
[UISystemDependency] private readonly SpriteSystem _sprite = default!; [UISystemDependency] private readonly SpriteSystem _sprite = default!;
@@ -56,13 +58,13 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
public void OnSystemLoaded(CharacterInfoSystem system) public void OnSystemLoaded(CharacterInfoSystem system)
{ {
system.OnCharacterUpdate += CharacterUpdated; system.OnCharacterUpdate += CharacterUpdated;
system.OnCharacterDetached += CharacterDetached; _player.LocalPlayerDetached += CharacterDetached;
} }
public void OnSystemUnloaded(CharacterInfoSystem system) public void OnSystemUnloaded(CharacterInfoSystem system)
{ {
system.OnCharacterUpdate -= CharacterUpdated; system.OnCharacterUpdate -= CharacterUpdated;
system.OnCharacterDetached -= CharacterDetached; _player.LocalPlayerDetached -= CharacterDetached;
} }
public void UnloadButton() public void UnloadButton()
@@ -160,7 +162,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
_window.RolePlaceholder.Visible = briefing == null && !controls.Any() && !objectives.Any(); _window.RolePlaceholder.Visible = briefing == null && !controls.Any() && !objectives.Any();
} }
private void CharacterDetached() private void CharacterDetached(EntityUid uid)
{ {
CloseWindow(); CloseWindow();
} }

View File

@@ -162,7 +162,8 @@ public sealed class ChatUIController : UIController
_sawmill = Logger.GetSawmill("chat"); _sawmill = Logger.GetSawmill("chat");
_sawmill.Level = LogLevel.Info; _sawmill.Level = LogLevel.Info;
_admin.AdminStatusUpdated += UpdateChannelPermissions; _admin.AdminStatusUpdated += UpdateChannelPermissions;
_player.LocalPlayerChanged += OnLocalPlayerChanged; _player.LocalPlayerAttached += OnAttachedChanged;
_player.LocalPlayerDetached += OnAttachedChanged;
_state.OnStateChanged += StateChanged; _state.OnStateChanged += StateChanged;
_net.RegisterNetMessage<MsgChatMessage>(OnChatMessage); _net.RegisterNetMessage<MsgChatMessage>(OnChatMessage);
_net.RegisterNetMessage<MsgDeleteChatMessagesBy>(OnDeleteChatMessagesBy); _net.RegisterNetMessage<MsgDeleteChatMessagesBy>(OnDeleteChatMessagesBy);
@@ -170,7 +171,7 @@ public sealed class ChatUIController : UIController
_speechBubbleRoot = new LayoutContainer(); _speechBubbleRoot = new LayoutContainer();
OnLocalPlayerChanged(new LocalPlayerChangedEventArgs(null, _player.LocalPlayer)); UpdateChannelPermissions();
_input.SetInputCommand(ContentKeyFunctions.FocusChat, _input.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(_ => FocusChat())); InputCmdHandler.FromDelegate(_ => FocusChat()));
@@ -363,29 +364,7 @@ public sealed class ChatUIController : UIController
_speechBubbleRoot.SetPositionLast(); _speechBubbleRoot.SetPositionLast();
} }
private void OnLocalPlayerChanged(LocalPlayerChangedEventArgs obj) private void OnAttachedChanged(EntityUid uid)
{
if (obj.OldPlayer != null)
{
obj.OldPlayer.EntityAttached -= OnLocalPlayerEntityAttached;
obj.OldPlayer.EntityDetached -= OnLocalPlayerEntityDetached;
}
if (obj.NewPlayer != null)
{
obj.NewPlayer.EntityAttached += OnLocalPlayerEntityAttached;
obj.NewPlayer.EntityDetached += OnLocalPlayerEntityDetached;
}
UpdateChannelPermissions();
}
private void OnLocalPlayerEntityAttached(EntityAttachedEventArgs obj)
{
UpdateChannelPermissions();
}
private void OnLocalPlayerEntityDetached(EntityDetachedEventArgs obj)
{ {
UpdateChannelPermissions(); UpdateChannelPermissions();
} }

View File

@@ -1,11 +1,9 @@
using Content.Client.Alerts;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Mobs; using Content.Shared.Mobs;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -25,13 +23,13 @@ public sealed class DamageOverlayUiController : UIController
public override void Initialize() public override void Initialize()
{ {
_overlay = new Overlays.DamageOverlay(); _overlay = new Overlays.DamageOverlay();
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttach); SubscribeLocalEvent<LocalPlayerAttachedEvent>(OnPlayerAttach);
SubscribeLocalEvent<PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<MobStateChangedEvent>(OnMobStateChanged); SubscribeLocalEvent<MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<MobThresholdChecked>(OnThresholdCheck); SubscribeLocalEvent<MobThresholdChecked>(OnThresholdCheck);
} }
private void OnPlayerAttach(PlayerAttachedEvent args) private void OnPlayerAttach(LocalPlayerAttachedEvent args)
{ {
ClearOverlay(); ClearOverlay();
if (!EntityManager.TryGetComponent<MobStateComponent>(args.Entity, out var mobState)) if (!EntityManager.TryGetComponent<MobStateComponent>(args.Entity, out var mobState))
@@ -41,7 +39,7 @@ public sealed class DamageOverlayUiController : UIController
_overlayManager.AddOverlay(_overlay); _overlayManager.AddOverlay(_overlay);
} }
private void OnPlayerDetached(PlayerDetachedEvent args) private void OnPlayerDetached(LocalPlayerDetachedEvent args)
{ {
_overlayManager.RemoveOverlay(_overlay); _overlayManager.RemoveOverlay(_overlay);
ClearOverlay(); ClearOverlay();

View File

@@ -17,7 +17,7 @@ using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controllers.Implementations; using Robust.Client.UserInterface.Controllers.Implementations;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Players; using Robust.Shared.Player;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BaseButton; using static Robust.Client.UserInterface.Controls.BaseButton;

View File

@@ -16,7 +16,8 @@ using Robust.Client.State;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Players; using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Client.Weapons.Melee; namespace Content.Client.Weapons.Melee;

View File

@@ -3,13 +3,11 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Players;
using Content.Shared.Mind;
using Content.Shared.Players; using Content.Shared.Players;
using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.UnitTesting; using Robust.UnitTesting;
@@ -30,8 +28,8 @@ public sealed partial class TestPair
public RobustIntegrationTest.ServerIntegrationInstance Server { get; private set; } = default!; public RobustIntegrationTest.ServerIntegrationInstance Server { get; private set; } = default!;
public RobustIntegrationTest.ClientIntegrationInstance Client { get; private set; } = default!; public RobustIntegrationTest.ClientIntegrationInstance Client { get; private set; } = default!;
public IPlayerSession? Player => (IPlayerSession?) Server.PlayerMan.Sessions.FirstOrDefault(); public ICommonSession? Player => Server.PlayerMan.Sessions.FirstOrDefault();
public PlayerData? PlayerData => Player?.Data.ContentData(); public ContentPlayerData? PlayerData => Player?.Data.ContentData();
public PoolTestLogHandler ServerLogHandler { get; private set; } = default!; public PoolTestLogHandler ServerLogHandler { get; private set; } = default!;
public PoolTestLogHandler ClientLogHandler { get; private set; } = default!; public PoolTestLogHandler ClientLogHandler { get; private set; } = default!;

View File

@@ -3,8 +3,6 @@ using Content.Shared.Actions;
using Content.Shared.CombatMode; using Content.Shared.CombatMode;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using PlayerManager = Robust.Client.Player.PlayerManager;
namespace Content.IntegrationTests.Tests.Actions; namespace Content.IntegrationTests.Tests.Actions;
@@ -26,7 +24,7 @@ public sealed class ActionsAddedTest
var sEntMan = server.ResolveDependency<IEntityManager>(); var sEntMan = server.ResolveDependency<IEntityManager>();
var cEntMan = client.ResolveDependency<IEntityManager>(); var cEntMan = client.ResolveDependency<IEntityManager>();
var clientSession = client.ResolveDependency<Robust.Client.Player.IPlayerManager>().LocalPlayer?.Session; var clientSession = client.ResolveDependency<Robust.Client.Player.IPlayerManager>().LocalPlayer?.Session;
var serverSession = server.ResolveDependency<IPlayerManager>().ServerSessions.Single(); var serverSession = server.ResolveDependency<IPlayerManager>().Sessions.Single();
var sActionSystem = server.System<SharedActionsSystem>(); var sActionSystem = server.System<SharedActionsSystem>();
var cActionSystem = client.System<SharedActionsSystem>(); var cActionSystem = client.System<SharedActionsSystem>();

View File

@@ -7,8 +7,6 @@ using Content.Shared.Administration.Logs;
using Content.Shared.Database; using Content.Shared.Database;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Utility;
namespace Content.IntegrationTests.Tests.Administration.Logs; namespace Content.IntegrationTests.Tests.Administration.Logs;
@@ -177,7 +175,7 @@ public sealed class AddTests
await server.WaitPost(() => await server.WaitPost(() =>
{ {
var player = sPlayers.ServerSessions.First(); var player = sPlayers.Sessions.First();
playerGuid = player.UserId; playerGuid = player.UserId;
Assert.DoesNotThrow(() => Assert.DoesNotThrow(() =>
@@ -280,7 +278,7 @@ public sealed class AddTests
await server.WaitPost(() => await server.WaitPost(() =>
{ {
var player = sPlayers.ServerSessions.Single(); var player = sPlayers.Sessions.Single();
sAdminLogSystem.Add(LogType.Unknown, $"{player} {player} test log: {guid}"); sAdminLogSystem.Add(LogType.Unknown, $"{player} {player} test log: {guid}");
}); });
@@ -318,7 +316,7 @@ public sealed class AddTests
await server.WaitPost(() => await server.WaitPost(() =>
{ {
var player = sPlayers.ServerSessions.Single(); var player = sPlayers.Sessions.Single();
sAdminLogSystem.Add(LogType.Unknown, $"{player:first} {player:second} test log: {guid}"); sAdminLogSystem.Add(LogType.Unknown, $"{player:first} {player:second} test log: {guid}");
}); });

View File

@@ -5,6 +5,7 @@ using Content.Server.GameTicking;
using Content.Shared.Database; using Content.Shared.Database;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Player;
namespace Content.IntegrationTests.Tests.Administration.Logs; namespace Content.IntegrationTests.Tests.Administration.Logs;
@@ -27,11 +28,11 @@ public sealed class QueryTests
var date = DateTime.UtcNow; var date = DateTime.UtcNow;
var guid = Guid.NewGuid(); var guid = Guid.NewGuid();
IPlayerSession player = default; ICommonSession player = default;
await server.WaitPost(() => await server.WaitPost(() =>
{ {
player = sPlayers.ServerSessions.First(); player = sPlayers.Sessions.First();
sAdminLogSystem.Add(LogType.Unknown, $"{player.AttachedEntity:Entity} test log: {guid}"); sAdminLogSystem.Add(LogType.Unknown, $"{player.AttachedEntity:Entity} test log: {guid}");
}); });

View File

@@ -25,7 +25,7 @@ public sealed class EuiManagerTest
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var clientSession = sPlayerManager.ServerSessions.Single(); var clientSession = sPlayerManager.Sessions.Single();
var ui = new AdminAnnounceEui(); var ui = new AdminAnnounceEui();
eui.OpenEui(ui, clientSession); eui.OpenEui(ui, clientSession);
}); });

View File

@@ -14,6 +14,7 @@ using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems; using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Mind; using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Client.Input; using Robust.Client.Input;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -21,7 +22,7 @@ using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Players; using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.UnitTesting; using Robust.UnitTesting;
@@ -67,7 +68,7 @@ public abstract partial class InteractionTest
protected NetEntity Player; protected NetEntity Player;
protected ICommonSession ClientSession = default!; protected ICommonSession ClientSession = default!;
protected IPlayerSession ServerSession = default!; protected ICommonSession ServerSession = default!;
public EntityUid? ClientTarget; public EntityUid? ClientTarget;

View File

@@ -5,6 +5,7 @@ using Content.Server.Ghost.Roles.Components;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Mind; using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -43,7 +44,7 @@ public sealed class GhostRoleTests
var sPlayerMan = server.ResolveDependency<Robust.Server.Player.IPlayerManager>(); var sPlayerMan = server.ResolveDependency<Robust.Server.Player.IPlayerManager>();
var conHost = client.ResolveDependency<IConsoleHost>(); var conHost = client.ResolveDependency<IConsoleHost>();
var mindSystem = entMan.System<SharedMindSystem>(); var mindSystem = entMan.System<SharedMindSystem>();
var session = sPlayerMan.ServerSessions.Single(); var session = sPlayerMan.Sessions.Single();
var originalMindId = session.ContentData()!.Mind!.Value; var originalMindId = session.ContentData()!.Mind!.Value;
// Spawn player entity & attach // Spawn player entity & attach

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Mind; using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
@@ -35,7 +36,7 @@ public sealed partial class MindTests
MindComponent mind = default!; MindComponent mind = default!;
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
playerEnt = entMan.SpawnEntity(null, MapCoordinates.Nullspace); playerEnt = entMan.SpawnEntity(null, MapCoordinates.Nullspace);
visitEnt = entMan.SpawnEntity(null, MapCoordinates.Nullspace); visitEnt = entMan.SpawnEntity(null, MapCoordinates.Nullspace);
@@ -81,7 +82,7 @@ public sealed partial class MindTests
var entMan = server.ResolveDependency<IServerEntityManager>(); var entMan = server.ResolveDependency<IServerEntityManager>();
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
var playerMan = server.ResolveDependency<IPlayerManager>(); var playerMan = server.ResolveDependency<IPlayerManager>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
var mindSystem = entMan.EntitySysManager.GetEntitySystem<SharedMindSystem>(); var mindSystem = entMan.EntitySysManager.GetEntitySystem<SharedMindSystem>();
@@ -128,7 +129,7 @@ public sealed partial class MindTests
var entMan = server.ResolveDependency<IServerEntityManager>(); var entMan = server.ResolveDependency<IServerEntityManager>();
var playerMan = server.ResolveDependency<IPlayerManager>(); var playerMan = server.ResolveDependency<IPlayerManager>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
Assert.That(!entMan.HasComponent<GhostComponent>(player.AttachedEntity), "Player was initially a ghost?"); Assert.That(!entMan.HasComponent<GhostComponent>(player.AttachedEntity), "Player was initially a ghost?");
@@ -162,7 +163,7 @@ public sealed partial class MindTests
var mindSystem = entMan.EntitySysManager.GetEntitySystem<SharedMindSystem>(); var mindSystem = entMan.EntitySysManager.GetEntitySystem<SharedMindSystem>();
var mind = GetMind(pair); var mind = GetMind(pair);
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
#pragma warning disable NUnit2045 // Interdependent assertions. #pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(player.AttachedEntity, Is.Not.Null); Assert.That(player.AttachedEntity, Is.Not.Null);
Assert.That(entMan.EntityExists(player.AttachedEntity)); Assert.That(entMan.EntityExists(player.AttachedEntity));
@@ -218,7 +219,7 @@ public sealed partial class MindTests
var playerMan = server.ResolveDependency<IPlayerManager>(); var playerMan = server.ResolveDependency<IPlayerManager>();
var serverConsole = server.ResolveDependency<IServerConsoleHost>(); var serverConsole = server.ResolveDependency<IServerConsoleHost>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
var ghost = await BecomeGhost(pair); var ghost = await BecomeGhost(pair);
@@ -263,7 +264,7 @@ public sealed partial class MindTests
var playerMan = server.ResolveDependency<IPlayerManager>(); var playerMan = server.ResolveDependency<IPlayerManager>();
var serverConsole = server.ResolveDependency<IServerConsoleHost>(); var serverConsole = server.ResolveDependency<IServerConsoleHost>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
EntityUid ghost = default!; EntityUid ghost = default!;

View File

@@ -1,14 +1,17 @@
using System.Linq; using System.Linq;
using Content.IntegrationTests.Pair; using Content.IntegrationTests.Pair;
using Content.Server.Mind;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Mind; using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player;
namespace Content.IntegrationTests.Tests.Minds; namespace Content.IntegrationTests.Tests.Minds;
@@ -36,7 +39,7 @@ public sealed partial class MindTests
var playerMan = pair.Server.ResolveDependency<IPlayerManager>(); var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var mindSys = entMan.System<SharedMindSystem>(); var mindSys = entMan.System<SharedMindSystem>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
EntityUid entity = default; EntityUid entity = default;
EntityUid mindId = default!; EntityUid mindId = default!;
@@ -71,7 +74,7 @@ public sealed partial class MindTests
EntityUid mindId = default!; EntityUid mindId = default!;
MindComponent mind = default!; MindComponent mind = default!;
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
await pair.Server.WaitAssertion(() => await pair.Server.WaitAssertion(() =>
{ {
var oldUid = player.AttachedEntity; var oldUid = player.AttachedEntity;
@@ -116,20 +119,25 @@ public sealed partial class MindTests
/// </summary> /// </summary>
private static (EntityUid Id, MindComponent Comp) GetMind(Pair.TestPair pair) private static (EntityUid Id, MindComponent Comp) GetMind(Pair.TestPair pair)
{ {
var playerMan = pair.Server.ResolveDependency<IPlayerManager>(); var playerMan = pair.Server.PlayerMan;
var entMan = pair.Server.ResolveDependency<IEntityManager>(); var entMan = pair.Server.EntMan;
var player = playerMan.ServerSessions.SingleOrDefault(); var player = playerMan.Sessions.SingleOrDefault();
Assert.That(player, Is.Not.Null); Assert.That(player, Is.Not.Null);
var mindId = player.ContentData()!.Mind!.Value; var mindId = player.ContentData()!.Mind!.Value;
Assert.That(mindId, Is.Not.EqualTo(default(EntityUid))); Assert.That(mindId, Is.Not.EqualTo(default(EntityUid)));
var mind = entMan.GetComponent<MindComponent>(mindId); var mind = entMan.GetComponent<MindComponent>(mindId);
ActorComponent actor = default!;
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(player, Is.EqualTo(mind.Session), "Player session does not match mind session");
Assert.That(entMan.System<MindSystem>().GetMind(player.UserId), Is.EqualTo(mindId));
Assert.That(player.AttachedEntity, Is.EqualTo(mind.CurrentEntity), "Player is not attached to the mind's current entity."); Assert.That(player.AttachedEntity, Is.EqualTo(mind.CurrentEntity), "Player is not attached to the mind's current entity.");
Assert.That(entMan.EntityExists(mind.OwnedEntity), "The mind's current entity does not exist"); Assert.That(entMan.EntityExists(mind.OwnedEntity), "The mind's current entity does not exist");
Assert.That(mind.VisitingEntity == null || entMan.EntityExists(mind.VisitingEntity), "The minds visited entity does not exist."); Assert.That(mind.VisitingEntity == null || entMan.EntityExists(mind.VisitingEntity), "The minds visited entity does not exist.");
Assert.That(entMan.TryGetComponent(mind.CurrentEntity, out actor));
}); });
Assert.That(actor.PlayerSession, Is.EqualTo(mind.Session));
return (mindId, mind); return (mindId, mind);
} }
@@ -139,7 +147,7 @@ public sealed partial class MindTests
var netManager = pair.Client.ResolveDependency<IClientNetManager>(); var netManager = pair.Client.ResolveDependency<IClientNetManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>(); var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var entMan = pair.Server.ResolveDependency<IEntityManager>(); var entMan = pair.Server.ResolveDependency<IEntityManager>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
var mindId = player.ContentData()!.Mind!.Value; var mindId = player.ContentData()!.Mind!.Value;
var mind = entMan.GetComponent<MindComponent>(mindId); var mind = entMan.GetComponent<MindComponent>(mindId);
@@ -161,21 +169,21 @@ public sealed partial class MindTests
{ {
var netManager = pair.Client.ResolveDependency<IClientNetManager>(); var netManager = pair.Client.ResolveDependency<IClientNetManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>(); var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
Assert.That(!playerMan.ServerSessions.Any()); Assert.That(!playerMan.Sessions.Any());
await Task.WhenAll(pair.Client.WaitIdleAsync(), pair.Client.WaitIdleAsync()); await Task.WhenAll(pair.Client.WaitIdleAsync(), pair.Client.WaitIdleAsync());
pair.Client.SetConnectTarget(pair.Server); pair.Client.SetConnectTarget(pair.Server);
await pair.Client.WaitPost(() => netManager.ClientConnect(null!, 0, username)); await pair.Client.WaitPost(() => netManager.ClientConnect(null!, 0, username));
await pair.RunTicksSync(5); await pair.RunTicksSync(5);
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
Assert.That(player.Status, Is.EqualTo(SessionStatus.InGame)); Assert.That(player.Status, Is.EqualTo(SessionStatus.InGame));
} }
private static async Task<IPlayerSession> DisconnectReconnect(Pair.TestPair pair) private static async Task<ICommonSession> DisconnectReconnect(Pair.TestPair pair)
{ {
var playerMan = pair.Server.ResolveDependency<IPlayerManager>(); var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
var name = player.Name; var name = player.Name;
var id = player.UserId; var id = player.UserId;
@@ -183,7 +191,7 @@ public sealed partial class MindTests
await Connect(pair, name); await Connect(pair, name);
// Session has changed // Session has changed
var newSession = playerMan.ServerSessions.Single(); var newSession = playerMan.Sessions.Single();
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(newSession, Is.Not.EqualTo(player)); Assert.That(newSession, Is.Not.EqualTo(player));

View File

@@ -1,6 +1,8 @@
using System.Linq; using System.Linq;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Mind; using Content.Shared.Mind;
using NUnit.Framework.Interfaces;
using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -49,7 +51,7 @@ public sealed partial class MindTests
var mind = GetMind(pair); var mind = GetMind(pair);
var playerMan = pair.Server.ResolveDependency<IPlayerManager>(); var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
var name = player.Name; var name = player.Name;
var user = player.UserId; var user = player.UserId;
Assert.That(mind.Comp.OwnedEntity, Is.Not.Null); Assert.That(mind.Comp.OwnedEntity, Is.Not.Null);
@@ -72,7 +74,7 @@ public sealed partial class MindTests
// Reconnect // Reconnect
await Connect(pair, name); await Connect(pair, name);
player = playerMan.ServerSessions.Single(); player = playerMan.Sessions.Single();
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(user, Is.EqualTo(player.UserId)); Assert.That(user, Is.EqualTo(player.UserId));
@@ -127,8 +129,10 @@ public sealed partial class MindTests
var mindSys = entMan.System<SharedMindSystem>(); var mindSys = entMan.System<SharedMindSystem>();
var mind = GetMind(pair); var mind = GetMind(pair);
Assert.Null(mind.Comp.VisitingEntity);
// Make player visit a new mob // Make player visit a new mob
var original = mind.Comp.CurrentEntity; var original = mind.Comp.OwnedEntity;
EntityUid visiting = default; EntityUid visiting = default;
await pair.Server.WaitAssertion(() => await pair.Server.WaitAssertion(() =>
{ {
@@ -137,6 +141,7 @@ public sealed partial class MindTests
}); });
await pair.RunTicksSync(5); await pair.RunTicksSync(5);
Assert.That(mind.Comp.VisitingEntity, Is.EqualTo(visiting));
await DisconnectReconnect(pair); await DisconnectReconnect(pair);
// Player is back in control of the visited mob, mind was preserved // Player is back in control of the visited mob, mind was preserved
@@ -150,4 +155,32 @@ public sealed partial class MindTests
await pair.CleanReturnAsync(); await pair.CleanReturnAsync();
} }
// This test will do the following
// - connect as a normal player
// - disconnect
// - reconnect
// - assert that they return to the original entity.
[Test]
public async Task TestReconnect()
{
await using var pair = await SetupPair();
var mind = GetMind(pair);
Assert.Null(mind.Comp.VisitingEntity);
Assert.NotNull(mind.Comp.OwnedEntity);
var entity = mind.Comp.OwnedEntity;
await pair.RunTicksSync(5);
await DisconnectReconnect(pair);
await pair.RunTicksSync(5);
var newMind = GetMind(pair);
Assert.Null(newMind.Comp.VisitingEntity);
Assert.That(newMind.Comp.OwnedEntity, Is.EqualTo(entity));
Assert.That(newMind.Id, Is.EqualTo(mind.Id));
await pair.CleanReturnAsync();
}
} }

View File

@@ -11,6 +11,7 @@ using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Mind; using Content.Shared.Mind;
using Content.Shared.Mind.Components; using Content.Shared.Mind.Components;
using Content.Shared.Players;
using Content.Shared.Roles; using Content.Shared.Roles;
using Content.Shared.Roles.Jobs; using Content.Shared.Roles.Jobs;
using Robust.Server.Console; using Robust.Server.Console;
@@ -345,7 +346,7 @@ public sealed partial class MindTests
EntityUid entity = default!; EntityUid entity = default!;
EntityUid mindId = default!; EntityUid mindId = default!;
MindComponent mind = default!; MindComponent mind = default!;
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
@@ -406,12 +407,6 @@ public sealed partial class MindTests
await pair.CleanReturnAsync(); await pair.CleanReturnAsync();
} }
// TODO Implement
/*[Test]
public async Task TestPlayerCanReturnFromGhostWhenDead()
{
}*/
[Test] [Test]
public async Task TestGhostDoesNotInfiniteLoop() public async Task TestGhostDoesNotInfiniteLoop()
{ {
@@ -432,7 +427,7 @@ public sealed partial class MindTests
EntityUid ghost = default!; EntityUid ghost = default!;
EntityUid mindId = default!; EntityUid mindId = default!;
MindComponent mind = default!; MindComponent mind = default!;
var player = playerMan.ServerSessions.Single(); var player = playerMan.Sessions.Single();
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {

View File

@@ -2,8 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.IntegrationTests.Pair; using Content.IntegrationTests.Pair;
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Robust.Server.Player; using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Toolshed; using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors; using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Toolshed.Syntax; using Robust.Shared.Toolshed.Syntax;
@@ -60,7 +59,7 @@ public abstract class ToolshedTest : IInvocationContext
AdminManager = Server.ResolveDependency<IAdminManager>(); AdminManager = Server.ResolveDependency<IAdminManager>();
} }
protected bool InvokeCommand(string command, out object? result, IPlayerSession? session = null) protected bool InvokeCommand(string command, out object? result, ICommonSession? session = null)
{ {
return Toolshed.InvokeCommand(this, command, null, out result); return Toolshed.InvokeCommand(this, command, null, out result);
} }
@@ -95,7 +94,7 @@ public abstract class ToolshedTest : IInvocationContext
return true; return true;
} }
protected IPlayerSession? InvocationSession { get; set; } protected ICommonSession? InvocationSession { get; set; }
public ICommonSession? Session public ICommonSession? Session
{ {

View File

@@ -68,7 +68,7 @@ namespace Content.MapRenderer.Painters
await server.WaitPost(() => await server.WaitPost(() =>
{ {
var playerEntity = sPlayerManager.ServerSessions.Single().AttachedEntity; var playerEntity = sPlayerManager.Sessions.Single().AttachedEntity;
if (playerEntity.HasValue) if (playerEntity.HasValue)
{ {

View File

@@ -1,5 +1,5 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player; using Robust.Shared.Player;
namespace Content.Server.Administration namespace Content.Server.Administration
{ {
@@ -8,7 +8,7 @@ namespace Content.Server.Administration
/// </summary> /// </summary>
public sealed class AdminPermsChangedEventArgs : EventArgs public sealed class AdminPermsChangedEventArgs : EventArgs
{ {
public AdminPermsChangedEventArgs(IPlayerSession player, AdminFlags? flags) public AdminPermsChangedEventArgs(ICommonSession player, AdminFlags? flags)
{ {
Player = player; Player = player;
Flags = flags; Flags = flags;
@@ -17,7 +17,7 @@ namespace Content.Server.Administration
/// <summary> /// <summary>
/// The player that had their admin permissions changed. /// The player that had their admin permissions changed.
/// </summary> /// </summary>
public IPlayerSession Player { get; } public ICommonSession Player { get; }
/// <summary> /// <summary>
/// The admin flags of the player. Null if the player is no longer an admin. /// The admin flags of the player. Null if the player is no longer an admin.

View File

@@ -2,7 +2,6 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Mind; using Content.Shared.Mind;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
@@ -18,7 +17,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("Nah"); shell.WriteLine("Nah");

View File

@@ -2,7 +2,6 @@
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Server.Afk; using Content.Server.Afk;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -35,7 +34,7 @@ public sealed class AdminWhoCommand : IConsoleCommand
if (adminData.Title is { } title) if (adminData.Title is { } title)
sb.Append($": [{title}]"); sb.Append($": [{title}]");
if (shell.Player is IPlayerSession player && adminMgr.HasAdminFlag(player, AdminFlags.Admin)) if (shell.Player is { } player && adminMgr.HasAdminFlag(player, AdminFlags.Admin))
{ {
if (afk.IsAfk(admin)) if (afk.IsAfk(admin))
sb.Append(" [AFK]"); sb.Append(" [AFK]");

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration.UI; using Content.Server.Administration.UI;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
@@ -17,7 +16,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("This does not work from the server console."); shell.WriteLine("This does not work from the server console.");

View File

@@ -1,15 +1,8 @@
using System.Linq; using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Server.Administration.Notes;
using Content.Server.Database;
using Content.Server.GameTicking;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Players.PlayTimeTracking;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Console; using Robust.Shared.Console;
@@ -84,7 +77,7 @@ public sealed class BanCommand : LocalizedCommands
} }
var located = await _locator.LookupIdByNameOrIdAsync(target); var located = await _locator.LookupIdByNameOrIdAsync(target);
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (located == null) if (located == null)
{ {
@@ -102,7 +95,7 @@ public sealed class BanCommand : LocalizedCommands
{ {
if (args.Length == 1) if (args.Length == 1)
{ {
var options = _playerManager.ServerSessions.Select(c => c.Name).OrderBy(c => c).ToArray(); var options = _playerManager.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
return CompletionResult.FromHintOptions(options, LocalizationManager.GetString("cmd-ban-hint")); return CompletionResult.FromHintOptions(options, LocalizationManager.GetString("cmd-ban-hint"));
} }

View File

@@ -36,7 +36,7 @@ public sealed class BanListCommand : LocalizedCommands
return; return;
} }
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
var bans = await _dbManager.GetServerBansAsync(data.LastAddress, data.UserId, data.LastHWId, false); var bans = await _dbManager.GetServerBansAsync(data.LastAddress, data.UserId, data.LastHWId, false);
@@ -67,7 +67,7 @@ public sealed class BanListCommand : LocalizedCommands
return CompletionResult.Empty; return CompletionResult.Empty;
var playerMgr = IoCManager.Resolve<IPlayerManager>(); var playerMgr = IoCManager.Resolve<IPlayerManager>();
var options = playerMgr.ServerSessions.Select(c => c.Name).OrderBy(c => c).ToArray(); var options = playerMgr.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-banlist-hint")); return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-banlist-hint"));
} }
} }

View File

@@ -1,12 +1,6 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Shared.Console; using Robust.Shared.Console;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Content.Server.EUI; using Content.Server.EUI;
using Robust.Server.Player;
namespace Content.Server.Administration.Commands; namespace Content.Server.Administration.Commands;
@@ -21,7 +15,7 @@ public sealed class BanPanelCommand : LocalizedCommands
public override async void Execute(IConsoleShell shell, string argStr, string[] args) public override async void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
shell.WriteError(Loc.GetString("cmd-banpanel-server")); shell.WriteError(Loc.GetString("cmd-banpanel-server"));
return; return;

View File

@@ -1,6 +1,5 @@
using Content.Server.Mind; using Content.Server.Mind;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
@@ -16,7 +15,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
shell.WriteLine("shell-server-cannot"); shell.WriteLine("shell-server-cannot");
return; return;

View File

@@ -1,7 +1,5 @@
using Content.Server.Chat;
using Content.Server.Chat.Systems; using Content.Server.Chat.Systems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
@@ -17,7 +15,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("shell-only-players-can-run-this-command"); shell.WriteLine("shell-only-players-can-run-this-command");

View File

@@ -1,10 +1,8 @@
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Shared.Administration; using Content.Shared.Administration;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[UsedImplicitly] [UsedImplicitly]
@@ -17,7 +15,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("You cannot use this command from the server console."); shell.WriteLine("You cannot use this command from the server console.");

View File

@@ -3,7 +3,6 @@ using Content.Server.EUI;
using Content.Server.Explosion.EntitySystems; using Content.Server.Explosion.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Explosion; using Content.Shared.Explosion;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -21,7 +20,7 @@ public sealed class OpenExplosionEui : IConsoleCommand
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteError("This does not work from the server console."); shell.WriteError("This does not work from the server console.");

View File

@@ -1,7 +1,6 @@
using Content.Server.EUI; using Content.Server.EUI;
using Content.Server.Fax.AdminUI; using Content.Server.Fax.AdminUI;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands; namespace Content.Server.Administration.Commands;
@@ -16,7 +15,7 @@ public sealed class FaxUiCommand : IConsoleCommand
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("shell-only-players-can-run-this-command"); shell.WriteLine("shell-only-players-can-run-this-command");

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands; namespace Content.Server.Administration.Commands;
@@ -15,7 +14,7 @@ public sealed class OpenAdminLogsCommand : IConsoleCommand
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
shell.WriteLine("This does not work from the server console."); shell.WriteLine("This does not work from the server console.");
return; return;

View File

@@ -1,7 +1,5 @@
using Content.Server.Administration.Notes; using Content.Server.Administration.Notes;
using Content.Server.Database;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands; namespace Content.Server.Administration.Commands;
@@ -17,7 +15,7 @@ public sealed class OpenAdminNotesCommand : IConsoleCommand
public async void Execute(IConsoleShell shell, string argStr, string[] args) public async void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
shell.WriteError("This does not work from the server console."); shell.WriteError("This does not work from the server console.");
return; return;

View File

@@ -1,10 +1,8 @@
using Content.Server.Administration.UI; using Content.Server.Administration.UI;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AdminCommand(AdminFlags.Permissions)] [AdminCommand(AdminFlags.Permissions)]
@@ -16,7 +14,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("This does not work from the server console."); shell.WriteLine("This does not work from the server console.");

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration.Notes; using Content.Server.Administration.Notes;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Robust.Server.Player;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Console; using Robust.Shared.Console;
@@ -27,7 +26,7 @@ public sealed class OpenUserVisibleNotesCommand : IConsoleCommand
return; return;
} }
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
shell.WriteError("This does not work from the server console."); shell.WriteError("This does not work from the server console.");
return; return;

View File

@@ -1,7 +1,6 @@
using System.Text; using System.Text;
using Content.Server.Database; using Content.Server.Database;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
@@ -15,7 +14,7 @@ namespace Content.Server.Administration.Commands
public async void Execute(IConsoleShell shell, string argStr, string[] args) public async void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
var dbMan = IoCManager.Resolve<IServerDbManager>(); var dbMan = IoCManager.Resolve<IServerDbManager>();
if (args.Length != 1) if (args.Length != 1)

View File

@@ -6,7 +6,6 @@ using Robust.Shared.Audio;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.ContentPack; using Robust.Shared.ContentPack;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.Administration.Commands; namespace Content.Server.Administration.Commands;

View File

@@ -1,9 +1,7 @@
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
[AnyCommand] [AnyCommand]
@@ -15,7 +13,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("You cannot use this command from the server console."); shell.WriteLine("You cannot use this command from the server console.");

View File

@@ -1,8 +1,6 @@
using Content.Server.Database; using Content.Server.Database;
using Content.Server.Preferences.Managers; using Content.Server.Preferences.Managers;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
@@ -16,7 +14,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (!(shell.Player is IPlayerSession)) if (shell.Player == null)
{ {
shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command")); shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command"));
return; return;

View File

@@ -2,6 +2,7 @@ using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Mind; using Content.Shared.Mind;
using Content.Shared.Mind.Components; using Content.Shared.Mind.Components;
using Content.Shared.Players;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;

View File

@@ -10,7 +10,6 @@ using Content.Shared.PDA;
using Content.Shared.Preferences; using Content.Shared.Preferences;
using Content.Shared.Roles; using Content.Shared.Roles;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -57,7 +56,7 @@ namespace Content.Server.Administration.Commands
if (args.Length == 1) if (args.Length == 1)
{ {
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
shell.WriteError(Loc.GetString("set-outfit-command-is-not-player-error")); shell.WriteError(Loc.GetString("set-outfit-command-is-not-player-error"));
return; return;

View File

@@ -4,11 +4,9 @@ using Content.Server.Warps;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Follower; using Content.Shared.Follower;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
@@ -28,7 +26,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("Only players can use this command"); shell.WriteLine("Only players can use this command");

View File

@@ -1,8 +1,8 @@
using Content.Server.Database; using Content.Server.Database;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Robust.Server.Player;
using Robust.Server.Upload; using Robust.Server.Upload;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Robust.Shared.Upload; using Robust.Shared.Upload;
namespace Content.Server.Administration; namespace Content.Server.Administration;
@@ -22,7 +22,7 @@ public sealed class ContentNetworkResourceManager
_netRes.OnResourceUploaded += OnUploadResource; _netRes.OnResourceUploaded += OnUploadResource;
} }
private async void OnUploadResource(IPlayerSession session, NetworkResourceUploadMessage msg) private async void OnUploadResource(ICommonSession session, NetworkResourceUploadMessage msg)
{ {
if (StoreUploaded) if (StoreUploaded)
await _serverDb.AddUploadedResourceLogAsync(session.UserId, DateTime.Now, msg.RelativePath.ToString(), msg.Data); await _serverDb.AddUploadedResourceLogAsync(session.UserId, DateTime.Now, msg.RelativePath.ToString(), msg.Data);

View File

@@ -3,8 +3,8 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Content.Server.Administration.Logs.Converters; using Content.Server.Administration.Logs.Converters;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Player;
namespace Content.Server.Administration.Logs; namespace Content.Server.Administration.Logs;
@@ -44,7 +44,7 @@ public sealed partial class AdminLogManager
var value = properties[key]; var value = properties[key];
value = value switch value = value switch
{ {
IPlayerSession player => new SerializablePlayer(player), ICommonSession player => new SerializablePlayer(player),
EntityCoordinates entityCoordinates => new SerializableEntityCoordinates(_entityManager, entityCoordinates), EntityCoordinates entityCoordinates => new SerializableEntityCoordinates(_entityManager, entityCoordinates),
_ => value _ => value
}; };
@@ -56,7 +56,7 @@ public sealed partial class AdminLogManager
{ {
EntityUid id => id, EntityUid id => id,
EntityStringRepresentation rep => rep.Uid, EntityStringRepresentation rep => rep.Uid,
IPlayerSession {AttachedEntity: {Valid: true}} session => session.AttachedEntity, ICommonSession {AttachedEntity: {Valid: true}} session => session.AttachedEntity,
IComponent component => component.Owner, IComponent component => component.Owner,
_ => null _ => null
}; };

View File

@@ -1,5 +1,5 @@
using System.Text.Json; using System.Text.Json;
using Robust.Server.Player; using Robust.Shared.Player;
namespace Content.Server.Administration.Logs.Converters; namespace Content.Server.Administration.Logs.Converters;
@@ -36,9 +36,9 @@ public sealed class PlayerSessionConverter : AdminLogConverter<SerializablePlaye
public readonly struct SerializablePlayer public readonly struct SerializablePlayer
{ {
public readonly IPlayerSession Player; public readonly ICommonSession Player;
public SerializablePlayer(IPlayerSession player) public SerializablePlayer(ICommonSession player)
{ {
Player = player; Player = player;
} }

View File

@@ -7,15 +7,15 @@ using Content.Server.Database;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Players;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.ContentPack; using Robust.Shared.ContentPack;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Players; using Robust.Shared.Player;
using Robust.Shared.Toolshed; using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors; using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -35,16 +35,16 @@ namespace Content.Server.Administration.Managers
[Dependency] private readonly IChatManager _chat = default!; [Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly ToolshedManager _toolshed = default!; [Dependency] private readonly ToolshedManager _toolshed = default!;
private readonly Dictionary<IPlayerSession, AdminReg> _admins = new(); private readonly Dictionary<ICommonSession, AdminReg> _admins = new();
private readonly HashSet<NetUserId> _promotedPlayers = new(); private readonly HashSet<NetUserId> _promotedPlayers = new();
public event Action<AdminPermsChangedEventArgs>? OnPermsChanged; public event Action<AdminPermsChangedEventArgs>? OnPermsChanged;
public IEnumerable<IPlayerSession> ActiveAdmins => _admins public IEnumerable<ICommonSession> ActiveAdmins => _admins
.Where(p => p.Value.Data.Active) .Where(p => p.Value.Data.Active)
.Select(p => p.Key); .Select(p => p.Key);
public IEnumerable<IPlayerSession> AllAdmins => _admins.Select(p => p.Key); public IEnumerable<ICommonSession> AllAdmins => _admins.Select(p => p.Key);
private readonly AdminCommandPermissions _commandPermissions = new(); private readonly AdminCommandPermissions _commandPermissions = new();
private readonly AdminCommandPermissions _toolshedCommandPermissions = new(); private readonly AdminCommandPermissions _toolshedCommandPermissions = new();
@@ -56,7 +56,7 @@ namespace Content.Server.Administration.Managers
public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false) public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
{ {
if (_admins.TryGetValue((IPlayerSession)session, out var reg) && (reg.Data.Active || includeDeAdmin)) if (_admins.TryGetValue(session, out var reg) && (reg.Data.Active || includeDeAdmin))
{ {
return reg.Data; return reg.Data;
} }
@@ -66,13 +66,13 @@ namespace Content.Server.Administration.Managers
public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false) public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false)
{ {
if (_playerManager.TryGetSessionByEntity(uid, out var session) && session is IPlayerSession playerSession) if (_playerManager.TryGetSessionByEntity(uid, out var session))
return GetAdminData(playerSession, includeDeAdmin); return GetAdminData(session, includeDeAdmin);
return null; return null;
} }
public void DeAdmin(IPlayerSession session) public void DeAdmin(ICommonSession session)
{ {
if (!_admins.TryGetValue(session, out var reg)) if (!_admins.TryGetValue(session, out var reg))
{ {
@@ -95,7 +95,7 @@ namespace Content.Server.Administration.Managers
UpdateAdminStatus(session); UpdateAdminStatus(session);
} }
public void ReAdmin(IPlayerSession session) public void ReAdmin(ICommonSession session)
{ {
if (!_admins.TryGetValue(session, out var reg)) if (!_admins.TryGetValue(session, out var reg))
{ {
@@ -119,7 +119,7 @@ namespace Content.Server.Administration.Managers
UpdateAdminStatus(session); UpdateAdminStatus(session);
} }
public async void ReloadAdmin(IPlayerSession player) public async void ReloadAdmin(ICommonSession player)
{ {
var data = await LoadAdminData(player); var data = await LoadAdminData(player);
var curAdmin = _admins.GetValueOrDefault(player); var curAdmin = _admins.GetValueOrDefault(player);
@@ -236,7 +236,7 @@ namespace Content.Server.Administration.Managers
_toolshed.ActivePermissionController = this; _toolshed.ActivePermissionController = this;
} }
public void PromoteHost(IPlayerSession player) public void PromoteHost(ICommonSession player)
{ {
_promotedPlayers.Add(player.UserId); _promotedPlayers.Add(player.UserId);
@@ -250,7 +250,7 @@ namespace Content.Server.Administration.Managers
} }
// NOTE: Also sends commands list for non admins.. // NOTE: Also sends commands list for non admins..
private void UpdateAdminStatus(IPlayerSession session) private void UpdateAdminStatus(ICommonSession session)
{ {
var msg = new MsgUpdateAdminStatus(); var msg = new MsgUpdateAdminStatus();
@@ -290,7 +290,7 @@ namespace Content.Server.Administration.Managers
} }
} }
private async void LoginAdminMaybe(IPlayerSession session) private async void LoginAdminMaybe(ICommonSession session)
{ {
var adminDat = await LoadAdminData(session); var adminDat = await LoadAdminData(session);
if (adminDat == null) if (adminDat == null)
@@ -323,7 +323,7 @@ namespace Content.Server.Administration.Managers
UpdateAdminStatus(session); UpdateAdminStatus(session);
} }
private async Task<(AdminData dat, int? rankId, bool specialLogin)?> LoadAdminData(IPlayerSession session) private async Task<(AdminData dat, int? rankId, bool specialLogin)?> LoadAdminData(ICommonSession session)
{ {
var promoteHost = IsLocal(session) && _cfg.GetCVar(CCVars.ConsoleLoginLocal) var promoteHost = IsLocal(session) && _cfg.GetCVar(CCVars.ConsoleLoginLocal)
|| _promotedPlayers.Contains(session.UserId) || _promotedPlayers.Contains(session.UserId)
@@ -387,7 +387,7 @@ namespace Content.Server.Administration.Managers
} }
} }
private static bool IsLocal(IPlayerSession player) private static bool IsLocal(ICommonSession player)
{ {
var ep = player.ConnectedClient.RemoteEndPoint; var ep = player.ConnectedClient.RemoteEndPoint;
var addr = ep.Address; var addr = ep.Address;
@@ -419,7 +419,7 @@ namespace Content.Server.Administration.Managers
return false; return false;
} }
public bool CanCommand(IPlayerSession session, string cmdName) public bool CanCommand(ICommonSession session, string cmdName)
{ {
if (_commandPermissions.AnyCommands.Contains(cmdName)) if (_commandPermissions.AnyCommands.Contains(cmdName))
{ {
@@ -474,7 +474,7 @@ namespace Content.Server.Administration.Managers
return true; return true;
} }
var data = GetAdminData((IPlayerSession)user); var data = GetAdminData(user);
if (data == null) if (data == null)
{ {
// Player isn't an admin. // Player isn't an admin.
@@ -520,32 +520,32 @@ namespace Content.Server.Administration.Managers
return (attribs.Length != 0, attribs); return (attribs.Length != 0, attribs);
} }
public bool CanViewVar(IPlayerSession session) public bool CanViewVar(ICommonSession session)
{ {
return CanCommand(session, "vv"); return CanCommand(session, "vv");
} }
public bool CanAdminPlace(IPlayerSession session) public bool CanAdminPlace(ICommonSession session)
{ {
return GetAdminData(session)?.CanAdminPlace() ?? false; return GetAdminData(session)?.CanAdminPlace() ?? false;
} }
public bool CanScript(IPlayerSession session) public bool CanScript(ICommonSession session)
{ {
return GetAdminData(session)?.CanScript() ?? false; return GetAdminData(session)?.CanScript() ?? false;
} }
public bool CanAdminMenu(IPlayerSession session) public bool CanAdminMenu(ICommonSession session)
{ {
return GetAdminData(session)?.CanAdminMenu() ?? false; return GetAdminData(session)?.CanAdminMenu() ?? false;
} }
public bool CanAdminReloadPrototypes(IPlayerSession session) public bool CanAdminReloadPrototypes(ICommonSession session)
{ {
return GetAdminData(session)?.CanAdminReloadPrototypes() ?? false; return GetAdminData(session)?.CanAdminReloadPrototypes() ?? false;
} }
private void SendPermsChangedEvent(IPlayerSession session) private void SendPermsChangedEvent(ICommonSession session)
{ {
var flags = GetAdminData(session)?.Flags; var flags = GetAdminData(session)?.Flags;
OnPermsChanged?.Invoke(new AdminPermsChangedEventArgs(session, flags)); OnPermsChanged?.Invoke(new AdminPermsChangedEventArgs(session, flags));
@@ -553,7 +553,7 @@ namespace Content.Server.Administration.Managers
private sealed class AdminReg private sealed class AdminReg
{ {
public readonly IPlayerSession Session; public readonly ICommonSession Session;
public AdminData Data; public AdminData Data;
public int? RankId; public int? RankId;
@@ -561,7 +561,7 @@ namespace Content.Server.Administration.Managers
// Such as console.loginlocal or promotehost // Such as console.loginlocal or promotehost
public bool IsSpecialLogin; public bool IsSpecialLogin;
public AdminReg(IPlayerSession session, AdminData data) public AdminReg(ICommonSession session, AdminData data)
{ {
Data = data; Data = data;
Session = session; Session = session;

View File

@@ -15,6 +15,7 @@ using Robust.Server.Player;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -283,7 +284,7 @@ public sealed class BanManager : IBanManager, IPostInjectInit
SendRoleBans(player); SendRoleBans(player);
} }
public void SendRoleBans(IPlayerSession pSession) public void SendRoleBans(ICommonSession pSession)
{ {
var roleBans = _cachedRoleBans.GetValueOrDefault(pSession.UserId) ?? new HashSet<ServerRoleBanDef>(); var roleBans = _cachedRoleBans.GetValueOrDefault(pSession.UserId) ?? new HashSet<ServerRoleBanDef>();
var bans = new MsgRoleBans() var bans = new MsgRoleBans()

View File

@@ -1,9 +1,8 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Administration.Managers; using Content.Shared.Administration.Managers;
using Robust.Server.Player; using Robust.Shared.Player;
using Robust.Shared.Toolshed; using Robust.Shared.Toolshed;
namespace Content.Server.Administration.Managers namespace Content.Server.Administration.Managers
{ {
/// <summary> /// <summary>
@@ -22,12 +21,12 @@ namespace Content.Server.Administration.Managers
/// <remarks> /// <remarks>
/// This does not include admins that are de-adminned. /// This does not include admins that are de-adminned.
/// </remarks> /// </remarks>
IEnumerable<IPlayerSession> ActiveAdmins { get; } IEnumerable<ICommonSession> ActiveAdmins { get; }
/// <summary> /// <summary>
/// Gets all admins currently on the server, even de-adminned ones. /// Gets all admins currently on the server, even de-adminned ones.
/// </summary> /// </summary>
IEnumerable<IPlayerSession> AllAdmins { get; } IEnumerable<ICommonSession> AllAdmins { get; }
/// <summary> /// <summary>
/// De-admins an admin temporarily so they are effectively a normal player. /// De-admins an admin temporarily so they are effectively a normal player.
@@ -35,18 +34,18 @@ namespace Content.Server.Administration.Managers
/// <remarks> /// <remarks>
/// De-adminned admins are able to re-admin at any time if they so desire. /// De-adminned admins are able to re-admin at any time if they so desire.
/// </remarks> /// </remarks>
void DeAdmin(IPlayerSession session); void DeAdmin(ICommonSession session);
/// <summary> /// <summary>
/// Re-admins a de-adminned admin. /// Re-admins a de-adminned admin.
/// </summary> /// </summary>
void ReAdmin(IPlayerSession session); void ReAdmin(ICommonSession session);
/// <summary> /// <summary>
/// Re-loads the permissions of an player in case their admin data changed DB-side. /// Re-loads the permissions of an player in case their admin data changed DB-side.
/// </summary> /// </summary>
/// <seealso cref="ReloadAdminsWithRank"/> /// <seealso cref="ReloadAdminsWithRank"/>
void ReloadAdmin(IPlayerSession player); void ReloadAdmin(ICommonSession player);
/// <summary> /// <summary>
/// Reloads admin permissions for all admins with a certain rank. /// Reloads admin permissions for all admins with a certain rank.
@@ -57,7 +56,7 @@ namespace Content.Server.Administration.Managers
void Initialize(); void Initialize();
void PromoteHost(IPlayerSession player); void PromoteHost(ICommonSession player);
bool TryGetCommandFlags(CommandSpec command, out AdminFlags[]? flags); bool TryGetCommandFlags(CommandSpec command, out AdminFlags[]? flags);
} }

View File

@@ -2,8 +2,8 @@ using System.Collections.Immutable;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Shared.Database; using Content.Shared.Database;
using Robust.Server.Player;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player;
namespace Content.Server.Administration.Managers; namespace Content.Server.Administration.Managers;
@@ -55,5 +55,5 @@ public interface IBanManager
/// Sends role bans to the target /// Sends role bans to the target
/// </summary> /// </summary>
/// <param name="pSession">Player's session</param> /// <param name="pSession">Player's session</param>
public void SendRoleBans(IPlayerSession pSession); public void SendRoleBans(ICommonSession pSession);
} }

View File

@@ -11,7 +11,7 @@ using Content.Shared.Database;
using Content.Shared.Players.PlayTimeTracking; using Content.Shared.Players.PlayTimeTracking;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Players; using Robust.Shared.Player;
namespace Content.Server.Administration.Notes; namespace Content.Server.Administration.Notes;

View File

@@ -1,13 +1,13 @@
using Content.Server.Administration.Commands; using Content.Server.Administration.Commands;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Shared.Chat;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Player;
using Robust.Shared.Utility; using Robust.Shared.Utility;
namespace Content.Server.Administration.Notes; namespace Content.Server.Administration.Notes;

View File

@@ -2,7 +2,7 @@ using System.Threading.Tasks;
using Content.Server.Database; using Content.Server.Database;
using Content.Shared.Administration.Notes; using Content.Shared.Administration.Notes;
using Content.Shared.Database; using Content.Shared.Database;
using Robust.Shared.Players; using Robust.Shared.Player;
namespace Content.Server.Administration.Notes; namespace Content.Server.Administration.Notes;

View File

@@ -1,6 +1,6 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Player; using Robust.Shared.Player;
namespace Content.Server.Administration; namespace Content.Server.Administration;
@@ -16,7 +16,7 @@ public sealed partial class QuickDialogSystem
/// <param name="cancelAction">The action to execute upon the dialog being cancelled.</param> /// <param name="cancelAction">The action to execute upon the dialog being cancelled.</param>
/// <typeparam name="T1">Type of the input.</typeparam> /// <typeparam name="T1">Type of the input.</typeparam>
[PublicAPI] [PublicAPI]
public void OpenDialog<T1>(IPlayerSession session, string title, string prompt, Action<T1> okAction, public void OpenDialog<T1>(ICommonSession session, string title, string prompt, Action<T1> okAction,
Action? cancelAction = null) Action? cancelAction = null)
{ {
OpenDialogInternal( OpenDialogInternal(
@@ -53,7 +53,7 @@ public sealed partial class QuickDialogSystem
/// <typeparam name="T1">Type of the first input.</typeparam> /// <typeparam name="T1">Type of the first input.</typeparam>
/// <typeparam name="T2">Type of the second input.</typeparam> /// <typeparam name="T2">Type of the second input.</typeparam>
[PublicAPI] [PublicAPI]
public void OpenDialog<T1, T2>(IPlayerSession session, string title, string prompt1, string prompt2, public void OpenDialog<T1, T2>(ICommonSession session, string title, string prompt1, string prompt2,
Action<T1, T2> okAction, Action? cancelAction = null) Action<T1, T2> okAction, Action? cancelAction = null)
{ {
OpenDialogInternal( OpenDialogInternal(
@@ -96,7 +96,7 @@ public sealed partial class QuickDialogSystem
/// <typeparam name="T2">Type of the second input.</typeparam> /// <typeparam name="T2">Type of the second input.</typeparam>
/// <typeparam name="T3">Type of the third input.</typeparam> /// <typeparam name="T3">Type of the third input.</typeparam>
[PublicAPI] [PublicAPI]
public void OpenDialog<T1, T2, T3>(IPlayerSession session, string title, string prompt1, string prompt2, public void OpenDialog<T1, T2, T3>(ICommonSession session, string title, string prompt1, string prompt2,
string prompt3, Action<T1, T2, T3> okAction, Action? cancelAction = null) string prompt3, Action<T1, T2, T3> okAction, Action? cancelAction = null)
{ {
OpenDialogInternal( OpenDialogInternal(
@@ -142,7 +142,7 @@ public sealed partial class QuickDialogSystem
/// <typeparam name="T3">Type of the third input.</typeparam> /// <typeparam name="T3">Type of the third input.</typeparam>
/// <typeparam name="T4">Type of the fourth input.</typeparam> /// <typeparam name="T4">Type of the fourth input.</typeparam>
[PublicAPI] [PublicAPI]
public void OpenDialog<T1, T2, T3, T4>(IPlayerSession session, string title, string prompt1, string prompt2, public void OpenDialog<T1, T2, T3, T4>(ICommonSession session, string title, string prompt1, string prompt2,
string prompt3, string prompt4, Action<T1, T2, T3, T4> okAction, Action? cancelAction = null) string prompt3, string prompt4, Action<T1, T2, T3, T4> okAction, Action? cancelAction = null)
{ {
OpenDialogInternal( OpenDialogInternal(

View File

@@ -1,12 +1,9 @@
using System.ComponentModel; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Administration; using Content.Shared.Administration;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.TypeSerializers.Interfaces;
namespace Content.Server.Administration; namespace Content.Server.Administration;
@@ -87,7 +84,7 @@ public sealed partial class QuickDialogSystem : EntitySystem
_openDialogsByUser.Remove(user); _openDialogsByUser.Remove(user);
} }
private void OpenDialogInternal(IPlayerSession session, string title, List<QuickDialogEntry> entries, QuickDialogButtonFlag buttons, Action<QuickDialogResponseEvent> okAction, Action cancelAction) private void OpenDialogInternal(ICommonSession session, string title, List<QuickDialogEntry> entries, QuickDialogButtonFlag buttons, Action<QuickDialogResponseEvent> okAction, Action cancelAction)
{ {
var did = GetDialogId(); var did = GetDialogId();
RaiseNetworkEvent( RaiseNetworkEvent(

View File

@@ -109,7 +109,7 @@ namespace Content.Server.Administration.Systems
} }
} }
public void UpdatePlayerList(IPlayerSession player) public void UpdatePlayerList(ICommonSession player)
{ {
_playerList[player.UserId] = GetPlayerInfo(player.Data, player); _playerList[player.UserId] = GetPlayerInfo(player.Data, player);
@@ -203,7 +203,7 @@ namespace Content.Server.Administration.Systems
UpdatePanicBunker(); UpdatePanicBunker();
} }
private void SendFullPlayerList(IPlayerSession playerSession) private void SendFullPlayerList(ICommonSession playerSession)
{ {
var ev = new FullPlayerListEvent(); var ev = new FullPlayerListEvent();
@@ -212,7 +212,7 @@ namespace Content.Server.Administration.Systems
RaiseNetworkEvent(ev, playerSession.ConnectedClient); RaiseNetworkEvent(ev, playerSession.ConnectedClient);
} }
private PlayerInfo GetPlayerInfo(IPlayerData data, IPlayerSession? session) private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session)
{ {
var name = data.UserName; var name = data.UserName;
var entityName = string.Empty; var entityName = string.Empty;
@@ -326,7 +326,7 @@ namespace Content.Server.Administration.Systems
/// chat messages and showing a popup to other players. /// chat messages and showing a popup to other players.
/// Their items are dropped on the ground. /// Their items are dropped on the ground.
/// </summary> /// </summary>
public void Erase(IPlayerSession player) public void Erase(ICommonSession player)
{ {
var entity = player.AttachedEntity; var entity = player.AttachedEntity;
_chat.DeleteMessagesBy(player); _chat.DeleteMessagesBy(player);

View File

@@ -1,8 +1,8 @@
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player;
namespace Content.Server.Administration.Systems; namespace Content.Server.Administration.Systems;
@@ -20,7 +20,7 @@ public sealed class AdminTestArenaSystem : EntitySystem
public Dictionary<NetUserId, EntityUid> ArenaMap { get; private set; } = new(); public Dictionary<NetUserId, EntityUid> ArenaMap { get; private set; } = new();
public Dictionary<NetUserId, EntityUid?> ArenaGrid { get; private set; } = new(); public Dictionary<NetUserId, EntityUid?> ArenaGrid { get; private set; } = new();
public (EntityUid Map, EntityUid? Grid) AssertArenaLoaded(IPlayerSession admin) public (EntityUid Map, EntityUid? Grid) AssertArenaLoaded(ICommonSession admin)
{ {
if (ArenaMap.TryGetValue(admin.UserId, out var arenaMap) && !Deleted(arenaMap) && !Terminating(arenaMap)) if (ArenaMap.TryGetValue(admin.UserId, out var arenaMap) && !Deleted(arenaMap) && !Terminating(arenaMap))
{ {

View File

@@ -24,11 +24,10 @@ using Content.Shared.Popups;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Players; using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Toolshed; using Robust.Shared.Toolshed;
@@ -427,7 +426,7 @@ namespace Content.Server.Administration.Systems
} }
} }
public void OpenEditSolutionsEui(IPlayerSession session, EntityUid uid) public void OpenEditSolutionsEui(ICommonSession session, EntityUid uid)
{ {
if (session.AttachedEntity == null) if (session.AttachedEntity == null)
return; return;

View File

@@ -17,6 +17,7 @@ using Robust.Shared;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -119,7 +120,7 @@ namespace Content.Server.Administration.Systems
_typingUpdateTimestamps[args.SenderSession.UserId] = (_timing.RealTime, msg.Typing); _typingUpdateTimestamps[args.SenderSession.UserId] = (_timing.RealTime, msg.Typing);
// Non-admins can only ever type on their own ahelp, guard against fake messages // Non-admins can only ever type on their own ahelp, guard against fake messages
var isAdmin = _adminManager.GetAdminData((IPlayerSession) args.SenderSession)?.HasFlag(AdminFlags.Adminhelp) ?? false; var isAdmin = _adminManager.GetAdminData(args.SenderSession)?.HasFlag(AdminFlags.Adminhelp) ?? false;
var channel = isAdmin ? msg.Channel : args.SenderSession.UserId; var channel = isAdmin ? msg.Channel : args.SenderSession.UserId;
var update = new BwoinkPlayerTypingUpdated(channel, args.SenderSession.Name, msg.Typing); var update = new BwoinkPlayerTypingUpdated(channel, args.SenderSession.Name, msg.Typing);
@@ -376,7 +377,7 @@ namespace Content.Server.Administration.Systems
protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs) protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
{ {
base.OnBwoinkTextMessage(message, eventArgs); base.OnBwoinkTextMessage(message, eventArgs);
var senderSession = (IPlayerSession) eventArgs.SenderSession; var senderSession = eventArgs.SenderSession;
// TODO: Sanitize text? // TODO: Sanitize text?
// Confirm that this person is actually allowed to send a message here. // Confirm that this person is actually allowed to send a message here.

View File

@@ -1,6 +1,6 @@
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player; using Robust.Shared.Player;
using Robust.Shared.Toolshed; using Robust.Shared.Toolshed;
namespace Content.Server.Administration.Toolshed; namespace Content.Server.Administration.Toolshed;
@@ -11,13 +11,13 @@ public sealed class AdminsCommand : ToolshedCommand
[Dependency] private readonly IAdminManager _admin = default!; [Dependency] private readonly IAdminManager _admin = default!;
[CommandImplementation("active")] [CommandImplementation("active")]
public IEnumerable<IPlayerSession> Active() public IEnumerable<ICommonSession> Active()
{ {
return _admin.ActiveAdmins; return _admin.ActiveAdmins;
} }
[CommandImplementation("all")] [CommandImplementation("all")]
public IEnumerable<IPlayerSession> All() public IEnumerable<ICommonSession> All()
{ {
return _admin.AllAdmins; return _admin.AllAdmins;
} }

View File

@@ -1,4 +1,3 @@
using System.Linq;
using Content.Server.Afk.Events; using Content.Server.Afk.Events;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Shared.CCVar; using Content.Shared.CCVar;
@@ -24,7 +23,7 @@ public sealed class AFKSystem : EntitySystem
private float _checkDelay; private float _checkDelay;
private TimeSpan _checkTime; private TimeSpan _checkTime;
private readonly HashSet<IPlayerSession> _afkPlayers = new(); private readonly HashSet<ICommonSession> _afkPlayers = new();
public override void Initialize() public override void Initialize()
{ {
@@ -73,11 +72,9 @@ public sealed class AFKSystem : EntitySystem
_checkTime = _timing.CurTime + TimeSpan.FromSeconds(_checkDelay); _checkTime = _timing.CurTime + TimeSpan.FromSeconds(_checkDelay);
foreach (var session in Filter.GetAllPlayers()) foreach (var pSession in Filter.GetAllPlayers())
{ {
if (session.Status != SessionStatus.InGame) continue; if (pSession.Status != SessionStatus.InGame) continue;
var pSession = (IPlayerSession) session;
var isAfk = _afkManager.IsAfk(pSession); var isAfk = _afkManager.IsAfk(pSession);
if (isAfk && _afkPlayers.Add(pSession)) if (isAfk && _afkPlayers.Add(pSession))

View File

@@ -5,6 +5,7 @@ using Robust.Shared.Configuration;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Player;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Server.Afk namespace Content.Server.Afk
@@ -20,13 +21,13 @@ namespace Content.Server.Afk
/// </summary> /// </summary>
/// <param name="player">The player to check.</param> /// <param name="player">The player to check.</param>
/// <returns>True if the player is AFK, false otherwise.</returns> /// <returns>True if the player is AFK, false otherwise.</returns>
bool IsAfk(IPlayerSession player); bool IsAfk(ICommonSession player);
/// <summary> /// <summary>
/// Resets AFK status for the player as if they just did an action and are definitely not AFK. /// Resets AFK status for the player as if they just did an action and are definitely not AFK.
/// </summary> /// </summary>
/// <param name="player">The player to set AFK status for.</param> /// <param name="player">The player to set AFK status for.</param>
void PlayerDidAction(IPlayerSession player); void PlayerDidAction(ICommonSession player);
void Initialize(); void Initialize();
} }
@@ -40,7 +41,7 @@ namespace Content.Server.Afk
[Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!; [Dependency] private readonly IConsoleHost _consoleHost = default!;
private readonly Dictionary<IPlayerSession, TimeSpan> _lastActionTimes = new(); private readonly Dictionary<ICommonSession, TimeSpan> _lastActionTimes = new();
public void Initialize() public void Initialize()
{ {
@@ -55,7 +56,7 @@ namespace Content.Server.Afk
HandleInputCmd); HandleInputCmd);
} }
public void PlayerDidAction(IPlayerSession player) public void PlayerDidAction(ICommonSession player)
{ {
if (player.Status == SessionStatus.Disconnected) if (player.Status == SessionStatus.Disconnected)
// Make sure we don't re-add to the dictionary if the player is disconnected now. // Make sure we don't re-add to the dictionary if the player is disconnected now.
@@ -64,7 +65,7 @@ namespace Content.Server.Afk
_lastActionTimes[player] = _gameTiming.RealTime; _lastActionTimes[player] = _gameTiming.RealTime;
} }
public bool IsAfk(IPlayerSession player) public bool IsAfk(ICommonSession player)
{ {
if (!_lastActionTimes.TryGetValue(player, out var time)) if (!_lastActionTimes.TryGetValue(player, out var time))
// Some weird edge case like disconnected clients. Just say true I guess. // Some weird edge case like disconnected clients. Just say true I guess.
@@ -87,13 +88,13 @@ namespace Content.Server.Afk
private void ConsoleHostOnAnyCommandExecuted(IConsoleShell shell, string commandname, string argstr, string[] args) private void ConsoleHostOnAnyCommandExecuted(IConsoleShell shell, string commandname, string argstr, string[] args)
{ {
if (shell.Player is IPlayerSession player) if (shell.Player is { } player)
PlayerDidAction(player); PlayerDidAction(player);
} }
private void HandleInputCmd(FullInputCmdMessage msg, EntitySessionEventArgs args) private void HandleInputCmd(FullInputCmdMessage msg, EntitySessionEventArgs args)
{ {
PlayerDidAction((IPlayerSession) args.SenderSession); PlayerDidAction(args.SenderSession);
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using Robust.Server.Player; using Robust.Shared.Player;
namespace Content.Server.Afk.Events; namespace Content.Server.Afk.Events;
@@ -8,9 +8,9 @@ namespace Content.Server.Afk.Events;
[ByRefEvent] [ByRefEvent]
public readonly struct AFKEvent public readonly struct AFKEvent
{ {
public readonly IPlayerSession Session; public readonly ICommonSession Session;
public AFKEvent(IPlayerSession playerSession) public AFKEvent(ICommonSession playerSession)
{ {
Session = playerSession; Session = playerSession;
} }

View File

@@ -1,4 +1,4 @@
using Robust.Server.Player; using Robust.Shared.Player;
namespace Content.Server.Afk.Events; namespace Content.Server.Afk.Events;
@@ -8,9 +8,9 @@ namespace Content.Server.Afk.Events;
[ByRefEvent] [ByRefEvent]
public readonly struct UnAFKEvent public readonly struct UnAFKEvent
{ {
public readonly IPlayerSession Session; public readonly ICommonSession Session;
public UnAFKEvent(IPlayerSession playerSession) public UnAFKEvent(ICommonSession playerSession)
{ {
Session = playerSession; Session = playerSession;
} }

View File

@@ -2,7 +2,6 @@ using Content.Server.Administration;
using Content.Server.Commands; using Content.Server.Commands;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Alert; using Content.Shared.Alert;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Alert.Commands namespace Content.Server.Alert.Commands
@@ -16,7 +15,7 @@ namespace Content.Server.Alert.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player?.AttachedEntity == null) if (player?.AttachedEntity == null)
{ {
shell.WriteLine("You don't have an entity."); shell.WriteLine("You don't have an entity.");

View File

@@ -2,7 +2,6 @@ using Content.Server.Administration;
using Content.Server.Commands; using Content.Server.Commands;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Alert; using Content.Shared.Alert;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Alert.Commands namespace Content.Server.Alert.Commands
@@ -16,7 +15,7 @@ namespace Content.Server.Alert.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player?.AttachedEntity == null) if (player?.AttachedEntity == null)
{ {
shell.WriteLine("You cannot run this from the server or without an attached entity."); shell.WriteLine("You cannot run this from the server or without an attached entity.");

View File

@@ -3,7 +3,6 @@ using Content.Server.Administration;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Shared.Administration; using Content.Shared.Administration;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.AlertLevel.Commands namespace Content.Server.AlertLevel.Commands
@@ -19,7 +18,7 @@ namespace Content.Server.AlertLevel.Commands
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{ {
var levelNames = new string[] {}; var levelNames = new string[] {};
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player?.AttachedEntity != null) if (player?.AttachedEntity != null)
{ {
var stationUid = EntitySystem.Get<StationSystem>().GetOwningStation(player.AttachedEntity.Value); var stationUid = EntitySystem.Get<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
@@ -54,7 +53,7 @@ namespace Content.Server.AlertLevel.Commands
return; return;
} }
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player?.AttachedEntity == null) if (player?.AttachedEntity == null)
{ {
shell.WriteLine(Loc.GetString("shell-only-players-can-run-this-command")); shell.WriteLine(Loc.GetString("shell-only-players-can-run-this-command"));

View File

@@ -22,6 +22,7 @@ using Content.Server.Station.Systems;
using Content.Server.Shuttles.Systems; using Content.Server.Shuttles.Systems;
using Content.Shared.Mobs; using Content.Shared.Mobs;
using Robust.Server.Containers; using Robust.Server.Containers;
using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.Antag; namespace Content.Server.Antag;
@@ -88,9 +89,9 @@ public sealed class AntagSelectionSystem : GameRuleSystem<GameRuleComponent>
out List<EntityUid> chosen, out List<EntityUid> chosen,
bool includeHeads = false) bool includeHeads = false)
{ {
var allPlayers = _playerSystem.ServerSessions.ToList(); var allPlayers = _playerSystem.Sessions.ToList();
var playerList = new List<IPlayerSession>(); var playerList = new List<ICommonSession>();
var prefList = new List<IPlayerSession>(); var prefList = new List<ICommonSession>();
chosen = new List<EntityUid>(); chosen = new List<EntityUid>();
foreach (var player in allPlayers) foreach (var player in allPlayers)
{ {
@@ -116,7 +117,7 @@ public sealed class AntagSelectionSystem : GameRuleSystem<GameRuleComponent>
var antags = Math.Clamp(allPlayers.Count / antagsPerPlayer, 1, maxAntags); var antags = Math.Clamp(allPlayers.Count / antagsPerPlayer, 1, maxAntags);
for (var antag = 0; antag < antags; antag++) for (var antag = 0; antag < antags; antag++)
{ {
IPlayerSession chosenPlayer = null!; ICommonSession? chosenPlayer = null;
if (prefList.Count == 0) if (prefList.Count == 0)
{ {
if (playerList.Count == 0) if (playerList.Count == 0)

View File

@@ -1,6 +1,6 @@
using Content.Shared.Arcade; using Content.Shared.Arcade;
using Robust.Server.Player;
using System.Linq; using System.Linq;
using Robust.Shared.Player;
namespace Content.Server.Arcade.BlockGame; namespace Content.Server.Arcade.BlockGame;
@@ -166,7 +166,7 @@ public sealed partial class BlockGame
/// </summary> /// </summary>
/// <param name="message">The message to send to a specific player/spectator.</param> /// <param name="message">The message to send to a specific player/spectator.</param>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void SendMessage(BoundUserInterfaceMessage message, IPlayerSession session) private void SendMessage(BoundUserInterfaceMessage message, ICommonSession session)
{ {
if (_uiSystem.TryGetUi(_owner, BlockGameUiKey.Key, out var bui)) if (_uiSystem.TryGetUi(_owner, BlockGameUiKey.Key, out var bui))
_uiSystem.TrySendUiMessage(bui, message, session); _uiSystem.TrySendUiMessage(bui, message, session);
@@ -176,7 +176,7 @@ public sealed partial class BlockGame
/// Handles sending the current state of the game to a player that has just opened the UI. /// Handles sending the current state of the game to a player that has just opened the UI.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
public void UpdateNewPlayerUI(IPlayerSession session) public void UpdateNewPlayerUI(ICommonSession session)
{ {
if (_gameOver) if (_gameOver)
{ {
@@ -209,7 +209,7 @@ public sealed partial class BlockGame
/// Handles broadcasting the full player-visible game state to a specific player/spectator. /// Handles broadcasting the full player-visible game state to a specific player/spectator.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void FullUpdate(IPlayerSession session) private void FullUpdate(ICommonSession session)
{ {
UpdateFieldUI(session); UpdateFieldUI(session);
SendNextPieceUpdate(session); SendNextPieceUpdate(session);
@@ -235,7 +235,7 @@ public sealed partial class BlockGame
/// Handles broadcasting the current location of all of the blocks in the playfield + the active piece to a specific player/spectator. /// Handles broadcasting the current location of all of the blocks in the playfield + the active piece to a specific player/spectator.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
public void UpdateFieldUI(IPlayerSession session) public void UpdateFieldUI(ICommonSession session)
{ {
if (!Started) if (!Started)
return; return;
@@ -283,7 +283,7 @@ public sealed partial class BlockGame
/// Broadcasts the state of the next queued piece to a specific viewer. /// Broadcasts the state of the next queued piece to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void SendNextPieceUpdate(IPlayerSession session) private void SendNextPieceUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(NextPiece.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.NextBlock), session); SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(NextPiece.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.NextBlock), session);
} }
@@ -303,7 +303,7 @@ public sealed partial class BlockGame
/// Broadcasts the state of the currently held piece to a specific viewer. /// Broadcasts the state of the currently held piece to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void SendHoldPieceUpdate(IPlayerSession session) private void SendHoldPieceUpdate(ICommonSession session)
{ {
if (HeldPiece.HasValue) if (HeldPiece.HasValue)
SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(HeldPiece.Value.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.HoldBlock), session); SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(HeldPiece.Value.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.HoldBlock), session);
@@ -323,7 +323,7 @@ public sealed partial class BlockGame
/// Broadcasts the current game level to a specific viewer. /// Broadcasts the current game level to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void SendLevelUpdate(IPlayerSession session) private void SendLevelUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameLevelUpdateMessage(Level), session); SendMessage(new BlockGameMessages.BlockGameLevelUpdateMessage(Level), session);
} }
@@ -340,7 +340,7 @@ public sealed partial class BlockGame
/// Broadcasts the current game score to a specific viewer. /// Broadcasts the current game score to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void SendPointsUpdate(IPlayerSession session) private void SendPointsUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameScoreUpdateMessage(Points), session); SendMessage(new BlockGameMessages.BlockGameScoreUpdateMessage(Points), session);
} }
@@ -357,7 +357,7 @@ public sealed partial class BlockGame
/// Broadcasts the current game high score positions to a specific viewer. /// Broadcasts the current game high score positions to a specific viewer.
/// </summary> /// </summary>
/// <param name="session">The target recipient.</param> /// <param name="session">The target recipient.</param>
private void SendHighscoreUpdate(IPlayerSession session) private void SendHighscoreUpdate(ICommonSession session)
{ {
SendMessage(new BlockGameMessages.BlockGameHighScoreUpdateMessage(_arcadeSystem.GetLocalHighscores(), _arcadeSystem.GetGlobalHighscores()), session); SendMessage(new BlockGameMessages.BlockGameHighScoreUpdateMessage(_arcadeSystem.GetLocalHighscores(), _arcadeSystem.GetGlobalHighscores()), session);
} }

View File

@@ -1,4 +1,4 @@
using Robust.Server.Player; using Robust.Shared.Player;
namespace Content.Server.Arcade.BlockGame; namespace Content.Server.Arcade.BlockGame;
@@ -13,10 +13,10 @@ public sealed partial class BlockGameArcadeComponent : Component
/// <summary> /// <summary>
/// The player currently playing the active session of NT-BG. /// The player currently playing the active session of NT-BG.
/// </summary> /// </summary>
public IPlayerSession? Player = null; public ICommonSession? Player = null;
/// <summary> /// <summary>
/// The players currently viewing (but not playing) the active session of NT-BG. /// The players currently viewing (but not playing) the active session of NT-BG.
/// </summary> /// </summary>
public readonly List<IPlayerSession> Spectators = new(); public readonly List<ICommonSession> Spectators = new();
} }

View File

@@ -2,7 +2,7 @@ using Content.Server.Power.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.Arcade; using Content.Shared.Arcade;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Shared.Player;
namespace Content.Server.Arcade.BlockGame; namespace Content.Server.Arcade.BlockGame;
@@ -30,7 +30,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
} }
} }
private void UpdatePlayerStatus(EntityUid uid, IPlayerSession session, PlayerBoundUserInterface? bui = null, BlockGameArcadeComponent? blockGame = null) private void UpdatePlayerStatus(EntityUid uid, ICommonSession session, PlayerBoundUserInterface? bui = null, BlockGameArcadeComponent? blockGame = null)
{ {
if (!Resolve(uid, ref blockGame)) if (!Resolve(uid, ref blockGame))
return; return;
@@ -67,7 +67,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args) private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args)
{ {
if (args.Session is not IPlayerSession session) if (args.Session is not { } session)
return; return;
if (component.Player != session) if (component.Player != session)

View File

@@ -2,7 +2,6 @@ using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -20,7 +19,7 @@ namespace Content.Server.Atmos.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
EntityUid? gridId; EntityUid? gridId;
Gas? gas = null; Gas? gas = null;

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.Atmos.Commands namespace Content.Server.Atmos.Commands
@@ -15,7 +14,7 @@ namespace Content.Server.Atmos.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; var player = shell.Player;
if (player == null) if (player == null)
{ {
shell.WriteLine("You must be a player to use this command."); shell.WriteLine("You must be a player to use this command.");

View File

@@ -10,6 +10,7 @@ using Robust.Shared.Configuration;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Player;
namespace Content.Server.Atmos.EntitySystems namespace Content.Server.Atmos.EntitySystems
{ {
@@ -27,7 +28,7 @@ namespace Content.Server.Atmos.EntitySystems
/// To modify it see <see cref="AddObserver"/> and /// To modify it see <see cref="AddObserver"/> and
/// <see cref="RemoveObserver"/>. /// <see cref="RemoveObserver"/>.
/// </summary> /// </summary>
private readonly HashSet<IPlayerSession> _playerObservers = new(); private readonly HashSet<ICommonSession> _playerObservers = new();
/// <summary> /// <summary>
/// Overlay update ticks per second. /// Overlay update ticks per second.
@@ -48,17 +49,17 @@ namespace Content.Server.Atmos.EntitySystems
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged; _playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
} }
public bool AddObserver(IPlayerSession observer) public bool AddObserver(ICommonSession observer)
{ {
return _playerObservers.Add(observer); return _playerObservers.Add(observer);
} }
public bool HasObserver(IPlayerSession observer) public bool HasObserver(ICommonSession observer)
{ {
return _playerObservers.Contains(observer); return _playerObservers.Contains(observer);
} }
public bool RemoveObserver(IPlayerSession observer) public bool RemoveObserver(ICommonSession observer)
{ {
if (!_playerObservers.Remove(observer)) if (!_playerObservers.Remove(observer))
{ {
@@ -76,7 +77,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary> /// </summary>
/// <param name="observer">The observer to toggle.</param> /// <param name="observer">The observer to toggle.</param>
/// <returns>true if added, false if removed.</returns> /// <returns>true if added, false if removed.</returns>
public bool ToggleObserver(IPlayerSession observer) public bool ToggleObserver(ICommonSession observer)
{ {
if (HasObserver(observer)) if (HasObserver(observer))
{ {

View File

@@ -12,7 +12,6 @@ using Content.Shared.Toggleable;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
@@ -60,12 +59,6 @@ namespace Content.Server.Atmos.EntitySystems
private void OnGasTankToggleInternals(Entity<GasTankComponent> ent, ref GasTankToggleInternalsMessage args) private void OnGasTankToggleInternals(Entity<GasTankComponent> ent, ref GasTankToggleInternalsMessage args)
{ {
if (args.Session is not IPlayerSession playerSession ||
playerSession.AttachedEntity == null)
{
return;
}
ToggleInternals(ent); ToggleInternals(ent);
} }

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