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

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Prototypes;
@@ -22,8 +21,8 @@ public sealed class ClientAlertsSystem : AlertsSystem
{
base.Initialize();
SubscribeLocalEvent<AlertsComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<AlertsComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<AlertsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<AlertsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<AlertsComponent, AfterAutoHandleStateEvent>(ClientAlertsHandleState);
}
@@ -69,7 +68,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
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)
return;
@@ -87,7 +86,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
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);
}

View File

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

View File

@@ -38,7 +38,7 @@ namespace Content.Client.Construction
base.Initialize();
UpdatesOutsidePrediction = true;
SubscribeLocalEvent<PlayerAttachSysMessage>(HandlePlayerAttached);
SubscribeLocalEvent<LocalPlayerAttachedEvent>(HandlePlayerAttached);
SubscribeNetworkEvent<AckStructureConstructionMessage>(HandleAckStructure);
SubscribeNetworkEvent<ResponseConstructionGuide>(OnConstructionGuideReceived);
@@ -110,9 +110,9 @@ namespace Content.Client.Construction
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);
}

View File

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

View File

@@ -1,5 +1,4 @@
using Content.Shared.Drunk;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
@@ -19,18 +18,18 @@ public sealed class DrunkSystem : SharedDrunkSystem
SubscribeLocalEvent<DrunkComponent, ComponentInit>(OnDrunkInit);
SubscribeLocalEvent<DrunkComponent, ComponentShutdown>(OnDrunkShutdown);
SubscribeLocalEvent<DrunkComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<DrunkComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<DrunkComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<DrunkComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
_overlay = new();
}
private void OnPlayerAttached(EntityUid uid, DrunkComponent component, PlayerAttachedEvent args)
private void OnPlayerAttached(EntityUid uid, DrunkComponent component, LocalPlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}
private void OnPlayerDetached(EntityUid uid, DrunkComponent component, PlayerDetachedEvent args)
private void OnPlayerDetached(EntityUid uid, DrunkComponent component, LocalPlayerDetachedEvent args)
{
_overlay.CurrentBoozePower = 0;
_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.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.GameTicking;
using Robust.Shared.GameObjects;
using Robust.Shared.Network;
namespace Content.Client.Eye.Blinding;
@@ -31,20 +21,20 @@ public sealed class BlindingSystem : EntitySystem
SubscribeLocalEvent<BlindableComponent, ComponentInit>(OnBlindInit);
SubscribeLocalEvent<BlindableComponent, ComponentShutdown>(OnBlindShutdown);
SubscribeLocalEvent<BlindableComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<BlindableComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<BlindableComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<BlindableComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
_overlay = new();
}
private void OnPlayerAttached(EntityUid uid, BlindableComponent component, PlayerAttachedEvent args)
private void OnPlayerAttached(EntityUid uid, BlindableComponent component, LocalPlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}
private void OnPlayerDetached(EntityUid uid, BlindableComponent component, PlayerDetachedEvent args)
private void OnPlayerDetached(EntityUid uid, BlindableComponent component, LocalPlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
_lightManager.Enabled = true;

View File

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

View File

@@ -30,7 +30,7 @@ public sealed class EyeLerpingSystem : EntitySystem
SubscribeLocalEvent<EyeAttachedEvent>(OnAttached);
SubscribeLocalEvent<LerpingEyeComponent, EntParentChangedMessage>(HandleMapChange);
SubscribeLocalEvent<LerpingEyeComponent, PlayerDetachedEvent>(OnDetached);
SubscribeLocalEvent<LerpingEyeComponent, LocalPlayerDetachedEvent>(OnDetached);
UpdatesAfter.Add(typeof(TransformSystem));
UpdatesAfter.Add(typeof(PhysicsSystem));
@@ -94,7 +94,7 @@ public sealed class EyeLerpingSystem : EntitySystem
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)
RemCompDeferred(uid, component);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Pulling.Components;
using Robust.Client.GameObjects;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Shared.Physics.Components;
@@ -17,10 +16,10 @@ namespace Content.Client.Physics.Controllers
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RelayInputMoverComponent, PlayerAttachedEvent>(OnRelayPlayerAttached);
SubscribeLocalEvent<RelayInputMoverComponent, PlayerDetachedEvent>(OnRelayPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InputMoverComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerAttachedEvent>(OnRelayPlayerAttached);
SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerDetachedEvent>(OnRelayPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InputMoverComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
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?
}
private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, PlayerAttachedEvent args)
private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, LocalPlayerAttachedEvent args)
{
Physics.UpdateIsPredicted(uid);
Physics.UpdateIsPredicted(component.RelayEntity);
@@ -62,7 +61,7 @@ namespace Content.Client.Physics.Controllers
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(component.RelayEntity);
@@ -70,12 +69,12 @@ namespace Content.Client.Physics.Controllers
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);
}
private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, PlayerDetachedEvent args)
private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, LocalPlayerDetachedEvent args)
{
SetMoveInput(component, MoveButtons.None);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,6 @@
using System.Numerics;
using Content.Shared.Traits.Assorted;
using Content.Client.Camera;
using Robust.Shared.Random;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Timing;
@@ -19,7 +17,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem
{
base.Initialize();
SubscribeLocalEvent<ParacusiaComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<ParacusiaComponent, PlayerDetachedEvent>(OnPlayerDetach);
SubscribeLocalEvent<ParacusiaComponent, LocalPlayerDetachedEvent>(OnPlayerDetach);
}
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));
}
private void OnPlayerDetach(EntityUid uid, ParacusiaComponent component, PlayerDetachedEvent args)
private void OnPlayerDetach(EntityUid uid, ParacusiaComponent component, LocalPlayerDetachedEvent args)
{
component.Stream?.Stop();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,13 +3,11 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Content.Server.GameTicking;
using Content.Server.Players;
using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.UnitTesting;
@@ -30,8 +28,8 @@ public sealed partial class TestPair
public RobustIntegrationTest.ServerIntegrationInstance Server { get; private set; } = default!;
public RobustIntegrationTest.ClientIntegrationInstance Client { get; private set; } = default!;
public IPlayerSession? Player => (IPlayerSession?) Server.PlayerMan.Sessions.FirstOrDefault();
public PlayerData? PlayerData => Player?.Data.ContentData();
public ICommonSession? Player => Server.PlayerMan.Sessions.FirstOrDefault();
public ContentPlayerData? PlayerData => Player?.Data.ContentData();
public PoolTestLogHandler ServerLogHandler { 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 Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using PlayerManager = Robust.Client.Player.PlayerManager;
namespace Content.IntegrationTests.Tests.Actions;
@@ -26,7 +24,7 @@ public sealed class ActionsAddedTest
var sEntMan = server.ResolveDependency<IEntityManager>();
var cEntMan = client.ResolveDependency<IEntityManager>();
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 cActionSystem = client.System<SharedActionsSystem>();

View File

@@ -7,8 +7,6 @@ using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Utility;
namespace Content.IntegrationTests.Tests.Administration.Logs;
@@ -177,7 +175,7 @@ public sealed class AddTests
await server.WaitPost(() =>
{
var player = sPlayers.ServerSessions.First();
var player = sPlayers.Sessions.First();
playerGuid = player.UserId;
Assert.DoesNotThrow(() =>
@@ -280,7 +278,7 @@ public sealed class AddTests
await server.WaitPost(() =>
{
var player = sPlayers.ServerSessions.Single();
var player = sPlayers.Sessions.Single();
sAdminLogSystem.Add(LogType.Unknown, $"{player} {player} test log: {guid}");
});
@@ -318,7 +316,7 @@ public sealed class AddTests
await server.WaitPost(() =>
{
var player = sPlayers.ServerSessions.Single();
var player = sPlayers.Sessions.Single();
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 Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
namespace Content.IntegrationTests.Tests.Administration.Logs;
@@ -27,11 +28,11 @@ public sealed class QueryTests
var date = DateTime.UtcNow;
var guid = Guid.NewGuid();
IPlayerSession player = default;
ICommonSession player = default;
await server.WaitPost(() =>
{
player = sPlayers.ServerSessions.First();
player = sPlayers.Sessions.First();
sAdminLogSystem.Add(LogType.Unknown, $"{player.AttachedEntity:Entity} test log: {guid}");
});

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,17 @@
using System.Linq;
using Content.IntegrationTests.Pair;
using Content.Server.Mind;
using Content.Server.Players;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Player;
namespace Content.IntegrationTests.Tests.Minds;
@@ -36,7 +39,7 @@ public sealed partial class MindTests
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var mindSys = entMan.System<SharedMindSystem>();
var player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
EntityUid entity = default;
EntityUid mindId = default!;
@@ -71,7 +74,7 @@ public sealed partial class MindTests
EntityUid mindId = default!;
MindComponent mind = default!;
var player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
await pair.Server.WaitAssertion(() =>
{
var oldUid = player.AttachedEntity;
@@ -116,20 +119,25 @@ public sealed partial class MindTests
/// </summary>
private static (EntityUid Id, MindComponent Comp) GetMind(Pair.TestPair pair)
{
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var entMan = pair.Server.ResolveDependency<IEntityManager>();
var player = playerMan.ServerSessions.SingleOrDefault();
var playerMan = pair.Server.PlayerMan;
var entMan = pair.Server.EntMan;
var player = playerMan.Sessions.SingleOrDefault();
Assert.That(player, Is.Not.Null);
var mindId = player.ContentData()!.Mind!.Value;
Assert.That(mindId, Is.Not.EqualTo(default(EntityUid)));
var mind = entMan.GetComponent<MindComponent>(mindId);
ActorComponent actor = default!;
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(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(entMan.TryGetComponent(mind.CurrentEntity, out actor));
});
Assert.That(actor.PlayerSession, Is.EqualTo(mind.Session));
return (mindId, mind);
}
@@ -139,7 +147,7 @@ public sealed partial class MindTests
var netManager = pair.Client.ResolveDependency<IClientNetManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var entMan = pair.Server.ResolveDependency<IEntityManager>();
var player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
var mindId = player.ContentData()!.Mind!.Value;
var mind = entMan.GetComponent<MindComponent>(mindId);
@@ -161,21 +169,21 @@ public sealed partial class MindTests
{
var netManager = pair.Client.ResolveDependency<IClientNetManager>();
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());
pair.Client.SetConnectTarget(pair.Server);
await pair.Client.WaitPost(() => netManager.ClientConnect(null!, 0, username));
await pair.RunTicksSync(5);
var player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
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 player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
var name = player.Name;
var id = player.UserId;
@@ -183,7 +191,7 @@ public sealed partial class MindTests
await Connect(pair, name);
// Session has changed
var newSession = playerMan.ServerSessions.Single();
var newSession = playerMan.Sessions.Single();
Assert.Multiple(() =>
{
Assert.That(newSession, Is.Not.EqualTo(player));

View File

@@ -1,6 +1,8 @@
using System.Linq;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using NUnit.Framework.Interfaces;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
@@ -49,7 +51,7 @@ public sealed partial class MindTests
var mind = GetMind(pair);
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
var name = player.Name;
var user = player.UserId;
Assert.That(mind.Comp.OwnedEntity, Is.Not.Null);
@@ -72,7 +74,7 @@ public sealed partial class MindTests
// Reconnect
await Connect(pair, name);
player = playerMan.ServerSessions.Single();
player = playerMan.Sessions.Single();
Assert.Multiple(() =>
{
Assert.That(user, Is.EqualTo(player.UserId));
@@ -127,8 +129,10 @@ public sealed partial class MindTests
var mindSys = entMan.System<SharedMindSystem>();
var mind = GetMind(pair);
Assert.Null(mind.Comp.VisitingEntity);
// Make player visit a new mob
var original = mind.Comp.CurrentEntity;
var original = mind.Comp.OwnedEntity;
EntityUid visiting = default;
await pair.Server.WaitAssertion(() =>
{
@@ -137,6 +141,7 @@ public sealed partial class MindTests
});
await pair.RunTicksSync(5);
Assert.That(mind.Comp.VisitingEntity, Is.EqualTo(visiting));
await DisconnectReconnect(pair);
// Player is back in control of the visited mob, mind was preserved
@@ -150,4 +155,32 @@ public sealed partial class MindTests
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.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Players;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Robust.Server.Console;
@@ -345,7 +346,7 @@ public sealed partial class MindTests
EntityUid entity = default!;
EntityUid mindId = default!;
MindComponent mind = default!;
var player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
await server.WaitAssertion(() =>
{
@@ -406,12 +407,6 @@ public sealed partial class MindTests
await pair.CleanReturnAsync();
}
// TODO Implement
/*[Test]
public async Task TestPlayerCanReturnFromGhostWhenDead()
{
}*/
[Test]
public async Task TestGhostDoesNotInfiniteLoop()
{
@@ -432,7 +427,7 @@ public sealed partial class MindTests
EntityUid ghost = default!;
EntityUid mindId = default!;
MindComponent mind = default!;
var player = playerMan.ServerSessions.Single();
var player = playerMan.Sessions.Single();
await server.WaitAssertion(() =>
{

View File

@@ -2,8 +2,7 @@
using System.Collections.Generic;
using Content.IntegrationTests.Pair;
using Content.Server.Administration.Managers;
using Robust.Server.Player;
using Robust.Shared.Players;
using Robust.Shared.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Toolshed.Syntax;
@@ -60,7 +59,7 @@ public abstract class ToolshedTest : IInvocationContext
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);
}
@@ -95,7 +94,7 @@ public abstract class ToolshedTest : IInvocationContext
return true;
}
protected IPlayerSession? InvocationSession { get; set; }
protected ICommonSession? InvocationSession { get; set; }
public ICommonSession? Session
{

View File

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

View File

@@ -1,5 +1,5 @@
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Player;
namespace Content.Server.Administration
{
@@ -8,7 +8,7 @@ namespace Content.Server.Administration
/// </summary>
public sealed class AdminPermsChangedEventArgs : EventArgs
{
public AdminPermsChangedEventArgs(IPlayerSession player, AdminFlags? flags)
public AdminPermsChangedEventArgs(ICommonSession player, AdminFlags? flags)
{
Player = player;
Flags = flags;
@@ -17,7 +17,7 @@ namespace Content.Server.Administration
/// <summary>
/// The player that had their admin permissions changed.
/// </summary>
public IPlayerSession Player { get; }
public ICommonSession Player { get; }
/// <summary>
/// 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.Ghost;
using Content.Shared.Mind;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
@@ -18,7 +17,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player == null)
{
shell.WriteLine("Nah");

View File

@@ -2,7 +2,6 @@
using Content.Server.Administration.Managers;
using Content.Server.Afk;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Utility;
@@ -35,7 +34,7 @@ public sealed class AdminWhoCommand : IConsoleCommand
if (adminData.Title is { } 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))
sb.Append(" [AFK]");

View File

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

View File

@@ -1,15 +1,8 @@
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
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.CCVar;
using Content.Shared.Database;
using Content.Shared.Players.PlayTimeTracking;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
@@ -84,7 +77,7 @@ public sealed class BanCommand : LocalizedCommands
}
var located = await _locator.LookupIdByNameOrIdAsync(target);
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (located == null)
{
@@ -102,7 +95,7 @@ public sealed class BanCommand : LocalizedCommands
{
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"));
}

View File

@@ -36,7 +36,7 @@ public sealed class BanListCommand : LocalizedCommands
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);
@@ -67,7 +67,7 @@ public sealed class BanListCommand : LocalizedCommands
return CompletionResult.Empty;
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"));
}
}

View File

@@ -1,12 +1,6 @@
using Content.Shared.Administration;
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 Robust.Server.Player;
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)
{
if (shell.Player is not IPlayerSession player)
if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("cmd-banpanel-server"));
return;

View File

@@ -1,6 +1,5 @@
using Content.Server.Mind;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
@@ -16,7 +15,7 @@ namespace Content.Server.Administration.Commands
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");
return;

View File

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

View File

@@ -1,10 +1,8 @@
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
{
[UsedImplicitly]
@@ -17,7 +15,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player == null)
{
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.Shared.Administration;
using Content.Shared.Explosion;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
@@ -21,7 +20,7 @@ public sealed class OpenExplosionEui : IConsoleCommand
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player == null)
{
shell.WriteError("This does not work from the server console.");

View File

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

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration.Logs;
using Content.Server.EUI;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
@@ -15,7 +14,7 @@ public sealed class OpenAdminLogsCommand : IConsoleCommand
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.");
return;

View File

@@ -1,7 +1,5 @@
using Content.Server.Administration.Notes;
using Content.Server.Database;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
@@ -17,7 +15,7 @@ public sealed class OpenAdminNotesCommand : IConsoleCommand
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.");
return;

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
using System.Text;
using Content.Server.Database;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
@@ -15,7 +14,7 @@ namespace Content.Server.Administration.Commands
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>();
if (args.Length != 1)

View File

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

View File

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

View File

@@ -1,8 +1,6 @@
using Content.Server.Database;
using Content.Server.Preferences.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
@@ -16,7 +14,7 @@ namespace Content.Server.Administration.Commands
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"));
return;

View File

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

View File

@@ -10,7 +10,6 @@ using Content.Shared.PDA;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
@@ -57,7 +56,7 @@ namespace Content.Server.Administration.Commands
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"));
return;

View File

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

View File

@@ -1,8 +1,8 @@
using Content.Server.Database;
using Content.Shared.CCVar;
using Robust.Server.Player;
using Robust.Server.Upload;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Robust.Shared.Upload;
namespace Content.Server.Administration;
@@ -22,7 +22,7 @@ public sealed class ContentNetworkResourceManager
_netRes.OnResourceUploaded += OnUploadResource;
}
private async void OnUploadResource(IPlayerSession session, NetworkResourceUploadMessage msg)
private async void OnUploadResource(ICommonSession session, NetworkResourceUploadMessage msg)
{
if (StoreUploaded)
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 Content.Server.Administration.Logs.Converters;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Map;
using Robust.Shared.Player;
namespace Content.Server.Administration.Logs;
@@ -44,7 +44,7 @@ public sealed partial class AdminLogManager
var value = properties[key];
value = value switch
{
IPlayerSession player => new SerializablePlayer(player),
ICommonSession player => new SerializablePlayer(player),
EntityCoordinates entityCoordinates => new SerializableEntityCoordinates(_entityManager, entityCoordinates),
_ => value
};
@@ -56,7 +56,7 @@ public sealed partial class AdminLogManager
{
EntityUid id => id,
EntityStringRepresentation rep => rep.Uid,
IPlayerSession {AttachedEntity: {Valid: true}} session => session.AttachedEntity,
ICommonSession {AttachedEntity: {Valid: true}} session => session.AttachedEntity,
IComponent component => component.Owner,
_ => null
};

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,8 +2,8 @@ using System.Collections.Immutable;
using System.Net;
using System.Threading.Tasks;
using Content.Shared.Database;
using Robust.Server.Player;
using Robust.Shared.Network;
using Robust.Shared.Player;
namespace Content.Server.Administration.Managers;
@@ -55,5 +55,5 @@ public interface IBanManager
/// Sends role bans to the target
/// </summary>
/// <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 Robust.Shared.Configuration;
using Robust.Shared.Network;
using Robust.Shared.Players;
using Robust.Shared.Player;
namespace Content.Server.Administration.Notes;

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Player;
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>
/// <typeparam name="T1">Type of the input.</typeparam>
[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)
{
OpenDialogInternal(
@@ -53,7 +53,7 @@ public sealed partial class QuickDialogSystem
/// <typeparam name="T1">Type of the first input.</typeparam>
/// <typeparam name="T2">Type of the second input.</typeparam>
[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)
{
OpenDialogInternal(
@@ -96,7 +96,7 @@ public sealed partial class QuickDialogSystem
/// <typeparam name="T2">Type of the second input.</typeparam>
/// <typeparam name="T3">Type of the third input.</typeparam>
[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)
{
OpenDialogInternal(
@@ -142,7 +142,7 @@ public sealed partial class QuickDialogSystem
/// <typeparam name="T3">Type of the third input.</typeparam>
/// <typeparam name="T4">Type of the fourth input.</typeparam>
[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)
{
OpenDialogInternal(

View File

@@ -1,12 +1,9 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Administration;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Robust.Server.Player;
using Robust.Shared.Enums;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Serialization.TypeSerializers.Interfaces;
namespace Content.Server.Administration;
@@ -87,7 +84,7 @@ public sealed partial class QuickDialogSystem : EntitySystem
_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();
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);
@@ -203,7 +203,7 @@ namespace Content.Server.Administration.Systems
UpdatePanicBunker();
}
private void SendFullPlayerList(IPlayerSession playerSession)
private void SendFullPlayerList(ICommonSession playerSession)
{
var ev = new FullPlayerListEvent();
@@ -212,7 +212,7 @@ namespace Content.Server.Administration.Systems
RaiseNetworkEvent(ev, playerSession.ConnectedClient);
}
private PlayerInfo GetPlayerInfo(IPlayerData data, IPlayerSession? session)
private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session)
{
var name = data.UserName;
var entityName = string.Empty;
@@ -326,7 +326,7 @@ namespace Content.Server.Administration.Systems
/// chat messages and showing a popup to other players.
/// Their items are dropped on the ground.
/// </summary>
public void Erase(IPlayerSession player)
public void Erase(ICommonSession player)
{
var entity = player.AttachedEntity;
_chat.DeleteMessagesBy(player);

View File

@@ -1,8 +1,8 @@
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Network;
using Robust.Shared.Player;
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?> 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))
{

View File

@@ -24,11 +24,10 @@ using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Server.Console;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Players;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
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)
return;

View File

@@ -17,6 +17,7 @@ using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -119,7 +120,7 @@ namespace Content.Server.Administration.Systems
_typingUpdateTimestamps[args.SenderSession.UserId] = (_timing.RealTime, msg.Typing);
// 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 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)
{
base.OnBwoinkTextMessage(message, eventArgs);
var senderSession = (IPlayerSession) eventArgs.SenderSession;
var senderSession = eventArgs.SenderSession;
// TODO: Sanitize text?
// 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.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Player;
using Robust.Shared.Toolshed;
namespace Content.Server.Administration.Toolshed;
@@ -11,13 +11,13 @@ public sealed class AdminsCommand : ToolshedCommand
[Dependency] private readonly IAdminManager _admin = default!;
[CommandImplementation("active")]
public IEnumerable<IPlayerSession> Active()
public IEnumerable<ICommonSession> Active()
{
return _admin.ActiveAdmins;
}
[CommandImplementation("all")]
public IEnumerable<IPlayerSession> All()
public IEnumerable<ICommonSession> All()
{
return _admin.AllAdmins;
}

View File

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

View File

@@ -5,6 +5,7 @@ using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.Input;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Afk
@@ -20,13 +21,13 @@ namespace Content.Server.Afk
/// </summary>
/// <param name="player">The player to check.</param>
/// <returns>True if the player is AFK, false otherwise.</returns>
bool IsAfk(IPlayerSession player);
bool IsAfk(ICommonSession player);
/// <summary>
/// Resets AFK status for the player as if they just did an action and are definitely not AFK.
/// </summary>
/// <param name="player">The player to set AFK status for.</param>
void PlayerDidAction(IPlayerSession player);
void PlayerDidAction(ICommonSession player);
void Initialize();
}
@@ -40,7 +41,7 @@ namespace Content.Server.Afk
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!;
private readonly Dictionary<IPlayerSession, TimeSpan> _lastActionTimes = new();
private readonly Dictionary<ICommonSession, TimeSpan> _lastActionTimes = new();
public void Initialize()
{
@@ -55,7 +56,7 @@ namespace Content.Server.Afk
HandleInputCmd);
}
public void PlayerDidAction(IPlayerSession player)
public void PlayerDidAction(ICommonSession player)
{
if (player.Status == SessionStatus.Disconnected)
// 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;
}
public bool IsAfk(IPlayerSession player)
public bool IsAfk(ICommonSession player)
{
if (!_lastActionTimes.TryGetValue(player, out var time))
// 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)
{
if (shell.Player is IPlayerSession player)
if (shell.Player is { } player)
PlayerDidAction(player);
}
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;
@@ -8,9 +8,9 @@ namespace Content.Server.Afk.Events;
[ByRefEvent]
public readonly struct AFKEvent
{
public readonly IPlayerSession Session;
public readonly ICommonSession Session;
public AFKEvent(IPlayerSession playerSession)
public AFKEvent(ICommonSession playerSession)
{
Session = playerSession;
}

View File

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

View File

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

View File

@@ -2,7 +2,6 @@ using Content.Server.Administration;
using Content.Server.Commands;
using Content.Shared.Administration;
using Content.Shared.Alert;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Alert.Commands
@@ -16,7 +15,7 @@ namespace Content.Server.Alert.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player?.AttachedEntity == null)
{
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.Shared.Administration;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.AlertLevel.Commands
@@ -19,7 +18,7 @@ namespace Content.Server.AlertLevel.Commands
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
var levelNames = new string[] {};
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player?.AttachedEntity != null)
{
var stationUid = EntitySystem.Get<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
@@ -54,7 +53,7 @@ namespace Content.Server.AlertLevel.Commands
return;
}
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player?.AttachedEntity == null)
{
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.Shared.Mobs;
using Robust.Server.Containers;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Server.Antag;
@@ -88,9 +89,9 @@ public sealed class AntagSelectionSystem : GameRuleSystem<GameRuleComponent>
out List<EntityUid> chosen,
bool includeHeads = false)
{
var allPlayers = _playerSystem.ServerSessions.ToList();
var playerList = new List<IPlayerSession>();
var prefList = new List<IPlayerSession>();
var allPlayers = _playerSystem.Sessions.ToList();
var playerList = new List<ICommonSession>();
var prefList = new List<ICommonSession>();
chosen = new List<EntityUid>();
foreach (var player in allPlayers)
{
@@ -116,7 +117,7 @@ public sealed class AntagSelectionSystem : GameRuleSystem<GameRuleComponent>
var antags = Math.Clamp(allPlayers.Count / antagsPerPlayer, 1, maxAntags);
for (var antag = 0; antag < antags; antag++)
{
IPlayerSession chosenPlayer = null!;
ICommonSession? chosenPlayer = null;
if (prefList.Count == 0)
{
if (playerList.Count == 0)

View File

@@ -1,6 +1,6 @@
using Content.Shared.Arcade;
using Robust.Server.Player;
using System.Linq;
using Robust.Shared.Player;
namespace Content.Server.Arcade.BlockGame;
@@ -166,7 +166,7 @@ public sealed partial class BlockGame
/// </summary>
/// <param name="message">The message to send to a specific player/spectator.</param>
/// <param name="session">The target recipient.</param>
private void SendMessage(BoundUserInterfaceMessage message, IPlayerSession session)
private void SendMessage(BoundUserInterfaceMessage message, ICommonSession session)
{
if (_uiSystem.TryGetUi(_owner, BlockGameUiKey.Key, out var bui))
_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.
/// </summary>
/// <param name="session">The target recipient.</param>
public void UpdateNewPlayerUI(IPlayerSession session)
public void UpdateNewPlayerUI(ICommonSession session)
{
if (_gameOver)
{
@@ -209,7 +209,7 @@ public sealed partial class BlockGame
/// Handles broadcasting the full player-visible game state to a specific player/spectator.
/// </summary>
/// <param name="session">The target recipient.</param>
private void FullUpdate(IPlayerSession session)
private void FullUpdate(ICommonSession session)
{
UpdateFieldUI(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.
/// </summary>
/// <param name="session">The target recipient.</param>
public void UpdateFieldUI(IPlayerSession session)
public void UpdateFieldUI(ICommonSession session)
{
if (!Started)
return;
@@ -283,7 +283,7 @@ public sealed partial class BlockGame
/// Broadcasts the state of the next queued piece to a specific viewer.
/// </summary>
/// <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);
}
@@ -303,7 +303,7 @@ public sealed partial class BlockGame
/// Broadcasts the state of the currently held piece to a specific viewer.
/// </summary>
/// <param name="session">The target recipient.</param>
private void SendHoldPieceUpdate(IPlayerSession session)
private void SendHoldPieceUpdate(ICommonSession session)
{
if (HeldPiece.HasValue)
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.
/// </summary>
/// <param name="session">The target recipient.</param>
private void SendLevelUpdate(IPlayerSession session)
private void SendLevelUpdate(ICommonSession 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.
/// </summary>
/// <param name="session">The target recipient.</param>
private void SendPointsUpdate(IPlayerSession session)
private void SendPointsUpdate(ICommonSession 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.
/// </summary>
/// <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);
}

View File

@@ -1,4 +1,4 @@
using Robust.Server.Player;
using Robust.Shared.Player;
namespace Content.Server.Arcade.BlockGame;
@@ -13,10 +13,10 @@ public sealed partial class BlockGameArcadeComponent : Component
/// <summary>
/// The player currently playing the active session of NT-BG.
/// </summary>
public IPlayerSession? Player = null;
public ICommonSession? Player = null;
/// <summary>
/// The players currently viewing (but not playing) the active session of NT-BG.
/// </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.Shared.Arcade;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Player;
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))
return;
@@ -67,7 +67,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args)
{
if (args.Session is not IPlayerSession session)
if (args.Session is not { } session)
return;
if (component.Player != session)

View File

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

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Atmos.Commands
@@ -15,7 +14,7 @@ namespace Content.Server.Atmos.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var player = shell.Player;
if (player == null)
{
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.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Player;
namespace Content.Server.Atmos.EntitySystems
{
@@ -27,7 +28,7 @@ namespace Content.Server.Atmos.EntitySystems
/// To modify it see <see cref="AddObserver"/> and
/// <see cref="RemoveObserver"/>.
/// </summary>
private readonly HashSet<IPlayerSession> _playerObservers = new();
private readonly HashSet<ICommonSession> _playerObservers = new();
/// <summary>
/// Overlay update ticks per second.
@@ -48,17 +49,17 @@ namespace Content.Server.Atmos.EntitySystems
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
}
public bool AddObserver(IPlayerSession observer)
public bool AddObserver(ICommonSession observer)
{
return _playerObservers.Add(observer);
}
public bool HasObserver(IPlayerSession observer)
public bool HasObserver(ICommonSession observer)
{
return _playerObservers.Contains(observer);
}
public bool RemoveObserver(IPlayerSession observer)
public bool RemoveObserver(ICommonSession observer)
{
if (!_playerObservers.Remove(observer))
{
@@ -76,7 +77,7 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
/// <param name="observer">The observer to toggle.</param>
/// <returns>true if added, false if removed.</returns>
public bool ToggleObserver(IPlayerSession observer)
public bool ToggleObserver(ICommonSession observer)
{
if (HasObserver(observer))
{

View File

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

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