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;
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);
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();
}
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
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
{
using System.Linq;
using Content.Shared.Alert;
using JetBrains.Annotations;
-using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Prototypes;
{
base.Initialize();
- SubscribeLocalEvent<AlertsComponent, PlayerAttachedEvent>(OnPlayerAttached);
- SubscribeLocalEvent<AlertsComponent, PlayerDetachedEvent>(OnPlayerDetached);
+ SubscribeLocalEvent<AlertsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
+ SubscribeLocalEvent<AlertsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<AlertsComponent, AfterAutoHandleStateEvent>(ClientAlertsHandleState);
}
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;
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);
}
using Content.Shared.CharacterInfo;
using Content.Shared.Objectives;
-using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface;
[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);
}
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);
base.Initialize();
UpdatesOutsidePrediction = true;
- SubscribeLocalEvent<PlayerAttachSysMessage>(HandlePlayerAttached);
+ SubscribeLocalEvent<LocalPlayerAttachedEvent>(HandlePlayerAttached);
SubscribeNetworkEvent<AckStructureConstructionMessage>(HandleAckStructure);
SubscribeNetworkEvent<ResponseConstructionGuide>(OnConstructionGuideReceived);
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);
}
using Content.Shared.Drugs;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
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);
using Content.Shared.Drunk;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
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);
-
-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;
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;
-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;
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);
}
SubscribeLocalEvent<EyeAttachedEvent>(OnAttached);
SubscribeLocalEvent<LerpingEyeComponent, EntParentChangedMessage>(HandleMapChange);
- SubscribeLocalEvent<LerpingEyeComponent, PlayerDetachedEvent>(OnDetached);
+ SubscribeLocalEvent<LerpingEyeComponent, LocalPlayerDetachedEvent>(OnDetached);
UpdatesAfter.Add(typeof(TransformSystem));
UpdatesAfter.Add(typeof(PhysicsSystem));
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);
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
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
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);
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;
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);
{
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);
#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();
}
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
{
{
[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
base.Initialize();
SubscribeNetworkEvent<RoundRestartCleanupEvent>(Reset);
- SubscribeLocalEvent<PlayerAttachSysMessage>(HandlePlayerAttached);
}
public void Reset(RoundRestartCleanupEvent ev)
}
_guis.Clear();
- _attachedEntity = default;
- }
-
- private void HandlePlayerAttached(PlayerAttachSysMessage message)
- {
- _attachedEntity = message.AttachedEntity;
}
public override void FrameUpdate(float frameTime)
return;
}
- if (_attachedEntity is not {} ent || Deleted(ent))
+ if (_player.LocalEntity is not {} ent || Deleted(ent))
{
return;
}
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;
UpdatesOutsidePrediction = true;
base.Initialize();
- SubscribeLocalEvent<InventorySlotsComponent, PlayerAttachedEvent>(OnPlayerAttached);
- SubscribeLocalEvent<InventorySlotsComponent, PlayerDetachedEvent>(OnPlayerDetached);
+ SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
+ SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<InventoryComponent, ComponentShutdown>(OnShutdown);
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))
{
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;
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);
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();
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;
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);
// 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);
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);
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);
}
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;
}
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;
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;
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;
public void SetSpectatorPosition(SpectatorData data)
{
- if (_player.LocalPlayer == null)
+ if (_player.LocalSession == null)
return;
if (data.Controller != null
&& 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;
}
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;
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);
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)
{
return;
}
- _player.LocalPlayer.AttachEntity(target, EntityManager, _client);
+ _player.SetAttachedEntity(_player.LocalSession, target);
EnsureComp<ReplaySpectatorComponent>(target);
_stateMan.RequestStateChange<ReplaySpectateEntityState>();
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);
if (gridAttach)
_transform.AttachToGridOrMap(ent);
- _player.LocalPlayer.AttachEntity(ent, EntityManager, _client);
+ _player.SetAttachedEntity(_player.LocalSession, ent);
if (old != null)
{
{
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);
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;
SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerbs);
SubscribeLocalEvent<ReplaySpectatorComponent, EntityTerminatingEvent>(OnTerminating);
- SubscribeLocalEvent<ReplaySpectatorComponent, PlayerDetachedEvent>(OnDetached);
+ SubscribeLocalEvent<ReplaySpectatorComponent, LocalPlayerDetachedEvent>(OnDetached);
SubscribeLocalEvent<ReplaySpectatorComponent, EntParentChangedMessage>(OnParentChanged);
InitializeBlockers();
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
{
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;
{
base.Initialize();
SubscribeLocalEvent<ParacusiaComponent, ComponentStartup>(OnComponentStartup);
- SubscribeLocalEvent<ParacusiaComponent, PlayerDetachedEvent>(OnPlayerDetach);
+ SubscribeLocalEvent<ParacusiaComponent, LocalPlayerDetachedEvent>(OnPlayerDetach);
}
public override void Update(float frameTime)
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();
}
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;
[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!;
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()
_window.RolePlaceholder.Visible = briefing == null && !controls.Any() && !objectives.Any();
}
- private void CharacterDetached()
+ private void CharacterDetached(EntityUid uid)
{
CloseWindow();
}
_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);
_speechBubbleRoot = new LayoutContainer();
- OnLocalPlayerChanged(new LocalPlayerChangedEventArgs(null, _player.LocalPlayer));
+ UpdateChannelPermissions();
_input.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(_ => FocusChat()));
_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();
}
-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;
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))
_overlayManager.AddOverlay(_overlay);
}
- private void OnPlayerDetached(PlayerDetachedEvent args)
+ private void OnPlayerDetached(LocalPlayerDetachedEvent args)
{
_overlayManager.RemoveOverlay(_overlay);
ClearOverlay();
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;
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;
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;
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!;
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;
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>();
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;
await server.WaitPost(() =>
{
- var player = sPlayers.ServerSessions.First();
+ var player = sPlayers.Sessions.First();
playerGuid = player.UserId;
Assert.DoesNotThrow(() =>
await server.WaitPost(() =>
{
- var player = sPlayers.ServerSessions.Single();
+ var player = sPlayers.Sessions.Single();
sAdminLogSystem.Add(LogType.Unknown, $"{player} {player} test log: {guid}");
});
await server.WaitPost(() =>
{
- var player = sPlayers.ServerSessions.Single();
+ var player = sPlayers.Sessions.Single();
sAdminLogSystem.Add(LogType.Unknown, $"{player:first} {player:second} test log: {guid}");
});
using Content.Shared.Database;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
+using Robust.Shared.Player;
namespace Content.IntegrationTests.Tests.Administration.Logs;
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}");
});
await server.WaitAssertion(() =>
{
- var clientSession = sPlayerManager.ServerSessions.Single();
+ var clientSession = sPlayerManager.Sessions.Single();
var ui = new AdminAnnounceEui();
eui.OpenEui(ui, clientSession);
});
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;
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;
protected NetEntity Player;
protected ICommonSession ClientSession = default!;
- protected IPlayerSession ServerSession = default!;
+ protected ICommonSession ServerSession = default!;
public EntityUid? ClientTarget;
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;
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
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;
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);
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>();
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?");
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));
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);
var playerMan = server.ResolveDependency<IPlayerManager>();
var serverConsole = server.ResolveDependency<IServerConsoleHost>();
- var player = playerMan.ServerSessions.Single();
+ var player = playerMan.Sessions.Single();
EntityUid ghost = default!;
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;
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!;
EntityUid mindId = default!;
MindComponent mind = default!;
- var player = playerMan.ServerSessions.Single();
+ var player = playerMan.Sessions.Single();
await pair.Server.WaitAssertion(() =>
{
var oldUid = player.AttachedEntity;
/// </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);
}
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);
{
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;
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));
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;
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);
// Reconnect
await Connect(pair, name);
- player = playerMan.ServerSessions.Single();
+ player = playerMan.Sessions.Single();
Assert.Multiple(() =>
{
Assert.That(user, Is.EqualTo(player.UserId));
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(() =>
{
});
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
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();
+ }
}
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;
EntityUid entity = default!;
EntityUid mindId = default!;
MindComponent mind = default!;
- var player = playerMan.ServerSessions.Single();
+ var player = playerMan.Sessions.Single();
await server.WaitAssertion(() =>
{
await pair.CleanReturnAsync();
}
- // TODO Implement
- /*[Test]
- public async Task TestPlayerCanReturnFromGhostWhenDead()
- {
- }*/
-
[Test]
public async Task TestGhostDoesNotInfiniteLoop()
{
EntityUid ghost = default!;
EntityUid mindId = default!;
MindComponent mind = default!;
- var player = playerMan.ServerSessions.Single();
+ var player = playerMan.Sessions.Single();
await server.WaitAssertion(() =>
{
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;
AdminManager = Server.ResolveDependency<IAdminManager>();
}
- protected bool InvokeCommand(string command, out object? result, IPlayerSession? session = null)
+ protected bool InvokeCommand(string command, out object? result, ICommonSession? session = null)
{
return Toolshed.InvokeCommand(this, command, null, out result);
}
return true;
}
- protected IPlayerSession? InvocationSession { get; set; }
+ protected ICommonSession? InvocationSession { get; set; }
public ICommonSession? Session
{
await server.WaitPost(() =>
{
- var playerEntity = sPlayerManager.ServerSessions.Single().AttachedEntity;
+ var playerEntity = sPlayerManager.Sessions.Single().AttachedEntity;
if (playerEntity.HasValue)
{
using Content.Shared.Administration;
-using Robust.Server.Player;
+using Robust.Shared.Player;
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;
/// <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.
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
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");
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;
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]");
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
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.");
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;
}
var located = await _locator.LookupIdByNameOrIdAsync(target);
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
if (located == null)
{
{
if (args.Length == 1)
{
- var options = _playerManager.ServerSessions.Select(c => c.Name).OrderBy(c => c).ToArray();
+ var options = _playerManager.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
return CompletionResult.FromHintOptions(options, LocalizationManager.GetString("cmd-ban-hint"));
}
return;
}
- 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);
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"));
}
}
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;
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;
using Content.Server.Mind;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
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;
-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
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");
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]
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.");
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;
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.");
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;
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");
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;
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;
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;
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;
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)]
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.");
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;
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;
using System.Text;
using Content.Server.Database;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
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)
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;
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
-
namespace Content.Server.Administration.Commands
{
[AnyCommand]
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.");
-
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
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;
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;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
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;
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;
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");
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;
_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);
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;
var value = properties[key];
value = value switch
{
- IPlayerSession player => new SerializablePlayer(player),
+ ICommonSession player => new SerializablePlayer(player),
EntityCoordinates entityCoordinates => new SerializableEntityCoordinates(_entityManager, entityCoordinates),
_ => value
};
{
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
};
using System.Text.Json;
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.Administration.Logs.Converters;
public readonly struct SerializablePlayer
{
- public readonly IPlayerSession Player;
+ public readonly ICommonSession Player;
- public SerializablePlayer(IPlayerSession player)
+ public SerializablePlayer(ICommonSession player)
{
Player = player;
}
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;
[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();
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;
}
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))
{
UpdateAdminStatus(session);
}
- public void ReAdmin(IPlayerSession session)
+ public void ReAdmin(ICommonSession session)
{
if (!_admins.TryGetValue(session, out var reg))
{
UpdateAdminStatus(session);
}
- public async void ReloadAdmin(IPlayerSession player)
+ public async void ReloadAdmin(ICommonSession player)
{
var data = await LoadAdminData(player);
var curAdmin = _admins.GetValueOrDefault(player);
_toolshed.ActivePermissionController = this;
}
- public void PromoteHost(IPlayerSession player)
+ public void PromoteHost(ICommonSession player)
{
_promotedPlayers.Add(player.UserId);
}
// NOTE: Also sends commands list for non admins..
- private void UpdateAdminStatus(IPlayerSession session)
+ private void UpdateAdminStatus(ICommonSession session)
{
var msg = new MsgUpdateAdminStatus();
}
}
- private async void LoginAdminMaybe(IPlayerSession session)
+ private async void LoginAdminMaybe(ICommonSession session)
{
var adminDat = await LoadAdminData(session);
if (adminDat == null)
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)
}
}
- private static bool IsLocal(IPlayerSession player)
+ private static bool IsLocal(ICommonSession player)
{
var ep = player.ConnectedClient.RemoteEndPoint;
var addr = ep.Address;
return false;
}
- public bool CanCommand(IPlayerSession session, string cmdName)
+ public bool CanCommand(ICommonSession session, string cmdName)
{
if (_commandPermissions.AnyCommands.Contains(cmdName))
{
return true;
}
- var data = GetAdminData((IPlayerSession)user);
+ var data = GetAdminData(user);
if (data == null)
{
// Player isn't an admin.
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));
private sealed class AdminReg
{
- public readonly IPlayerSession Session;
+ public readonly ICommonSession Session;
public AdminData Data;
public int? RankId;
// 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;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
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()
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>
/// <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.
/// <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.
void Initialize();
- void PromoteHost(IPlayerSession player);
+ void PromoteHost(ICommonSession player);
bool TryGetCommandFlags(CommandSpec command, out AdminFlags[]? flags);
}
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;
/// Sends role bans to the target
/// </summary>
/// <param name="pSession">Player's session</param>
- public void SendRoleBans(IPlayerSession pSession);
+ public void SendRoleBans(ICommonSession pSession);
}
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;
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;
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;
using Content.Shared.Administration;
using JetBrains.Annotations;
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.Administration;
/// <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(
/// <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(
/// <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(
/// <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(
-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;
_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(
}
}
- public void UpdatePlayerList(IPlayerSession player)
+ public void UpdatePlayerList(ICommonSession player)
{
_playerList[player.UserId] = GetPlayerInfo(player.Data, player);
UpdatePanicBunker();
}
- private void SendFullPlayerList(IPlayerSession playerSession)
+ private void SendFullPlayerList(ICommonSession playerSession)
{
var ev = new FullPlayerListEvent();
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;
/// 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);
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;
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))
{
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;
}
}
- public void OpenEditSolutionsEui(IPlayerSession session, EntityUid uid)
+ public void OpenEditSolutionsEui(ICommonSession session, EntityUid uid)
{
if (session.AttachedEntity == null)
return;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
_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);
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.
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;
[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;
}
-using System.Linq;
using Content.Server.Afk.Events;
using Content.Server.GameTicking;
using Content.Shared.CCVar;
private float _checkDelay;
private TimeSpan _checkTime;
- private readonly HashSet<IPlayerSession> _afkPlayers = new();
+ private readonly HashSet<ICommonSession> _afkPlayers = new();
public override void Initialize()
{
_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))
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.Input;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
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();
}
[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()
{
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.
_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.
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);
}
}
}
-using Robust.Server.Player;
+using Robust.Shared.Player;
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;
}
-using Robust.Server.Player;
+using Robust.Shared.Player;
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;
}
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
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.");
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
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.");
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
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);
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"));
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;
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)
{
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)
using Content.Shared.Arcade;
-using Robust.Server.Player;
using System.Linq;
+using Robust.Shared.Player;
namespace Content.Server.Arcade.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);
/// 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)
{
/// 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);
/// 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;
/// 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);
}
/// 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);
/// 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);
}
/// 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);
}
/// 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);
}
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.Arcade.BlockGame;
/// <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();
}
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;
}
}
- 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;
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)
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;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
EntityUid? gridId;
Gas? gas = null;
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
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.");
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
+using Robust.Shared.Player;
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.
_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))
{
/// </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))
{
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;
private void OnGasTankToggleInternals(Entity<GasTankComponent> ent, ref GasTankToggleInternalsMessage args)
{
- if (args.Session is not IPlayerSession playerSession ||
- playerSession.AttachedEntity == null)
- {
- return;
- }
-
ToggleInternals(ent);
}
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Map;
+using Robust.Shared.Player;
using Robust.Shared.Threading;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
[Robust.Shared.IoC.Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Robust.Shared.IoC.Dependency] private readonly ChunkingSystem _chunkingSys = default!;
- private readonly Dictionary<IPlayerSession, Dictionary<NetEntity, HashSet<Vector2i>>> _lastSentChunks = new();
+ private readonly Dictionary<ICommonSession, Dictionary<NetEntity, HashSet<Vector2i>>> _lastSentChunks = new();
// Oh look its more duplicated decal system code!
private ObjectPool<HashSet<Vector2i>> _chunkIndexPool =
// Now we'll go through each player, then through each chunk in range of that player checking if the player is still in range
// If they are, check if they need the new data to send (i.e. if there's an overlay for the gas).
// Afterwards we reset all the chunk data for the next time we tick.
- var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
+ var players = _playerManager.Sessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount };
Parallel.ForEach(players, opts, p => UpdatePlayer(p, curTick));
}
- private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick)
+ private void UpdatePlayer(ICommonSession playerSession, GameTick curTick)
{
var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, _chunkIndexPool, _chunkViewerPool);
var previouslySent = _lastSentChunks[playerSession];
using Content.Shared.Administration;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
EntityUid entity;
EntityUid hand;
-using System.Linq;
using Content.Server.Administration;
using Content.Server.Body.Systems;
using Content.Shared.Administration;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Body.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
EntityUid bodyId;
EntityUid? partUid;
using Content.Server.Body.Systems;
using Content.Shared.Administration;
using Content.Shared.Body.Components;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Random;
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 a player can run this command.");
using Content.Shared.Administration;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Random;
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 a player can run this command.");
if (!Resolve(bodyId, ref body, false))
return new HashSet<EntityUid>();
- if (LifeStage(bodyId) >= EntityLifeStage.Terminating || EntityManager.IsQueuedForDeletion(bodyId))
+ if (TerminatingOrDeleted(bodyId) || EntityManager.IsQueuedForDeletion(bodyId))
return new HashSet<EntityUid>();
var xform = Transform(bodyId);
using Content.Shared.Cargo.Prototypes;
using Content.Shared.Database;
using Robust.Shared.Map;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Content.Shared.Interaction;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Containers;
using Robust.Shared.Map;
+using Robust.Shared.Player;
namespace Content.Server.CartridgeLoader;
/// and use this method to update its state so the cartridge loaders state can be added to it.
/// </remarks>
/// <seealso cref="PDA.PdaSystem.UpdatePdaUserInterface"/>
- public void UpdateUiState(EntityUid loaderUid, IPlayerSession? session, CartridgeLoaderComponent? loader)
+ public void UpdateUiState(EntityUid loaderUid, ICommonSession? session, CartridgeLoaderComponent? loader)
{
if (!Resolve(loaderUid, ref loader))
return;
/// This method is called "UpdateCartridgeUiState" but cartridges and a programs are the same. A cartridge is just a program as a visible item.
/// </remarks>
/// <seealso cref="Cartridges.NotekeeperCartridgeSystem.UpdateUiState"/>
- public void UpdateCartridgeUiState(EntityUid loaderUid, BoundUserInterfaceState state, IPlayerSession? session = default!, CartridgeLoaderComponent? loader = default!)
+ public void UpdateCartridgeUiState(EntityUid loaderUid, BoundUserInterfaceState state, ICommonSession? session = default!, CartridgeLoaderComponent? loader = default!)
{
if (!Resolve(loaderUid, ref loader))
return;
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = (IPlayerSession?) shell.Player;
+ var player = shell.Player;
if (player == null)
{
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;
using Content.Server.Chat.Managers;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;
using Content.Server.GameTicking;
using Content.Shared.Administration;
using Content.Shared.Mind;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteLine(Loc.GetString("shell-cannot-run-command-from-server"));
return;
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;
using Content.Shared.Chat;
using Content.Shared.Database;
using Content.Shared.Mind;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
using Robust.Shared.Player;
-using Robust.Shared.Players;
using Robust.Shared.Replays;
using Robust.Shared.Utility;
private bool _oocEnabled = true;
private bool _adminOocEnabled = true;
- public Dictionary<IPlayerSession, int> SenderKeys { get; } = new();
- public Dictionary<IPlayerSession, HashSet<NetEntity>> SenderEntities { get; } = new();
+ public Dictionary<ICommonSession, int> SenderKeys { get; } = new();
+ public Dictionary<ICommonSession, HashSet<NetEntity>> SenderEntities { get; } = new();
public void Initialize()
{
DispatchServerAnnouncement(Loc.GetString(val ? "chat-manager-admin-ooc-chat-enabled-message" : "chat-manager-admin-ooc-chat-disabled-message"));
}
- public void DeleteMessagesBy(IPlayerSession player)
+ public void DeleteMessagesBy(ICommonSession player)
{
var key = SenderKeys.GetValueOrDefault(player);
var entities = SenderEntities.GetValueOrDefault(player) ?? new HashSet<NetEntity>();
/// <param name="player">The player sending the message.</param>
/// <param name="message">The message.</param>
/// <param name="type">The type of message.</param>
- public void TrySendOOCMessage(IPlayerSession player, string message, OOCChatType type)
+ public void TrySendOOCMessage(ICommonSession player, string message, OOCChatType type)
{
// Check if message exceeds the character limit
if (message.Length > MaxMessageLength)
#region Private API
- private void SendOOC(IPlayerSession player, string message)
+ private void SendOOC(ICommonSession player, string message)
{
if (_adminManager.IsAdmin(player))
{
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"OOC from {player:Player}: {message}");
}
- private void SendAdminChat(IPlayerSession player, string message)
+ private void SendAdminChat(ICommonSession player, string message)
{
if (!_adminManager.IsAdmin(player))
{
}
}
- public bool MessageCharacterLimit(IPlayerSession? player, string message)
+ public bool MessageCharacterLimit(ICommonSession? player, string message)
{
var isOverLength = false;
using Content.Shared.Chat;
-using Robust.Server.Player;
using Robust.Shared.Network;
using Robust.Shared.Player;
-using Robust.Shared.Players;
namespace Content.Server.Chat.Managers
{
/// Keys identifying messages sent by a specific player, used when sending
/// <see cref="MsgChatMessage"/>
/// </summary>
- Dictionary<IPlayerSession, int> SenderKeys { get; }
+ Dictionary<ICommonSession, int> SenderKeys { get; }
/// <summary>
/// Tracks which entities a player was attached to while sending messages.
/// </summary>
- Dictionary<IPlayerSession, HashSet<NetEntity>> SenderEntities { get; }
+ Dictionary<ICommonSession, HashSet<NetEntity>> SenderEntities { get; }
void Initialize();
void DispatchServerMessage(ICommonSession player, string message, bool suppressLog = false);
- void TrySendOOCMessage(IPlayerSession player, string message, OOCChatType type);
+ void TrySendOOCMessage(ICommonSession player, string message, OOCChatType type);
void SendHookOOC(string sender, string message);
void SendAdminAnnouncement(string message);
void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0, int? senderKey = null);
- bool MessageCharacterLimit(IPlayerSession player, string message);
+ bool MessageCharacterLimit(ICommonSession player, string message);
- void DeleteMessagesBy(IPlayerSession player);
+ void DeleteMessagesBy(ICommonSession player);
}
}
using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
-using Content.Server.Players;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.ActionBlocker;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Mobs.Systems;
+using Content.Shared.Players;
using Content.Shared.Radio;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Network;
using Robust.Shared.Player;
-using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Replays;
InGameICChatType desiredType,
bool hideChat, bool hideLog = false,
IConsoleShell? shell = null,
- IPlayerSession? player = null, string? nameOverride = null,
+ ICommonSession? player = null, string? nameOverride = null,
bool checkRadioPrefix = true,
bool ignoreActionBlocker = false)
{
ChatTransmitRange range,
bool hideLog = false,
IConsoleShell? shell = null,
- IPlayerSession? player = null,
+ ICommonSession? player = null,
string? nameOverride = null,
bool checkRadioPrefix = true,
bool ignoreActionBlocker = false
InGameOOCChatType type,
bool hideChat,
IConsoleShell? shell = null,
- IPlayerSession? player = null
+ ICommonSession? player = null
)
{
if (!CanSendInGame(message, shell, player))
}
// ReSharper disable once InconsistentNaming
- private void SendLOOC(EntityUid source, IPlayerSession player, string message, bool hideChat)
+ private void SendLOOC(EntityUid source, ICommonSession player, string message, bool hideChat)
{
var name = FormattedMessage.EscapeText(Identity.Name(source, EntityManager));
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"LOOC from {player:Player}: {message}");
}
- private void SendDeadChat(EntityUid source, IPlayerSession player, string message, bool hideChat)
+ private void SendDeadChat(EntityUid source, ICommonSession player, string message, bool hideChat)
{
var clients = GetDeadChatClients();
var playerName = Name(source);
initialResult = MessageRangeCheckResult.Full;
break;
case ChatTransmitRange.GhostRangeLimit:
- initialResult = (data.Observer && data.Range < 0 && !_adminManager.IsAdmin((IPlayerSession) session)) ? MessageRangeCheckResult.HideChat : MessageRangeCheckResult.Full;
+ initialResult = (data.Observer && data.Range < 0 && !_adminManager.IsAdmin(session)) ? MessageRangeCheckResult.HideChat : MessageRangeCheckResult.Full;
break;
case ChatTransmitRange.HideChat:
initialResult = MessageRangeCheckResult.HideChat;
break;
case ChatTransmitRange.NoGhosts:
- initialResult = (data.Observer && !_adminManager.IsAdmin((IPlayerSession) session)) ? MessageRangeCheckResult.Disallowed : MessageRangeCheckResult.Full;
+ initialResult = (data.Observer && !_adminManager.IsAdmin(session)) ? MessageRangeCheckResult.Disallowed : MessageRangeCheckResult.Full;
break;
}
var insistHideChat = data.HideChatOverride ?? false;
/// <summary>
/// Returns true if the given player is 'allowed' to send the given message, false otherwise.
/// </summary>
- private bool CanSendInGame(string message, IConsoleShell? shell = null, IPlayerSession? player = null)
+ private bool CanSendInGame(string message, IConsoleShell? shell = null, ICommonSession? player = null)
{
// Non-players don't have to worry about these restrictions.
if (player == null)
{
var newMessage = message.Trim();
newMessage = SanitizeMessageReplaceWords(newMessage);
-
+
if (capitalize)
newMessage = SanitizeMessageCapital(newMessage);
if (capitalizeTheWordI)
using Content.Shared.Chemistry.Reagent;
using Robust.Server.Player;
using Robust.Shared.Enums;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.EntitySystems;
using System.Linq;
using Content.Shared.Decals;
using Microsoft.Extensions.ObjectPool;
-using Robust.Server.Player;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
+using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Shared.Chunking;
private void OnPvsRangeChanged(float value) => _baseViewBounds = Box2.UnitCentered.Scale(value);
public Dictionary<NetEntity, HashSet<Vector2i>> GetChunksForSession(
- IPlayerSession session,
+ ICommonSession session,
int chunkSize,
ObjectPool<HashSet<Vector2i>> indexPool,
ObjectPool<Dictionary<NetEntity, HashSet<Vector2i>>> viewerPool,
return chunks;
}
- private HashSet<EntityUid> GetSessionViewers(IPlayerSession session)
+ private HashSet<EntityUid> GetSessionViewers(ICommonSession session)
{
var viewers = new HashSet<EntityUid>();
if (session.Status != SessionStatus.InGame || session.AttachedEntity is null)
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Network;
+using Robust.Shared.Player;
namespace Content.Server.Commands
{
/// sending a failure to the performer if unable to.
/// </summary>
public static bool TryGetSessionByUsernameOrId(IConsoleShell shell,
- string usernameOrId, IPlayerSession performer, [NotNullWhen(true)] out IPlayerSession? session)
+ string usernameOrId, ICommonSession performer, [NotNullWhen(true)] out ICommonSession? session)
{
var plyMgr = IoCManager.Resolve<IPlayerManager>();
if (plyMgr.TryGetSessionByUsername(usernameOrId, out session)) return true;
/// sending a failure to the performer if unable to.
/// </summary>
public static bool TryGetAttachedEntityByUsernameOrId(IConsoleShell shell,
- string usernameOrId, IPlayerSession performer, out EntityUid attachedEntity)
+ string usernameOrId, ICommonSession performer, out EntityUid attachedEntity)
{
attachedEntity = default;
if (!TryGetSessionByUsernameOrId(shell, usernameOrId, performer, out var session)) return false;
transform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$NAME", entMan.GetComponent<MetaDataComponent>(ent).EntityName);
- if (shell.Player is IPlayerSession player)
+ if (shell.Player is { } player)
{
if (player.AttachedEntity is {Valid: true} p)
{
using Content.Shared.Administration;
using Content.Shared.Construction;
using Content.Shared.Tag;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map.Components;
public void Execute(IConsoleShell shell, string argsOther, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
EntityUid? gridId;
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
using Content.Server.Administration;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
EntityUid? gridId;
string tileIdA;
string tileIdB;
using Content.Shared.Administration;
using Content.Shared.Maps;
using Content.Shared.Tag;
-using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map;
+using Robust.Server.GameObjects;
using Robust.Shared.Map.Components;
namespace Content.Server.Construction.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
EntityUid? gridId;
switch (args.Length)
using Content.Shared.Inventory;
using Content.Shared.Storage;
using Robust.Shared.Containers;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Construction
using Content.Shared.CrewManifest;
using Content.Shared.GameTicking;
using Content.Shared.StationRecords;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.CrewManifest;
private void OnRequestCrewManifest(RequestCrewManifestMessage message, EntitySessionEventArgs args)
{
- if (args.SenderSession is not IPlayerSession sessionCast
+ if (args.SenderSession is not { } sessionCast
|| !_configManager.GetCVar(CCVars.CrewManifestWithoutEntity))
{
return;
private void OnBoundUiClose(EntityUid uid, CrewManifestViewerComponent component, BoundUIClosedEvent ev)
{
var owningStation = _stationSystem.GetOwningStation(uid);
- if (owningStation == null || ev.Session is not IPlayerSession sessionCast)
+ if (owningStation == null || ev.Session is not { } session)
{
return;
}
- CloseEui(owningStation.Value, sessionCast, uid);
+ CloseEui(owningStation.Value, session, uid);
}
/// <summary>
private void OpenEuiFromBui(EntityUid uid, CrewManifestViewerComponent component, CrewManifestOpenUiMessage msg)
{
var owningStation = _stationSystem.GetOwningStation(uid);
- if (owningStation == null || msg.Session is not IPlayerSession sessionCast)
+ if (owningStation == null || msg.Session is not { } session)
{
return;
}
return;
}
- OpenEui(owningStation.Value, sessionCast, uid);
+ OpenEui(owningStation.Value, session, uid);
}
/// <summary>
/// <param name="station">Station that we're displaying the crew manifest for.</param>
/// <param name="session">The player's session.</param>
/// <param name="owner">If this EUI should be 'owned' by an entity.</param>
- public void OpenEui(EntityUid station, IPlayerSession session, EntityUid? owner = null)
+ public void OpenEui(EntityUid station, ICommonSession session, EntityUid? owner = null)
{
if (!HasComp<StationRecordsComponent>(station))
{
return;
}
- if (shell.Player == null || shell.Player is not IPlayerSession session)
+ if (shell.Player == null || shell.Player is not { } session)
{
shell.WriteLine("You must run this from a client.");
return;
using Content.Server.Administration;
-using Content.Server.Damage.Systems;
using Content.Shared.Administration;
using Content.Shared.Damage.Systems;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Damage.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
EntityUid entity;
switch (args.Length)
using Content.Shared.Stunnable;
using Robust.Server.GameObjects;
using Robust.Server.Player;
-using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using System.Threading.Tasks;
using Content.Server.Players.PlayTimeTracking;
using Content.Server.Preferences.Managers;
-using Robust.Server.Player;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.Database;
// TODO: Ideally connected/disconnected would be subscribed to IPlayerManager directly,
// but this runs into ordering issues with game ticker.
- public void ClientConnected(IPlayerSession session)
+ public void ClientConnected(ICommonSession session)
{
DebugTools.Assert(!_users.ContainsKey(session.UserId), "We should not have any cached data on client connect.");
_users.Add(session.UserId, data);
}
- public void ClientDisconnected(IPlayerSession session)
+ public void ClientDisconnected(ICommonSession session)
{
_users.Remove(session.UserId, out var data);
if (data == null)
_playTimeTracking.ClientDisconnected(session);
}
- private async Task Load(IPlayerSession session, CancellationToken cancel)
+ private async Task Load(ICommonSession session, CancellationToken cancel)
{
await Task.WhenAll(
_prefs.LoadData(session, cancel),
_playTimeTracking.LoadData(session, cancel));
}
- public Task WaitLoadComplete(IPlayerSession session)
+ public Task WaitLoadComplete(ICommonSession session)
{
return _users[session.UserId].Task;
}
- public bool IsLoadComplete(IPlayerSession session)
+ public bool IsLoadComplete(ICommonSession session)
{
return GetLoadTask(session).IsCompleted;
}
- public Task GetLoadTask(IPlayerSession session)
+ public Task GetLoadTask(ICommonSession session)
{
return _users[session.UserId].Task;
}
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
+using Robust.Shared.Player;
using Robust.Shared.Threading;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
[Dependency] private readonly MapSystem _mapSystem = default!;
private readonly Dictionary<NetEntity, HashSet<Vector2i>> _dirtyChunks = new();
- private readonly Dictionary<IPlayerSession, Dictionary<NetEntity, HashSet<Vector2i>>> _previousSentChunks = new();
+ private readonly Dictionary<ICommonSession, Dictionary<NetEntity, HashSet<Vector2i>>> _previousSentChunks = new();
private static readonly Vector2 _boundsMinExpansion = new(0.01f, 0.01f);
private static readonly Vector2 _boundsMaxExpansion = new(1.01f, 1.01f);
private void OnDecalPlacementRequest(RequestDecalPlacementEvent ev, EntitySessionEventArgs eventArgs)
{
- if (eventArgs.SenderSession is not IPlayerSession session)
+ if (eventArgs.SenderSession is not { } session)
return;
// bad
private void OnDecalRemovalRequest(RequestDecalRemovalEvent ev, EntitySessionEventArgs eventArgs)
{
- if (eventArgs.SenderSession is not IPlayerSession session)
+ if (eventArgs.SenderSession is not { } session)
return;
// bad
if (PvsEnabled)
{
- var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
+ var players = _playerManager.Sessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount };
Parallel.ForEach(players, opts, UpdatePlayer);
}
_dirtyChunks.Clear();
}
- public void UpdatePlayer(IPlayerSession player)
+ public void UpdatePlayer(ICommonSession player)
{
var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, _chunkIndexPool, _chunkViewerPool);
var staleChunks = _chunkViewerPool.Get();
}
private void SendChunkUpdates(
- IPlayerSession session,
+ ICommonSession session,
Dictionary<NetEntity, HashSet<Vector2i>> updatedChunks,
Dictionary<NetEntity, HashSet<Vector2i>> staleChunks)
{
using Content.Server.Disposal.Tube;
using Content.Server.Disposal.Tube.Components;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Disposal
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(Loc.GetString("shell-only-players-can-run-this-command"));
using Content.Shared.Eui;
using Robust.Shared.Network;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.EUI
{
using Robust.Server.Player;
using Robust.Shared.Enums;
using Robust.Shared.Network;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.EUI
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.EntityList;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
return;
}
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteError("You must be a player to run this command.");
return;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Utility;
namespace Content.Server.Examine
private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs)
{
- var player = (IPlayerSession) eventArgs.SenderSession;
+ var player = eventArgs.SenderSession;
var session = eventArgs.SenderSession;
var channel = player.ConnectedClient;
var entity = GetEntity(request.NetEntity);
using System.Numerics;
using Content.Shared.Fluids;
using Content.Shared.Fluids.Components;
-using Robust.Server.Player;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Fluids.EntitySystems;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly PuddleSystem _puddle = default!;
- private readonly HashSet<IPlayerSession> _playerObservers = new();
+ private readonly HashSet<ICommonSession> _playerObservers = new();
private List<Entity<MapGridComponent>> _grids = new();
- public bool ToggleObserver(IPlayerSession observer)
+ public bool ToggleObserver(ICommonSession observer)
{
NextTick ??= _timing.CurTime + Cooldown;
return true;
}
- private void RemoveObserver(IPlayerSession observer)
+ private void RemoveObserver(ICommonSession observer)
{
if (!_playerObservers.Remove(observer))
{
using Content.Server.Administration;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Fluids;
public string Help => $"Usage: {Command}";
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.");
using Content.Shared.Administration;
using Content.Shared.GameTicking;
using Content.Shared.Roles;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
return;
}
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
if (player == null)
{
using Content.Shared.Administration;
using Content.Shared.GameTicking;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
return;
}
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
if (args.Length > 1)
{
shell.WriteLine("Must provide <= 1 argument.");
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
if (args.Length != 1)
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using JetBrains.Annotations;
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.GameTicking
{
/// </summary>
public GamePresetPrototype? CurrentPreset { get; private set; }
- private bool StartPreset(IPlayerSession[] origReadyPlayers, bool force)
+ private bool StartPreset(ICommonSession[] origReadyPlayers, bool force)
{
var startAttempt = new RoundStartAttemptEvent(origReadyPlayers, force);
RaiseLocalEvent(startAttempt);
{
if (mind.Session != null) // Logging is suppressed to prevent spam from ghost attempts caused by movement attempts
{
- _chatManager.DispatchServerMessage((IPlayerSession) mind.Session, Loc.GetString("comp-mind-ghosting-prevented"),
+ _chatManager.DispatchServerMessage(mind.Session, Loc.GetString("comp-mind-ghosting-prevented"),
true);
}
using System.Linq;
using Content.Shared.GameTicking;
using Content.Server.Station.Components;
-using Robust.Server.Player;
using Robust.Shared.Network;
using Robust.Shared.Player;
-using Robust.Shared.Players;
using System.Text;
namespace Content.Server.GameTicking
("roundId", RoundId), ("playerCount", playerCount), ("readyCount", readyCount), ("mapName", stationNames.ToString()),("gmTitle", gmTitle),("desc", desc));
}
- private TickerLobbyStatusEvent GetStatusMsg(IPlayerSession session)
+ private TickerLobbyStatusEvent GetStatusMsg(ICommonSession session)
{
_playerGameStatuses.TryGetValue(session.UserId, out var status);
return new TickerLobbyStatusEvent(RunLevel != GameRunLevel.PreRoundLobby, LobbySong, LobbyBackground,status == PlayerGameStatus.ReadyToPlay, _roundStartTime, RoundPreloadTime, _roundStartTimeSpan, Paused);
private void SendStatusToAll()
{
- foreach (var player in _playerManager.ServerSessions)
+ foreach (var player in _playerManager.Sessions)
{
RaiseNetworkEvent(GetStatusMsg(player), player.ConnectedClient);
}
}
}
- public void ToggleReady(IPlayerSession player, bool ready)
+ public void ToggleReady(ICommonSession player, bool ready)
{
if (!_playerGameStatuses.ContainsKey(player.UserId))
return;
using Content.Server.Database;
-using Content.Server.Players;
using Content.Shared.GameTicking;
using Content.Shared.GameWindow;
using Content.Shared.Players;
using Content.Shared.Preferences;
using JetBrains.Annotations;
+using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Enums;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IServerDbManager _dbManager = default!;
+ [Dependency] private readonly ActorSystem _actor = default!;
private void InitializePlayer()
{
// Always make sure the client has player data.
if (session.Data.ContentDataUncast == null)
{
- var data = new PlayerData(session.UserId, args.Session.Name);
+ var data = new ContentPlayerData(session.UserId, args.Session.Name);
data.Mind = mindId;
session.Data.ContentDataUncast = data;
}
// Make the player actually join the game.
// timer time must be > tick length
- Timer.Spawn(0, args.Session.JoinGame);
+ Timer.Spawn(0, () => _playerManager.JoinGame(args.Session));
var record = await _dbManager.GetPlayerRecordByUserId(args.Session.UserId);
var firstConnection = record != null &&
}
else
{
- // Simply re-attach to existing entity.
- session.AttachToEntity(mind.CurrentEntity);
- PlayerJoinGame(session);
+ if (_actor.Attach(mind.CurrentEntity, session))
+ {
+ PlayerJoinGame(session);
+ }
+ else
+ {
+ Log.Error(
+ $"Failed to attach player {session} with mind {ToPrettyString(mindId)} to its current entity {ToPrettyString(mind.CurrentEntity)}");
+ SpawnObserverWaitDb();
+ }
}
break;
}
}
- private HumanoidCharacterProfile GetPlayerProfile(IPlayerSession p)
+ private HumanoidCharacterProfile GetPlayerProfile(ICommonSession p)
{
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(p.UserId).SelectedCharacter;
}
- public void PlayerJoinGame(IPlayerSession session, bool silent = false)
+ public void PlayerJoinGame(ICommonSession session, bool silent = false)
{
if (!silent)
_chatManager.DispatchServerMessage(session, Loc.GetString("game-ticker-player-join-game-message"));
RaiseNetworkEvent(new TickerJoinGameEvent(), session.ConnectedClient);
}
- private void PlayerJoinLobby(IPlayerSession session)
+ private void PlayerJoinLobby(ICommonSession session)
{
_playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
_db.AddRoundPlayers(RoundId, session.UserId);
public sealed class PlayerJoinedLobbyEvent : EntityEventArgs
{
- public readonly IPlayerSession PlayerSession;
+ public readonly ICommonSession PlayerSession;
- public PlayerJoinedLobbyEvent(IPlayerSession playerSession)
+ public PlayerJoinedLobbyEvent(ICommonSession playerSession)
{
PlayerSession = playerSession;
}
using JetBrains.Annotations;
using Prometheus;
using Robust.Server.Maps;
-using Robust.Server.Player;
using Robust.Shared.Asynchronous;
using Robust.Shared.Audio;
using Robust.Shared.Map;
var startingEvent = new RoundStartingEvent(RoundId);
RaiseLocalEvent(startingEvent);
- var readyPlayers = new List<IPlayerSession>();
+ var readyPlayers = new List<ICommonSession>();
var readyPlayerProfiles = new Dictionary<NetUserId, HumanoidCharacterProfile>();
foreach (var (userId, status) in _playerGameStatuses)
{
connected = true;
}
- PlayerData? contentPlayerData = null;
+ ContentPlayerData? contentPlayerData = null;
if (userId != null && _playerManager.TryGetPlayerData(userId.Value, out var playerData))
{
contentPlayerData = playerData.ContentData();
private void ResettingCleanup()
{
// Move everybody currently in the server to lobby.
- foreach (var player in _playerManager.ServerSessions)
+ foreach (var player in _playerManager.Sessions)
{
PlayerJoinLobby(player);
}
DisallowLateJoin = false;
_playerGameStatuses.Clear();
- foreach (var session in _playerManager.ServerSessions)
+ foreach (var session in _playerManager.Sessions)
{
_playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
}
/// </summary>
public sealed class RoundStartAttemptEvent : CancellableEntityEventArgs
{
- public IPlayerSession[] Players { get; }
+ public ICommonSession[] Players { get; }
public bool Forced { get; }
- public RoundStartAttemptEvent(IPlayerSession[] players, bool forced)
+ public RoundStartAttemptEvent(ICommonSession[] players, bool forced)
{
Players = players;
Forced = forced;
/// If you want to handle a specific player being spawned, remove it from this list and do what you need.
/// </summary>
/// <remarks>If you spawn a player by yourself from this event, don't forget to call <see cref="GameTicker.PlayerJoinGame"/> on them.</remarks>
- public List<IPlayerSession> PlayerPool { get; }
+ public List<ICommonSession> PlayerPool { get; }
public IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> Profiles { get; }
public bool Forced { get; }
- public RulePlayerSpawningEvent(List<IPlayerSession> playerPool, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
+ public RulePlayerSpawningEvent(List<ICommonSession> playerPool, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
{
PlayerPool = playerPool;
Profiles = profiles;
/// </summary>
public sealed class RulePlayerJobsAssignedEvent
{
- public IPlayerSession[] Players { get; }
+ public ICommonSession[] Players { get; }
public IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> Profiles { get; }
public bool Forced { get; }
- public RulePlayerJobsAssignedEvent(IPlayerSession[] players, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
+ public RulePlayerJobsAssignedEvent(ICommonSession[] players, IReadOnlyDictionary<NetUserId, HumanoidCharacterProfile> profiles, bool forced)
{
Players = players;
Profiles = profiles;
using System.Numerics;
using Content.Server.Administration.Managers;
using Content.Server.Ghost;
-using Content.Server.Players;
using Content.Server.Spawners.Components;
using Content.Server.Speech.Components;
using Content.Server.Station.Components;
using Content.Shared.CCVar;
using Content.Shared.Database;
+using Content.Shared.Players;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using JetBrains.Annotations;
-using Robust.Server.Player;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
[Dependency] private readonly SharedJobSystem _jobs = default!;
[ValidatePrototypeId<EntityPrototype>]
- private const string ObserverPrototypeName = "MobObserver";
+ public const string ObserverPrototypeName = "MobObserver";
/// <summary>
/// How many players have joined the round through normal methods.
return spawnableStations;
}
- private void SpawnPlayers(List<IPlayerSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
+ private void SpawnPlayers(List<ICommonSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
{
// Allow game rules to spawn players by themselves if needed. (For example, nuke ops or wizard)
RaiseLocalEvent(new RulePlayerSpawningEvent(readyPlayers, profiles, force));
RaiseLocalEvent(new RulePlayerJobsAssignedEvent(assignedJobs.Keys.Select(x => _playerManager.GetSessionByUserId(x)).ToArray(), profiles, force));
}
- private void SpawnPlayer(IPlayerSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
+ private void SpawnPlayer(ICommonSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
{
var character = GetPlayerProfile(player);
SpawnPlayer(player, character, station, jobId, lateJoin, silent);
}
- private void SpawnPlayer(IPlayerSession player, HumanoidCharacterProfile character, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
+ private void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile character, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
{
// Can't spawn players with a dummy ticker!
if (DummyTicker)
RaiseLocalEvent(mob, aev, true);
}
- public void Respawn(IPlayerSession player)
+ public void Respawn(ICommonSession player)
{
_mind.WipeMind(player);
_adminLogger.Add(LogType.Respawn, LogImpact.Medium, $"Player {player} was respawned.");
/// <param name="station">The station they're spawning on</param>
/// <param name="jobId">An optional job for them to spawn as</param>
/// <param name="silent">Whether or not the player should be greeted upon joining</param>
- public void MakeJoinGame(IPlayerSession player, EntityUid station, string? jobId = null, bool silent = false)
+ public void MakeJoinGame(ICommonSession player, EntityUid station, string? jobId = null, bool silent = false)
{
if (!_playerGameStatuses.ContainsKey(player.UserId))
return;
/// <summary>
/// Causes the given player to join the current game as observer ghost. See also <see cref="SpawnObserver"/>
/// </summary>
- public void JoinAsObserver(IPlayerSession player)
+ public void JoinAsObserver(ICommonSession player)
{
// Can't spawn players with a dummy ticker!
if (DummyTicker)
/// Spawns an observer ghost and attaches the given player to it. If the player does not yet have a mind, the
/// player is given a new mind with the observer role. Otherwise, the current mind is transferred to the ghost.
/// </summary>
- public void SpawnObserver(IPlayerSession player)
+ public void SpawnObserver(ICommonSession player)
{
if (DummyTicker)
return;
[PublicAPI]
public sealed class PlayerBeforeSpawnEvent : HandledEntityEventArgs
{
- public IPlayerSession Player { get; }
+ public ICommonSession Player { get; }
public HumanoidCharacterProfile Profile { get; }
public string? JobId { get; }
public bool LateJoin { get; }
public EntityUid Station { get; }
- public PlayerBeforeSpawnEvent(IPlayerSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, EntityUid station)
+ public PlayerBeforeSpawnEvent(ICommonSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, EntityUid station)
{
Player = player;
Profile = profile;
public sealed class PlayerSpawnCompleteEvent : EntityEventArgs
{
public EntityUid Mob { get; }
- public IPlayerSession Player { get; }
+ public ICommonSession Player { get; }
public string? JobId { get; }
public bool LateJoin { get; }
public EntityUid Station { get; }
// Ex. If this is the 27th person to join, this will be 27.
public int JoinOrder { get; }
- public PlayerSpawnCompleteEvent(EntityUid mob, IPlayerSession player, string? jobId, bool lateJoin, int joinOrder, EntityUid station, HumanoidCharacterProfile profile)
+ public PlayerSpawnCompleteEvent(EntityUid mob, ICommonSession player, string? jobId, bool lateJoin, int joinOrder, EntityUid station, HumanoidCharacterProfile profile)
{
Mob = mob;
Player = player;
using Content.Shared.Preferences;
using Content.Shared.Roles;
-using Robust.Server.Player;
using Robust.Shared.Audio;
+using Robust.Shared.Player;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.GameTicking.Rules.Components;
public SelectionState SelectionStatus = SelectionState.WaitingForSpawn;
public TimeSpan AnnounceAt = TimeSpan.Zero;
- public Dictionary<IPlayerSession, HumanoidCharacterProfile> StartCandidates = new();
+ public Dictionary<ICommonSession, HumanoidCharacterProfile> StartCandidates = new();
/// <summary>
/// Path to antagonist alert sound.
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Components;
using Robust.Server.Player;
+using Robust.Shared.Player;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server.GameTicking.Rules;
var maxOperatives = nukeops.MaxOps;
// Dear lord what is happening HERE.
- var everyone = new List<IPlayerSession>(ev.PlayerPool);
- var prefList = new List<IPlayerSession>();
- var medPrefList = new List<IPlayerSession>();
- var cmdrPrefList = new List<IPlayerSession>();
- var operatives = new List<IPlayerSession>();
+ var everyone = new List<ICommonSession>(ev.PlayerPool);
+ var prefList = new List<ICommonSession>();
+ var medPrefList = new List<ICommonSession>();
+ var cmdrPrefList = new List<ICommonSession>();
+ var operatives = new List<ICommonSession>();
// The LINQ expression ReSharper keeps suggesting is completely unintelligible so I'm disabling it
// ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
for (var i = 0; i < numNukies; i++)
{
// TODO: Please fix this if you touch it.
- IPlayerSession nukeOp;
+ ICommonSession nukeOp;
// Only one commander, so we do it at the start
if (i == 0)
{
_npcFaction.AddFaction(mob, "Syndicate");
}
- private void SpawnOperatives(int spawnCount, List<IPlayerSession> sessions, bool addSpawnPoints, NukeopsRuleComponent component)
+ private void SpawnOperatives(int spawnCount, List<ICommonSession> sessions, bool addSpawnPoints, NukeopsRuleComponent component)
{
if (component.NukieOutpost == null)
return;
var playersPerOperative = component.PlayersPerOperative;
var maxOperatives = component.MaxOps;
- var playerPool = _playerManager.ServerSessions.ToList();
+ var playerPool = _playerManager.Sessions.ToList();
var numNukies = MathHelper.Clamp(playerPool.Count / playersPerOperative, 1, maxOperatives);
- var operatives = new List<IPlayerSession>();
+ var operatives = new List<ICommonSession>();
SpawnOperatives(numNukies, operatives, true, component);
}
using Content.Shared.Roles;
using Robust.Server.GameObjects;
using Robust.Server.Maps;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Map;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
(int) Math.Min(
Math.Floor((double) ev.PlayerPool.Count / _cfg.GetCVar(CCVars.PiratesPlayersPerOp)),
_cfg.GetCVar(CCVars.PiratesMaxOps)));
- var ops = new IPlayerSession[numOps];
+ var ops = new ICommonSession[numOps];
for (var i = 0; i < numOps; i++)
{
ops[i] = _random.PickAndTake(ev.PlayerPool);
using Content.Shared.Interaction.Events;
using Content.Shared.Mind;
using Content.Shared.Mobs;
+using Content.Shared.Players;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Network;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
}
}
- private List<IPlayerSession> FindPotentialTraitors(in Dictionary<IPlayerSession, HumanoidCharacterProfile> candidates, TraitorRuleComponent component)
+ private List<ICommonSession> FindPotentialTraitors(in Dictionary<ICommonSession, HumanoidCharacterProfile> candidates, TraitorRuleComponent component)
{
- var list = new List<IPlayerSession>();
+ var list = new List<ICommonSession>();
var pendingQuery = GetEntityQuery<PendingClockInComponent>();
foreach (var player in candidates.Keys)
list.Add(player);
}
- var prefList = new List<IPlayerSession>();
+ var prefList = new List<ICommonSession>();
foreach (var player in list)
{
return prefList;
}
- private List<IPlayerSession> PickTraitors(int traitorCount, List<IPlayerSession> prefList)
+ private List<ICommonSession> PickTraitors(int traitorCount, List<ICommonSession> prefList)
{
- var results = new List<IPlayerSession>(traitorCount);
+ var results = new List<ICommonSession>(traitorCount);
if (prefList.Count == 0)
{
Log.Info("Insufficient ready players to fill up with traitors, stopping the selection.");
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Configuration;
-using Robust.Shared.Prototypes;
+using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
return;
component.InfectedChosen = true;
- var allPlayers = _playerManager.ServerSessions.ToList();
- var playerList = new List<IPlayerSession>();
- var prefList = new List<IPlayerSession>();
+ var allPlayers = _playerManager.Sessions.ToList();
+ var playerList = new List<ICommonSession>();
+ var prefList = new List<ICommonSession>();
foreach (var player in allPlayers)
{
if (player.AttachedEntity == null || !HasComp<HumanoidAppearanceComponent>(player.AttachedEntity) || HasComp<ZombieImmuneComponent>(player.AttachedEntity))
var totalInfected = 0;
while (totalInfected < numInfected)
{
- IPlayerSession zombie;
+ ICommonSession zombie;
if (prefList.Count == 0)
{
if (playerList.Count == 0)
using Content.Server.GameTicking;
using Content.Shared.Administration;
using Content.Shared.Mind;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Ghost
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 have no session, you can't ghost.");
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Ghost.Roles.UI;
using Content.Server.Mind.Commands;
-using Content.Server.Players;
using Content.Shared.Administration;
using Content.Shared.Database;
using Content.Shared.Follower;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs;
+using Content.Shared.Players;
using Content.Shared.Roles;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;
return unchecked(_nextRoleIdentifier++);
}
- public void OpenEui(IPlayerSession session)
+ public void OpenEui(ICommonSession session)
{
if (session.AttachedEntity is not {Valid: true} attached ||
!EntityManager.HasComponent<GhostComponent>(attached))
eui.StateDirty();
}
- public void OpenMakeGhostRoleEui(IPlayerSession session, EntityUid uid)
+ public void OpenMakeGhostRoleEui(ICommonSession session, EntityUid uid)
{
if (session.AttachedEntity == null)
return;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if(shell.Player != null)
- EntitySystem.Get<GhostRoleSystem>().OpenEui((IPlayerSession)shell.Player);
+ EntitySystem.Get<GhostRoleSystem>().OpenEui(shell.Player);
else
shell.WriteLine("You can only open the ghost roles UI on a client.");
}
using Content.Shared.Gravity;
using Content.Shared.Interaction;
using Robust.Server.GameObjects;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.Gravity
{
return;
if (session is { AttachedEntity: { } })
- _adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{ToPrettyString(session.AttachedEntity.Value):player} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}");
+ _adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{session:player} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}");
component.SwitchedOn = on;
UpdatePowerState(component, powerReceiver);
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Throwing;
-using Robust.Server.Player;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.Hands.Systems
#endregion
#region interactions
- private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coordinates, EntityUid entity)
+ private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity)
{
- if (session is not IPlayerSession playerSession)
+ if (playerSession == null)
return false;
if (playerSession.AttachedEntity is not {Valid: true} player ||
// TODO: move to storage or inventory
private void HandleSmartEquip(ICommonSession? session, string equipmentSlot)
{
- if (session is not IPlayerSession playerSession)
+ if (session is not { } playerSession)
return;
if (playerSession.AttachedEntity is not {Valid: true} plyEnt || !Exists(plyEnt))
using Content.Shared.Humanoid;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Utility;
namespace Content.Server.Humanoid;
private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierBaseLayersSetMessage message)
{
- if (message.Session is not IPlayerSession player
+ if (message.Session is not { } player
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
{
return;
private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component,
HumanoidMarkingModifierMarkingSetMessage message)
{
- if (message.Session is not IPlayerSession player
+ if (message.Session is not { } player
|| !_adminManager.HasAdminFlag(player, AdminFlags.Fun))
{
return;
using Content.Server.UserInterface;
using Content.Shared.Instruments;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.Instruments;
[ViewVariables] public uint LastSequencerTick = 0;
// TODO Instruments: Make this ECS
- public IPlayerSession? InstrumentPlayer =>
+ public ICommonSession? InstrumentPlayer =>
_entMan.GetComponentOrNull<ActivatableUIComponent>(Owner)?.CurrentSingleUser
?? _entMan.GetComponentOrNull<ActorComponent>(Owner)?.PlayerSession;
}
using Content.Shared.Popups;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Audio.Midi;
using Robust.Shared.Collections;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.GameStates;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Instruments;
var nearby = GetBands(entity);
_bui.TrySendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby),
- (IPlayerSession)request.Session);
+ request.Session);
}
_bandRequestQueue.Clear();
}
}
- public void ToggleInstrumentUi(EntityUid uid, IPlayerSession session, InstrumentComponent? component = null)
+ public void ToggleInstrumentUi(EntityUid uid, ICommonSession session, InstrumentComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
using Robust.Shared.Containers;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
-using Robust.Shared.Players;
using Robust.Shared.Random;
namespace Content.Server.Interaction
using System.Numerics;
using Content.Server.Administration;
-using Content.Server.Tools.Components;
using Content.Shared.Administration;
using Content.Shared.Maps;
-using Content.Shared.Tools.Components;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
if (player?.AttachedEntity is not {} attached)
{
return;
using Content.Shared.Humanoid.Markings;
using Content.Shared.MagicMirror;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.MagicMirror;
private void UpdateInterface(EntityUid uid, EntityUid playerUid, ICommonSession session, HumanoidAppearanceComponent? humanoid = null)
{
- if (!Resolve(playerUid, ref humanoid) || session is not IPlayerSession player)
+ if (!Resolve(playerUid, ref humanoid) || session is not { } player)
{
return;
}
public 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-savemap-server"));
return;
using Content.Shared.Maps;
using Robust.Server.Console;
-using Robust.Server.Player;
-using Robust.Shared.Players;
using Robust.Shared.Utility;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
+using Robust.Shared.Player;
namespace Content.Server.Maps;
public void Toggle(ICommonSession session)
{
- if (session is not IPlayerSession pSession)
+ if (session is not { } pSession)
return;
DebugTools.Assert(_admin.CanCommand(pSession, CommandName));
{
var grid = GetEntity(ev.Grid);
- if (args.SenderSession is not IPlayerSession playerSession ||
+ if (args.SenderSession is not { } playerSession ||
!_admin.CanCommand(playerSession, CommandName) ||
!Exists(grid) ||
Deleted(grid))
{
var grid = GetEntity(msg.Grid);
- if (args.SenderSession is not IPlayerSession playerSession ||
+ if (args.SenderSession is not { } playerSession ||
!_admin.CanCommand(playerSession, CommandName) ||
!Exists(grid) ||
Deleted(grid))
using Content.Shared.Mobs.Systems;
using Content.Shared.Timing;
using Content.Shared.Toggleable;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Medical;
using Robust.Server.GameStates;
using Robust.Server.Player;
using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
}
TransferTo(mindId, null, createGhost: false, mind: mind);
+ DebugTools.AssertNull(mind.OwnedEntity);
- // Let's not create ghosts if not in the middle of the round.
- if (_gameTicker.RunLevel == GameRunLevel.PreRoundLobby)
+ if (!component.GhostOnShutdown || mind.Session == null || _gameTicker.RunLevel == GameRunLevel.PreRoundLobby)
return;
- // I just love convoluted entity shutdown logic that results in more entities being spawned.
- if (component.GhostOnShutdown && mind.Session != null)
- {
- var xform = Transform(uid);
- var gridId = xform.GridUid;
- var spawnPosition = Transform(uid).Coordinates;
-
- // Use a regular timer here because the entity has probably been deleted.
- Timer.Spawn(0, () =>
- {
- // Make extra sure the round didn't end between spawning the timer and it being executed.
- if (_gameTicker.RunLevel == GameRunLevel.PreRoundLobby)
- return;
+ var xform = Transform(uid);
+ var gridId = xform.GridUid;
+ var spawnPosition = Transform(uid).Coordinates;
- // Async this so that we don't throw if the grid we're on is being deleted.
- if (!_maps.GridExists(gridId))
- spawnPosition = _gameTicker.GetObserverSpawnPoint();
+ // Use a regular timer here because the entity has probably been deleted.
+ Timer.Spawn(0, () =>
+ {
+ // Make extra sure the round didn't end between spawning the timer and it being executed.
+ if (_gameTicker.RunLevel == GameRunLevel.PreRoundLobby)
+ return;
- // TODO refactor observer spawning.
- // please.
- if (!spawnPosition.IsValid(EntityManager))
- {
- // This should be an error, if it didn't cause tests to start erroring when they delete a player.
- Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available.");
- TransferTo(mindId, null, createGhost: false, mind: mind);
- return;
- }
+ // Async this so that we don't throw if the grid we're on is being deleted.
+ if (!HasComp<MapGridComponent>(gridId))
+ spawnPosition = _gameTicker.GetObserverSpawnPoint();
- var ghost = Spawn("MobObserver", spawnPosition);
- var ghostComponent = Comp<GhostComponent>(ghost);
- _ghosts.SetCanReturnToBody(ghostComponent, false);
+ // TODO refactor observer spawning.
+ // please.
+ if (!spawnPosition.IsValid(EntityManager))
+ {
+ // This should be an error, if it didn't cause tests to start erroring when they delete a player.
+ Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available.");
+ TransferTo(mindId, null, createGhost: false, mind: mind);
+ return;
+ }
- // Log these to make sure they're not causing the GameTicker round restart bugs...
- Log.Debug($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, spawned \"{ToPrettyString(ghost)}\".");
+ var ghost = Spawn(GameTicker.ObserverPrototypeName, spawnPosition);
+ var ghostComponent = Comp<GhostComponent>(ghost);
+ _ghosts.SetCanReturnToBody(ghostComponent, false);
- var val = mind.CharacterName ?? string.Empty;
- _metaData.SetEntityName(ghost, val);
- TransferTo(mindId, ghost, mind: mind);
- });
- }
+ // Log these to make sure they're not causing the GameTicker round restart bugs...
+ Log.Debug($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, spawned \"{ToPrettyString(ghost)}\".");
+ _metaData.SetEntityName(ghost, mind.CharacterName ?? string.Empty);
+ TransferTo(mindId, ghost, mind: mind);
+ });
}
public override bool TryGetMind(NetUserId user, [NotNullWhen(true)] out EntityUid? mindId, [NotNullWhen(true)] out MindComponent? mind)
return false;
}
- public bool TryGetSession(EntityUid? mindId, [NotNullWhen(true)] out IPlayerSession? session)
+ public bool TryGetSession(EntityUid? mindId, [NotNullWhen(true)] out ICommonSession? session)
{
session = null;
- return TryComp(mindId, out MindComponent? mind) && (session = (IPlayerSession?) mind.Session) != null;
+ return TryComp(mindId, out MindComponent? mind) && (session = mind.Session) != null;
}
- public IPlayerSession? GetSession(MindComponent mind)
+ public ICommonSession? GetSession(MindComponent mind)
{
- return (IPlayerSession?) mind.Session;
+ return mind.Session;
}
- public bool TryGetSession(MindComponent mind, [NotNullWhen(true)] out IPlayerSession? session)
+ public bool TryGetSession(MindComponent mind, [NotNullWhen(true)] out ICommonSession? session)
{
return (session = GetSession(mind)) != null;
}
return;
}
- GetSession(mind)?.AttachToEntity(entity);
+ if (GetSession(mind) is { } session)
+ _actor.Attach(entity, session);
+
mind.VisitingEntity = entity;
// EnsureComp instead of AddComp to deal with deferred deletions.
return;
var owned = mind.OwnedEntity;
- GetSession(mind)?.AttachToEntity(owned);
+ if (GetSession(mind) is { } session)
+ _actor.Attach(owned, session);
if (owned.HasValue)
{
if (session != null && !alreadyAttached && mind.VisitingEntity == null)
{
_actor.Attach(entity, session, true);
+ DebugTools.Assert(session.AttachedEntity == entity, $"Failed to attach entity.");
Log.Info($"Session {session.Name} transferred to entity {entity}.");
}
using Content.Shared.Mind;
-using Robust.Server.Player;
+using Robust.Shared.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Toolshed.Syntax;
private SharedMindSystem? _mind;
[CommandImplementation("get")]
- public MindComponent? Get([PipedArgument] IPlayerSession session)
+ public MindComponent? Get([PipedArgument] ICommonSession session)
{
_mind ??= GetSys<SharedMindSystem>();
return _mind.TryGetMind(session, out _, out var mind) ? mind : null;
public EntityUid Control(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid target,
- [CommandArgument] ValueRef<IPlayerSession> playerRef)
+ [CommandArgument] ValueRef<ICommonSession> playerRef)
{
_mind ??= GetSys<SharedMindSystem>();
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Motd;
[Dependency] private readonly IAdminManager _adminManager = default!;
public override string Command => "motd";
-
+
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = (IPlayerSession?)shell.Player;
+ var player = shell.Player;
if (args.Length < 1 || (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd")))
shell.ConsoleHost.ExecuteCommand(shell.Player, "get-motd");
else
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
- var player = (IPlayerSession?)shell.Player;
+ var player = shell.Player;
if (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd"))
return CompletionResult.Empty;
if (args.Length == 1)
using Content.Server.GameTicking;
using Content.Shared.CCVar;
using Content.Shared.Chat;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Configuration;
+using Robust.Shared.Player;
namespace Content.Server.Motd;
{
if (string.IsNullOrEmpty(_messageOfTheDay))
return;
-
+
var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay));
_chatManager.ChatMessageToAll(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, recordReplay: true);
}
/// <summary>
/// Sends the Message Of The Day, if any, to a specific player.
/// </summary>
- public void TrySendMOTD(IPlayerSession player)
+ public void TrySendMOTD(ICommonSession player)
{
if (string.IsNullOrEmpty(_messageOfTheDay))
return;
-
+
var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay));
_chatManager.ChatMessageToOne(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, client: player.ConnectedClient);
}
{
if (string.IsNullOrEmpty(_messageOfTheDay))
return;
-
+
var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay));
shell.WriteLine(wrappedMessage);
- if (shell.Player is IPlayerSession player)
+ if (shell.Player is { } player)
_chatManager.ChatMessageToOne(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, client: player.ConnectedClient);
}
{
if (val == _messageOfTheDay)
return;
-
+
_messageOfTheDay = val;
TrySendMOTD();
}
using Content.Shared.Database;
using Content.Shared.CCVar;
using Content.Server.Chat.Managers;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
public override string Command => "set-motd";
-
+
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
string motd = "";
- var player = (IPlayerSession?)shell.Player;
+ var player = shell.Player;
if (args.Length > 0)
{
motd = string.Join(" ", args).Trim();
if (player != null && _chatManager.MessageCharacterLimit(player, motd))
return; // check function prints its own error response
}
-
+
_configurationManager.SetCVar(CCVars.MOTD, motd); // A hook in MOTDSystem broadcasts changes to the MOTD to everyone so we don't need to do it here.
if (string.IsNullOrEmpty(motd))
{
using Content.Server.Movement.Components;
using Robust.Server.Player;
using Robust.Shared.Map;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Movement.Systems;
using Content.Server.EUI;
using Content.Server.NPC.UI;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.NPC.Commands;
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession playerSession)
+ if (shell.Player is not { } playerSession)
{
return;
}
using Content.Server.Administration.Managers;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.CPUJob.JobQueues.Queues;
-using Content.Server.NPC.Components;
using Content.Server.NPC.HTN.PrimitiveTasks;
using Content.Server.NPC.Systems;
using Content.Shared.Administration;
using Content.Shared.Mobs;
using Content.Shared.NPC;
-using Content.Shared.NPC;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
private void OnHTNMessage(RequestHTNMessage msg, EntitySessionEventArgs args)
{
- if (!_admin.HasAdminFlag((IPlayerSession) args.SenderSession, AdminFlags.Debug))
+ if (!_admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug))
{
_subscribers.Remove(args.SenderSession);
return;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Threading;
using Robust.Shared.Timing;
private void OnBreadcrumbs(RequestPathfindingDebugMessage msg, EntitySessionEventArgs args)
{
- var pSession = (IPlayerSession) args.SenderSession;
+ var pSession = args.SenderSession;
if (!_adminManager.HasAdminFlag(pSession, AdminFlags.Debug))
{
using Content.Shared.NPC.Events;
using Content.Shared.Physics;
using Content.Shared.Weapons.Melee;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
-using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
private void OnDebugRequest(RequestNPCSteeringDebugEvent msg, EntitySessionEventArgs args)
{
- if (!_admin.IsAdmin((IPlayerSession)args.SenderSession))
+ if (!_admin.IsAdmin(args.SenderSession))
return;
if (msg.Enabled)
using Robust.Server.Player;
using Robust.Shared.Enums;
using Robust.Shared.Map;
+using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.NodeContainer.EntitySystems
private readonly List<int> _visDeletes = new();
private readonly List<BaseNodeGroup> _visSends = new();
- private readonly HashSet<IPlayerSession> _visPlayers = new();
+ private readonly HashSet<ICommonSession> _visPlayers = new();
private readonly HashSet<BaseNodeGroup> _toRemake = new();
private readonly HashSet<BaseNodeGroup> _nodeGroups = new();
private readonly HashSet<Node> _toRemove = new();
private void HandleEnableMsg(NodeVis.MsgEnable msg, EntitySessionEventArgs args)
{
- var session = (IPlayerSession) args.SenderSession;
+ var session = args.SenderSession;
if (!_adminManager.HasAdminFlag(session, AdminFlags.Debug))
return;
}
}
- private void VisSendFullStateImmediate(IPlayerSession player)
+ private void VisSendFullStateImmediate(ICommonSession player)
{
var msg = new NodeVis.MsgData();
using Content.Server.Administration;
-using Content.Server.Nutrition.Components;
using Content.Shared.Administration;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Nutrition
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 unless you are a player.");
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
- var player = shell.Player as IPlayerSession;
+ var player = shell.Player;
if (player == null || !_players.TryGetSessionByUsername(args[0], out player))
{
shell.WriteError(LocalizationManager.GetString("shell-target-player-does-not-exist"));
using Content.Server.Instruments;
using Content.Server.Light.EntitySystems;
using Content.Server.Light.Events;
-using Content.Server.MassMedia.Components;
-using Content.Server.MassMedia.Systems;
-using Content.Server.Mind;
using Content.Server.PDA.Ringer;
using Content.Server.Station.Systems;
using Content.Server.Store.Components;
using Content.Shared.Light.Components;
using Content.Shared.PDA;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Containers;
namespace Content.Server.PDA
return;
if (HasComp<RingerComponent>(uid))
- _ringer.ToggleRingerUI(uid, (IPlayerSession) msg.Session);
+ _ringer.ToggleRingerUI(uid, msg.Session);
}
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowMusicMessage msg)
return;
if (TryComp<InstrumentComponent>(uid, out var instrument))
- _instrument.ToggleInstrumentUi(uid, (IPlayerSession) msg.Session, instrument);
+ _instrument.ToggleInstrumentUi(uid, msg.Session, instrument);
}
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowUplinkMessage msg)
using Content.Shared.Popups;
using Content.Shared.Store;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Network;
using Robust.Shared.Player;
_ui.SetUiState(bui, new RingerUpdateState(isPlaying, ringer.Ringtone));
}
- public bool ToggleRingerUI(EntityUid uid, IPlayerSession session)
+ public bool ToggleRingerUI(EntityUid uid, ICommonSession session)
{
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui))
_ui.ToggleUi(bui, session);
using Content.Server.UserInterface;
using Content.Shared.Database;
using Content.Shared.Examine;
-using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Paper;
using Content.Shared.Tag;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Player;
-using Robust.Shared.Utility;
-using Robust.Shared.Audio;
using static Content.Shared.Paper.SharedPaperComponent;
namespace Content.Server.Paper
_appearance.SetData(uid, PaperVisuals.Status, status, appearance);
}
- public void UpdateUserInterface(EntityUid uid, PaperComponent? paperComp = null, IPlayerSession? session = null)
+ public void UpdateUserInterface(EntityUid uid, PaperComponent? paperComp = null, ICommonSession? session = null)
{
if (!Resolve(uid, ref paperComp))
return;
}
// Get chunks in range
- foreach (var client in Filter.GetAllPlayers(_playerManager))
+ foreach (var pSession in Filter.GetAllPlayers(_playerManager))
{
- var pSession = (IPlayerSession) client;
if (xformQuery.TryGetComponent(pSession.AttachedEntity, out var xform) &&
_handledEntities.Add(pSession.AttachedEntity.Value) &&
using Content.Server.Power.Components;
using Content.Shared.Database;
using Content.Shared.Singularity.Components;
-using Robust.Server.Player;
-using Robust.Server.GameObjects;
using Robust.Shared.Utility;
using System.Diagnostics;
using Content.Shared.CCVar;
+using Robust.Shared.Player;
namespace Content.Server.ParticleAccelerator.EntitySystems;
FireEmitter(comp.StarboardEmitter!.Value, strength);
}
- public void SwitchOn(EntityUid uid, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
+ public void SwitchOn(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;
UpdateUI(uid, comp);
}
- public void SwitchOff(EntityUid uid, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
+ public void SwitchOff(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;
UpdateUI(uid, comp);
}
- public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
+ public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;
if (msg.Enabled)
{
if (comp.Assembled)
- SwitchOn(uid, (IPlayerSession?) msg.Session, comp);
+ SwitchOn(uid, msg.Session, comp);
}
else
- SwitchOff(uid, (IPlayerSession?) msg.Session, comp);
+ SwitchOff(uid, msg.Session, comp);
UpdateUI(uid, comp);
}
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered)
return;
- SetStrength(uid, msg.State, (IPlayerSession?) msg.Session, comp);
+ SetStrength(uid, msg.State, msg.Session, comp);
UpdateUI(uid, comp);
}
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered)
return;
- RescanParts(uid, (IPlayerSession?) msg.Session, comp);
+ RescanParts(uid, msg.Session, comp);
UpdateUI(uid, comp);
}
using System.Numerics;
using Content.Server.ParticleAccelerator.Components;
using JetBrains.Annotations;
-using Robust.Server.Player;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Events;
+using Robust.Shared.Player;
namespace Content.Server.ParticleAccelerator.EntitySystems;
SubscribeLocalEvent<ParticleAcceleratorPartComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
- public void RescanParts(EntityUid uid, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? controller = null)
+ public void RescanParts(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? controller = null)
{
if (!Resolve(uid, ref controller))
return;
using Content.Server.Database;
using Content.Shared.CCVar;
using Content.Shared.Players.PlayTimeTracking;
-using Robust.Server.Player;
using Robust.Shared.Asynchronous;
using Robust.Shared.Collections;
using Robust.Shared.Configuration;
using Robust.Shared.Exceptions;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Server.Players.PlayTimeTracking;
-public delegate void CalcPlayTimeTrackersCallback(IPlayerSession player, HashSet<string> trackers);
+public delegate void CalcPlayTimeTrackersCallback(ICommonSession player, HashSet<string> trackers);
/// <summary>
/// Tracks play time for players, across all roles.
private ISawmill _sawmill = default!;
// List of players that need some kind of update (refresh timers or resend).
- private ValueList<IPlayerSession> _playersDirty;
+ private ValueList<ICommonSession> _playersDirty;
// DB auto-saving logic.
private TimeSpan _saveInterval;
// We must block server shutdown on these to avoid losing data.
private readonly List<Task> _pendingSaveTasks = new();
- private readonly Dictionary<IPlayerSession, PlayTimeData> _playTimeData = new();
+ private readonly Dictionary<ICommonSession, PlayTimeData> _playTimeData = new();
public event CalcPlayTimeTrackersCallback? CalcTrackers;
_playersDirty.Clear();
}
- private void RefreshSingleTracker(IPlayerSession dirty, PlayTimeData data, TimeSpan time)
+ private void RefreshSingleTracker(ICommonSession dirty, PlayTimeData data, TimeSpan time)
{
DebugTools.Assert(data.Initialized);
/// so APIs like <see cref="GetPlayTimeForTracker"/> return up-to-date info.
/// </summary>
/// <seealso cref="FlushAllTrackers"/>
- public void FlushTracker(IPlayerSession player)
+ public void FlushTracker(ICommonSession player)
{
var time = _timing.RealTime;
var data = _playTimeData[player];
}
}
- private void SendPlayTimes(IPlayerSession pSession)
+ private void SendPlayTimes(ICommonSession pSession)
{
var roles = GetTrackerTimes(pSession);
/// <summary>
/// Save all modified time trackers for a player to the database.
/// </summary>
- public async void SaveSession(IPlayerSession session)
+ public async void SaveSession(ICommonSession session)
{
// This causes all trackers to refresh, ah well.
FlushAllTrackers();
_sawmill.Debug($"Saved {log.Count} trackers");
}
- private async Task DoSaveSessionAsync(IPlayerSession session)
+ private async Task DoSaveSessionAsync(ICommonSession session)
{
var log = new List<PlayTimeUpdate>();
_sawmill.Debug($"Saved {log.Count} trackers for {session.Name}");
}
- public async Task LoadData(IPlayerSession session, CancellationToken cancel)
+ public async Task LoadData(ICommonSession session, CancellationToken cancel)
{
var data = new PlayTimeData();
_playTimeData.Add(session, data);
QueueSendTimers(session);
}
- public void ClientDisconnected(IPlayerSession session)
+ public void ClientDisconnected(ICommonSession session)
{
SaveSession(session);
_playTimeData.Remove(session);
}
- public void AddTimeToTracker(IPlayerSession id, string tracker, TimeSpan time)
+ public void AddTimeToTracker(ICommonSession id, string tracker, TimeSpan time)
{
if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
throw new InvalidOperationException("Play time info is not yet loaded for this player!");
data.DbTrackersDirty.Add(tracker);
}
- public void AddTimeToOverallPlaytime(IPlayerSession id, TimeSpan time)
+ public void AddTimeToOverallPlaytime(ICommonSession id, TimeSpan time)
{
AddTimeToTracker(id, PlayTimeTrackingShared.TrackerOverall, time);
}
- public TimeSpan GetOverallPlaytime(IPlayerSession id)
+ public TimeSpan GetOverallPlaytime(ICommonSession id)
{
return GetPlayTimeForTracker(id, PlayTimeTrackingShared.TrackerOverall);
}
- public bool TryGetTrackerTimes(IPlayerSession id, [NotNullWhen(true)] out Dictionary<string, TimeSpan>? time)
+ public bool TryGetTrackerTimes(ICommonSession id, [NotNullWhen(true)] out Dictionary<string, TimeSpan>? time)
{
time = null;
return true;
}
- public Dictionary<string, TimeSpan> GetTrackerTimes(IPlayerSession id)
+ public Dictionary<string, TimeSpan> GetTrackerTimes(ICommonSession id)
{
if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
throw new InvalidOperationException("Play time info is not yet loaded for this player!");
return data.TrackerTimes;
}
- public TimeSpan GetPlayTimeForTracker(IPlayerSession id, string tracker)
+ public TimeSpan GetPlayTimeForTracker(ICommonSession id, string tracker)
{
if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
throw new InvalidOperationException("Play time info is not yet loaded for this player!");
/// <summary>
/// Queue for play time trackers to be refreshed on a player, in case the set of active trackers may have changed.
/// </summary>
- public void QueueRefreshTrackers(IPlayerSession player)
+ public void QueueRefreshTrackers(ICommonSession player)
{
if (DirtyPlayer(player) is { } data)
data.NeedRefreshTackers = true;
/// <summary>
/// Queue for play time information to be sent to a client, for showing in UIs etc.
/// </summary>
- public void QueueSendTimers(IPlayerSession player)
+ public void QueueSendTimers(ICommonSession player)
{
if (DirtyPlayer(player) is { } data)
data.NeedSendTimers = true;
}
- private PlayTimeData? DirtyPlayer(IPlayerSession player)
+ private PlayTimeData? DirtyPlayer(ICommonSession player)
{
if (!_playTimeData.TryGetValue(player, out var data) || !data.Initialized)
return null;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
_tracking.CalcTrackers -= CalcTrackers;
}
- private void CalcTrackers(IPlayerSession player, HashSet<string> trackers)
+ private void CalcTrackers(ICommonSession player, HashSet<string> trackers)
{
if (_afk.IsAfk(player))
return;
trackers.UnionWith(GetTimedRoles(player));
}
- private bool IsPlayerAlive(IPlayerSession session)
+ private bool IsPlayerAlive(ICommonSession session)
{
var attached = session.AttachedEntity;
if (attached == null)
}
}
- private IEnumerable<string> GetTimedRoles(IPlayerSession session)
+ private IEnumerable<string> GetTimedRoles(ICommonSession session)
{
var contentData = _playerManager.GetPlayerData(session.UserId).ContentData();
_tracking.QueueSendTimers(ev.PlayerSession);
}
- public bool IsAllowed(IPlayerSession player, string role)
+ public bool IsAllowed(ICommonSession player, string role)
{
if (!_prototypes.TryIndex<JobPrototype>(role, out var job) ||
job.Requirements == null ||
return JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes);
}
- public HashSet<string> GetDisallowedJobs(IPlayerSession player)
+ public HashSet<string> GetDisallowedJobs(ICommonSession player)
{
var roles = new HashSet<string>();
if (!_cfg.GetCVar(CCVars.GameRoleTimers))
}
}
- public void PlayerRolesChanged(IPlayerSession player)
+ public void PlayerRolesChanged(ICommonSession player)
{
_tracking.QueueRefreshTrackers(player);
}
+++ /dev/null
-using Content.Shared.Players;
-using Robust.Server.Player;
-using Robust.Shared.Players;
-
-namespace Content.Server.Players
-{
- public static class PlayerDataExt
- {
- /// <summary>
- /// Gets the correctly cast instance of content player data from an engine player data storage.
- /// </summary>
- public static PlayerData? ContentData(this IPlayerSession session)
- {
- return session.Data.ContentData();
- }
-
- public static PlayerData? ContentData(this ICommonSession session)
- {
- return ((IPlayerSession) session).ContentData();
- }
-
- /// <summary>
- /// Gets the mind that is associated with this player.
- /// </summary>
- public static EntityUid? GetMind(this IPlayerSession session)
- {
- return session.Data.ContentData()?.Mind;
- }
- }
-}
using Content.Shared.Players;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.Players;
public sealed class PlayerSystem : SharedPlayerSystem
{
- public override PlayerData? ContentData(ICommonSession? session)
+ public override ContentPlayerData? ContentData(ICommonSession? session)
{
return session?.ContentData();
}
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Player;
-using Robust.Shared.Players;
using Robust.Shared.Replays;
using Robust.Shared.Timing;
}
// Get players that are in range and whose visibility layer matches the arrow's.
- bool ViewerPredicate(IPlayerSession playerSession)
+ bool ViewerPredicate(ICommonSession playerSession)
{
if (!_minds.TryGetMind(playerSession, out _, out var mind) ||
mind.CurrentEntity is not { Valid: true } ent ||
}
var viewers = Filter.Empty()
- .AddWhere(session1 => ViewerPredicate((IPlayerSession) session1))
+ .AddWhere(session1 => ViewerPredicate(session1))
.Recipients;
string selfMessage;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Player;
-using Robust.Shared.Players;
namespace Content.Server.Popups
{
using Content.Server.Popups;
using Content.Shared.Database;
using Content.Shared.Popups;
-using Robust.Server.Player;
-using Robust.Shared.Player;
using Content.Shared.Chat;
using Content.Shared.Prayer;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
+using Robust.Shared.Player;
namespace Content.Server.Prayer;
/// <summary>
/// <param name="source">The IPlayerSession that sent the message</param>
/// <param name="messageString">The main message sent to the player via the chatbox</param>
/// <param name="popupMessage">The popup to notify the player, also prepended to the messageString</param>
- public void SendSubtleMessage(IPlayerSession target, IPlayerSession source, string messageString, string popupMessage)
+ public void SendSubtleMessage(ICommonSession target, ICommonSession source, string messageString, string popupMessage)
{
if (target.AttachedEntity == null)
return;
/// You may be wondering, "Why the admin chat, specifically? Nobody even reads it!"
/// Exactly.
/// </remarks>
- public void Pray(IPlayerSession sender, PrayableComponent comp, string message)
+ public void Pray(ICommonSession sender, PrayableComponent comp, string message)
{
if (sender.AttachedEntity == null)
return;
using System.Threading;
using System.Threading.Tasks;
using Content.Shared.Preferences;
-using Robust.Server.Player;
using Robust.Shared.Network;
+using Robust.Shared.Player;
namespace Content.Server.Preferences.Managers
{
{
void Init();
- Task LoadData(IPlayerSession session, CancellationToken cancel);
- void OnClientDisconnected(IPlayerSession session);
+ Task LoadData(ICommonSession session, CancellationToken cancel);
+ void OnClientDisconnected(ICommonSession session);
bool TryGetCachedPreferences(NetUserId userId, [NotNullWhen(true)] out PlayerPreferences? playerPreferences);
PlayerPreferences GetPreferences(NetUserId userId);
IEnumerable<KeyValuePair<NetUserId, ICharacterProfile>> GetSelectedProfilesForPlayers(List<NetUserId> userIds);
- bool HavePreferencesLoaded(IPlayerSession session);
+ bool HavePreferencesLoaded(ICommonSession session);
}
}
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Content.Shared.Roles;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
}
// Should only be called via UserDbDataManager.
- public async Task LoadData(IPlayerSession session, CancellationToken cancel)
+ public async Task LoadData(ICommonSession session, CancellationToken cancel)
{
if (!ShouldStorePrefs(session.ConnectedClient.AuthType))
{
}
}
- public void OnClientDisconnected(IPlayerSession session)
+ public void OnClientDisconnected(ICommonSession session)
{
_cachedPlayerPrefs.Remove(session.UserId);
}
- public bool HavePreferencesLoaded(IPlayerSession session)
+ public bool HavePreferencesLoaded(ICommonSession session)
{
return _cachedPlayerPrefs.ContainsKey(session.UserId);
}
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Input.Binding;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.Pulling
{
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.Map.Components;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.Radiation.Systems;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Power.EntitySystems;
using Content.Shared.Research.Components;
-using Robust.Server.Player;
namespace Content.Server.Research.Systems;
if (!this.IsPowered(uid, EntityManager))
return;
- _uiSystem.TryToggleUi(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session);
+ _uiSystem.TryToggleUi(uid, ResearchClientUiKey.Key, args.Session);
}
#endregion
using Content.Server.Administration;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map;
return;
}
- if (shell.Player is not IPlayerSession player)
+ if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command"));
return;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.NodeGroups;
using Content.Shared.Administration;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Sandbox.Commands
{
var sandboxManager = EntitySystem.Get<SandboxSystem>();
var adminManager = IoCManager.Resolve<IAdminManager>();
- if (shell.IsClient && (!sandboxManager.IsSandboxEnabled && !adminManager.HasAdminFlag((IPlayerSession)shell.Player!, AdminFlags.Mapping)))
+ if (shell.IsClient && (!sandboxManager.IsSandboxEnabled && !adminManager.HasAdminFlag(shell.Player!, AdminFlags.Mapping)))
{
shell.WriteError("You are not currently able to use mapping commands.");
}
using Robust.Server.Placement;
using Robust.Server.Player;
using Robust.Shared.Enums;
+using Robust.Shared.Player;
namespace Content.Server.Sandbox
{
using Content.Shared.SensorMonitoring;
using Robust.Server.Player;
using Robust.Shared.Collections;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Server.SensorMonitoring;
using Content.Server.DeviceNetwork.Components;
using Content.Shared.SensorMonitoring;
-using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Collections;
using ConsoleUIState = Content.Shared.SensorMonitoring.SensorMonitoringConsoleBoundInterfaceState;
using IncrementalUIState = Content.Shared.SensorMonitoring.SensorMonitoringIncrementalUpdate;
if (!args.UiKey.Equals(SensorMonitoringConsoleUiKey.Key))
return;
- if (args.Session is not IPlayerSession player)
+ if (args.Session is not { } player)
return;
component.InitialUIStateSent.Remove(player);
using Robust.Server.ServerStatus;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.ServerUpdates;
using Content.Shared.Tiles;
using Robust.Server.GameObjects;
using Robust.Server.Maps;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
/// </summary>
private void OnShuttleRequestPosition(EmergencyShuttleRequestPositionMessage msg, EntitySessionEventArgs args)
{
- if (!_admin.IsAdmin((IPlayerSession) args.SenderSession))
+ if (!_admin.IsAdmin(args.SenderSession))
return;
var player = args.SenderSession.AttachedEntity;
if (!TryComp<HandsComponent>(chassis, out var hands))
return;
- if (LifeStage(uid) >= EntityLifeStage.Terminating)
+ if (TerminatingOrDeleted(uid))
{
foreach (var (hand, item) in component.ProvidedItems)
{
using Content.Shared.Wires;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Random;
namespace Content.Server.Silicons.Borgs;
using Content.Shared.Stunnable;
using Content.Shared.Wires;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Toolshed;
HashSet<string>? radioChannels = intrinsicRadio?.Channels;
var state = new SiliconLawBuiState(GetLaws(uid).Laws, radioChannels);
- _userInterface.TrySetUiState(args.Entity, SiliconLawsUiKey.Key, state, (IPlayerSession) args.Session);
+ _userInterface.TrySetUiState(args.Entity, SiliconLawsUiKey.Key, state, args.Session);
}
private void OnPlayerSpawnComplete(EntityUid uid, SiliconLawBoundComponent component, PlayerSpawnCompleteEvent args)
if (_availableJobsDirty)
{
_cachedAvailableJobs = GenerateJobsAvailableEvent();
- RaiseNetworkEvent(_cachedAvailableJobs, Filter.Empty().AddPlayers(_playerManager.ServerSessions));
+ RaiseNetworkEvent(_cachedAvailableJobs, Filter.Empty().AddPlayers(_playerManager.Sessions));
_availableJobsDirty = false;
}
}
using Content.Shared.Timing;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
/// If the user has nested-UIs open (e.g., PDA UI open when pda is in a backpack), close them.
/// </summary>
/// <param name="session"></param>
- public void CloseNestedInterfaces(EntityUid uid, IPlayerSession session, StorageComponent? storageComp = null)
+ public void CloseNestedInterfaces(EntityUid uid, ICommonSession session, StorageComponent? storageComp = null)
{
if (!Resolve(uid, ref storageComp))
return;
using System.Numerics;
-using Robust.Server.Player;
using Robust.Shared.Map;
+using Robust.Shared.Player;
namespace Content.Server.Tabletop
{
/// <summary>
/// The set of players currently playing this tabletop game.
/// </summary>
- public readonly Dictionary<IPlayerSession, TabletopSessionPlayerData> Players = new();
+ public readonly Dictionary<ICommonSession, TabletopSessionPlayerData> Players = new();
/// <summary>
/// All entities bound to this session. If you create an entity for this session, you have to add it here.
using System.Numerics;
using Content.Server.Tabletop.Components;
using Content.Shared.Tabletop.Events;
-using Robust.Server.Player;
+using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.Tabletop
/// </summary>
/// <param name="player">The player session in question.</param>
/// <param name="uid">The UID of the tabletop game entity.</param>
- public void OpenSessionFor(IPlayerSession player, EntityUid uid)
+ public void OpenSessionFor(ICommonSession player, EntityUid uid)
{
if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {Valid: true} attachedEntity)
return;
/// <param name="player">The player in question.</param>
/// <param name="uid">The UID of the tabletop game entity.</param>
/// <param name="removeGamerComponent">Whether to remove the <see cref="TabletopGamerComponent"/> from the player's attached entity.</param>
- public void CloseSessionFor(IPlayerSession player, EntityUid uid, bool removeGamerComponent = true)
+ public void CloseSessionFor(ICommonSession player, EntityUid uid, bool removeGamerComponent = true)
{
if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || tabletop.Session is not { } session)
return;
/// <param name="player">The player in question.</param>
/// <param name="offset">An offset from the tabletop position for the camera. Zero by default.</param>
/// <returns>The UID of the camera entity.</returns>
- private EntityUid CreateCamera(TabletopGameComponent tabletop, IPlayerSession player, Vector2 offset = default)
+ private EntityUid CreateCamera(TabletopGameComponent tabletop, ICommonSession player, Vector2 offset = default)
{
DebugTools.AssertNotNull(tabletop.Session);
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Utility;
private void OnTabletopRequestTakeOut(TabletopRequestTakeOut msg, EntitySessionEventArgs args)
{
- if (args.SenderSession is not IPlayerSession playerSession)
+ if (args.SenderSession is not { } playerSession)
return;
var table = GetEntity(msg.TableUid);
protected override void OnTabletopMove(TabletopMoveEvent msg, EntitySessionEventArgs args)
{
- if (args.SenderSession is not IPlayerSession playerSession)
+ if (args.SenderSession is not { } playerSession)
return;
if (!TryComp(GetEntity(msg.TableUid), out TabletopGameComponent? tabletop) || tabletop.Session is not { } session)
private void OnStopPlaying(TabletopStopPlayingEvent msg, EntitySessionEventArgs args)
{
- CloseSessionFor((IPlayerSession)args.SenderSession, GetEntity(msg.TableUid));
+ CloseSessionFor(args.SenderSession, GetEntity(msg.TableUid));
}
private void OnPlayerDetached(EntityUid uid, TabletopGamerComponent component, PlayerDetachedEvent args)
using Content.Server.Administration;
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
-using Robust.Server.Player;
+using Robust.Shared.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Syntax;
public bool CanInvoke(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] CommandSpec command,
- [CommandArgument] ValueRef<IPlayerSession> player
+ [CommandArgument] ValueRef<ICommonSession> player
)
{
// Deliberately discard the error.
using Content.Shared.Administration;
using Content.Shared.Bql;
using Content.Shared.Eui;
-using Robust.Server.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
var ui = new ToolshedVisualizeEui(
input.Select(e => (EntName(e), EntityManager.GetNetEntity(e))).ToArray()
);
- _euiManager.OpenEui(ui, (IPlayerSession) ctx.Session);
+ _euiManager.OpenEui(ui, ctx.Session);
_euiManager.QueueStateUpdate(ui);
}
}
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
+using Robust.Shared.Player;
namespace Content.Server.Traitor.Uplink.Commands
{
return;
}
- IPlayerSession? session;
+ ICommonSession? session;
if (args.Length > 0)
{
// Get player entity
}
else
{
- session = (IPlayerSession?) shell.Player;
+ session = shell.Player;
}
if (session?.AttachedEntity is not { } user)
-using Robust.Server.Player;
+using Robust.Shared.Player;
using Robust.Shared.Reflection;
using Robust.Shared.Serialization;
/// NOTE: DO NOT DIRECTLY SET, USE ActivatableUISystem.SetCurrentSingleUser
/// </summary>
[ViewVariables]
- public IPlayerSession? CurrentSingleUser;
+ public ICommonSession? CurrentSingleUser;
void ISerializationHooks.AfterDeserialization()
{
using Content.Shared.UserInterface;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.UserInterface;
return true;
}
- public void SetCurrentSingleUser(EntityUid uid, IPlayerSession? v, ActivatableUIComponent? aui = null)
+ public void SetCurrentSingleUser(EntityUid uid, ICommonSession? v, ActivatableUIComponent? aui = null)
{
if (!Resolve(uid, ref aui))
return;
public sealed class AfterActivatableUIOpenEvent : EntityEventArgs
{
public EntityUid User { get; }
- public readonly IPlayerSession Session;
+ public readonly ICommonSession Session;
- public AfterActivatableUIOpenEvent(EntityUid who, IPlayerSession session)
+ public AfterActivatableUIOpenEvent(EntityUid who, ICommonSession session)
{
User = who;
Session = session;
using Content.Shared.Research.Prototypes;
using Content.Shared.UserInterface;
using Content.Shared.Weapons.Melee;
-using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
public string Help => $"{Command} <cargosell / lathesell / melee>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (shell.Player is not IPlayerSession pSession)
+ if (shell.Player is not { } pSession)
{
shell.WriteError(Loc.GetString("stat-values-server"));
return;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.Verbs;
-using Robust.Server.Player;
namespace Content.Server.Verbs
{
private void HandleVerbRequest(RequestServerVerbsEvent args, EntitySessionEventArgs eventArgs)
{
- var player = (IPlayerSession) eventArgs.SenderSession;
+ var player = eventArgs.SenderSession;
if (!EntityManager.EntityExists(GetEntity(args.EntityUid)))
{
// this, and some verbs (e.g. view variables) won't even care about whether an entity is accessible through
// the entity menu or not.
- var force = args.AdminRequest && eventArgs.SenderSession is IPlayerSession playerSession &&
+ var force = args.AdminRequest && eventArgs.SenderSession is { } playerSession &&
_adminMgr.HasAdminFlag(playerSession, AdminFlags.Admin);
List<Type> verbTypes = new();
using Content.Server.Voting.Managers;
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.Voting
{
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="optionId"/> is not a valid option ID.
/// </exception>
- void CastVote(IPlayerSession session, int? optionId);
+ void CastVote(ICommonSession session, int? optionId);
/// <summary>
/// Cancel this vote.
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Voting;
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.Voting.Managers
{
/// True if <paramref name="initiator"/> can start votes right now,
/// and if provided if they can start votes of type <paramref name="voteType"/>.
/// </returns>
- bool CanCallVote(IPlayerSession initiator, StandardVoteType? voteType = null);
+ bool CanCallVote(ICommonSession initiator, StandardVoteType? voteType = null);
/// <summary>
/// Initiate a standard vote such as restart round, that can be initiated by players.
/// If null it is assumed to be an automatic vote by the server.
/// </param>
/// <param name="voteType">The type of standard vote to make.</param>
- void CreateStandardVote(IPlayerSession? initiator, StandardVoteType voteType);
+ void CreateStandardVote(ICommonSession? initiator, StandardVoteType voteType);
/// <summary>
/// Create a non-standard vote with special parameters.
using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Shared.Voting;
-using Robust.Server.Player;
using Robust.Shared.Configuration;
+using Robust.Shared.Player;
using Robust.Shared.Random;
namespace Content.Server.Voting.Managers
{StandardVoteType.Map, CCVars.VoteMapEnabled},
};
- public void CreateStandardVote(IPlayerSession? initiator, StandardVoteType voteType)
+ public void CreateStandardVote(ICommonSession? initiator, StandardVoteType voteType)
{
if (initiator != null)
_adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{initiator} initiated a {voteType.ToString()} vote");
TimeoutStandardVote(voteType);
}
- private void CreateRestartVote(IPlayerSession? initiator)
+ private void CreateRestartVote(ICommonSession? initiator)
{
var alone = _playerManager.PlayerCount == 1 && initiator != null;
var options = new VoteOptions
vote.CastVote(initiator, 0);
}
- foreach (var player in _playerManager.ServerSessions)
+ foreach (var player in _playerManager.Sessions)
{
if (player != initiator)
{
}
}
- private void CreatePresetVote(IPlayerSession? initiator)
+ private void CreatePresetVote(ICommonSession? initiator)
{
var presets = GetGamePresets();
};
}
- private void CreateMapVote(IPlayerSession? initiator)
+ private void CreateMapVote(ICommonSession? initiator)
{
var maps = _gameMapManager.CurrentlyEligibleMaps().ToDictionary(map => map, map => map.MapName);
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Network;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
private readonly Dictionary<StandardVoteType, TimeSpan> _standardVoteTimeout = new();
private readonly Dictionary<NetUserId, TimeSpan> _voteTimeout = new();
- private readonly HashSet<IPlayerSession> _playerCanCallVoteDirty = new();
+ private readonly HashSet<ICommonSession> _playerCanCallVoteDirty = new();
private readonly StandardVoteType[] _standardVoteTypeValues = Enum.GetValues<StandardVoteType>();
public void Initialize()
}
}
- private void CastVote(VoteReg v, IPlayerSession player, int? option)
+ private void CastVote(VoteReg v, ICommonSession player, int? option)
{
if (!IsValidOption(v, option))
throw new ArgumentOutOfRangeException(nameof(option), "Invalid vote option ID");
private void SendUpdates(VoteReg v)
{
- foreach (var player in _playerManager.ServerSessions)
+ foreach (var player in _playerManager.Sessions)
{
SendSingleUpdate(v, player);
}
v.Dirty = false;
}
- private void SendSingleUpdate(VoteReg v, IPlayerSession player)
+ private void SendSingleUpdate(VoteReg v, ICommonSession player)
{
var msg = new MsgVoteData();
private void DirtyCanCallVoteAll()
{
- _playerCanCallVoteDirty.UnionWith(_playerManager.ServerSessions);
+ _playerCanCallVoteDirty.UnionWith(_playerManager.Sessions);
}
- private void SendUpdateCanCallVote(IPlayerSession player)
+ private void SendUpdateCanCallVote(ICommonSession player)
{
var msg = new MsgVoteCanCall();
msg.CanCall = CanCallVote(player, null, out var isAdmin, out var timeSpan);
}
private bool CanCallVote(
- IPlayerSession initiator,
+ ICommonSession initiator,
StandardVoteType? voteType,
out bool isAdmin,
out TimeSpan timeSpan)
return !_voteTimeout.TryGetValue(initiator.UserId, out timeSpan);
}
- public bool CanCallVote(IPlayerSession initiator, StandardVoteType? voteType = null)
+ public bool CanCallVote(ICommonSession initiator, StandardVoteType? voteType = null)
{
return CanCallVote(initiator, voteType, out _, out _);
}
return false;
}
- private void DirtyCanCallVote(IPlayerSession player)
+ private void DirtyCanCallVote(ICommonSession player)
{
_playerCanCallVoteDirty.Add(player);
}
#region Preset Votes
- private void WirePresetVoteInitiator(VoteOptions options, IPlayerSession? player)
+ private void WirePresetVoteInitiator(VoteOptions options, ICommonSession? player)
{
if (player != null)
{
private sealed class VoteReg
{
public readonly int Id;
- public readonly Dictionary<IPlayerSession, int> CastVotes = new();
+ public readonly Dictionary<ICommonSession, int> CastVotes = new();
public readonly VoteEntry[] Entries;
public readonly string Title;
public readonly string InitiatorText;
public readonly TimeSpan StartTime;
public readonly TimeSpan EndTime;
- public readonly HashSet<IPlayerSession> VotesDirty = new();
+ public readonly HashSet<ICommonSession> VotesDirty = new();
public bool Cancelled;
public bool Finished;
public VoteFinishedEventHandler? OnFinished;
public VoteCancelledEventHandler? OnCancelled;
- public IPlayerSession? Initiator { get; }
+ public ICommonSession? Initiator { get; }
public VoteReg(int id, VoteEntry[] entries, string title, string initiatorText,
- IPlayerSession? initiator, TimeSpan start, TimeSpan end)
+ ICommonSession? initiator, TimeSpan start, TimeSpan end)
{
Id = id;
Entries = entries;
return _mgr.IsValidOption(_reg, optionId);
}
- public void CastVote(IPlayerSession session, int? optionId)
+ public void CastVote(ICommonSession session, int? optionId)
{
_mgr.CastVote(_reg, session, optionId);
}
using Content.Shared.Administration;
using Content.Shared.Database;
using Content.Shared.Voting;
-using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Voting
var mgr = IoCManager.Resolve<IVoteManager>();
- if (shell.Player != null && !mgr.CanCallVote((IPlayerSession) shell.Player, type))
+ if (shell.Player != null && !mgr.CanCallVote(shell.Player, type))
{
_adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} failed to start {type.ToString()} vote");
shell.WriteError(Loc.GetString("cmd-createvote-cannot-call-vote-now"));
return;
}
- mgr.CreateStandardVote((IPlayerSession?) shell.Player, type);
+ mgr.CreateStandardVote(shell.Player, type);
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
options.Options.Add((args[i], i));
}
- options.SetInitiatorOrServer((IPlayerSession?) shell.Player);
+ options.SetInitiatorOrServer(shell.Player);
if (shell.Player != null)
_adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} initiated a custom vote: {options.Title} - {string.Join("; ", options.Options.Select(x => x.text))}");
return;
}
- vote.CastVote((IPlayerSession) shell.Player!, optionN);
+ vote.CastVote(shell.Player!, optionN);
}
}
-using Robust.Server.Player;
+using Robust.Shared.Player;
namespace Content.Server.Voting
/// <summary>
/// The player that started the vote. Used to keep track of player cooldowns to avoid vote spam.
/// </summary>
- public IPlayerSession? InitiatorPlayer { get; set; }
+ public ICommonSession? InitiatorPlayer { get; set; }
/// <summary>
/// The shown title of the vote.
/// Sets <see cref="InitiatorPlayer"/> and <see cref="InitiatorText"/>
/// by setting the latter to the player's name.
/// </summary>
- public void SetInitiator(IPlayerSession player)
+ public void SetInitiator(ICommonSession player)
{
InitiatorPlayer = player;
InitiatorText = player.Name;
}
- public void SetInitiatorOrServer(IPlayerSession? player)
+ public void SetInitiatorOrServer(ICommonSession? player)
{
if (player != null)
{
using Content.Shared.Tag;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
-using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using Robust.Shared.Player;
-using Robust.Shared.Players;
using Robust.Shared.Random;
namespace Content.Server.Weapons.Melee;
EntityCoordinates targetCoordinates;
Angle targetLocalAngle;
- if (session is IPlayerSession pSession)
+ if (session is { } pSession)
{
(targetCoordinates, targetLocalAngle) = _lag.GetCoordinatesAngle(target, pSession);
}
using Content.Shared.Tools.Components;
using Content.Shared.Wires;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;
wires.WireSeed), ui: ui);
}
- public void OpenUserInterface(EntityUid uid, IPlayerSession player)
+ public void OpenUserInterface(EntityUid uid, ICommonSession player)
{
if (_uiSystem.TryGetUi(uid, WiresUiKey.Key, out var ui))
_uiSystem.OpenUi(ui, player);
using Content.Shared.Xenoarchaeology.XenoArtifacts;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
-using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
/// <param name="args"></param>
private void OnServerSelectionMessage(EntityUid uid, AnalysisConsoleComponent component, AnalysisConsoleServerSelectionMessage args)
{
- _ui.TryOpen(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session);
+ _ui.TryOpen(uid, ResearchClientUiKey.Key, args.Session);
}
/// <summary>
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Shared.Administration.Managers;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Physics.Systems;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Shared.Buckle;
using Content.Shared.Localizations;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Shared.Hands.EntitySystems;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Content.Shared.Mind.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Network;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Shared.Mind
{
using Content.Shared.Players;
using Robust.Shared.Map;
using Robust.Shared.Network;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Shared.Mind;
}
public bool TryGetMind(
- PlayerData player,
+ ContentPlayerData contentPlayer,
out EntityUid mindId,
[NotNullWhen(true)] out MindComponent? mind)
{
- mindId = player.Mind ?? default;
+ mindId = contentPlayer.Mind ?? default;
return TryComp(mindId, out mind);
}
-using Robust.Shared.Players;
-
namespace Content.Shared.Movement.Events;
/// <summary>
using Content.Shared.Input;
using Content.Shared.Movement.Components;
using Robust.Shared.Input.Binding;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Serialization;
namespace Content.Shared.Movement.Systems;
using Content.Shared.Movement.Events;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Content.Shared.GameTicking;
using Content.Shared.Mind;
using Robust.Shared.Network;
-using Robust.Shared.Player;
namespace Content.Shared.Players;
/// <summary>
/// Content side for all data that tracks a player session.
-/// Use <see cref="PlaIPlayerDatarver.Player.IPlayerData)"/> to retrieve this from an <see cref="IPlayerData"/>.
+/// Use <see cref="PlaIPlayerDatarver.Player.IPlayerData)"/> to retrieve this from an <see cref="PlayerData"/>.
/// <remarks>Not currently used on the client.</remarks>
/// </summary>
-public sealed class PlayerData
+public sealed class ContentPlayerData
{
/// <summary>
/// The session ID of the player owning this data.
/// </summary>
public bool ExplicitlyDeadminned { get; set; }
- public PlayerData(NetUserId userId, string name)
+ public ContentPlayerData(NetUserId userId, string name)
{
UserId = userId;
Name = name;
}
-}
-
-
-public static class PlayerDataExt
-{
- /// <summary>
- /// Gets the correctly cast instance of content player data from an engine player data storage.
- /// </summary>
- public static PlayerData? ContentData(this IPlayerData data)
- {
- return (PlayerData?) data.ContentDataUncast;
- }
-}
+}
\ No newline at end of file
--- /dev/null
+using Robust.Shared.Player;
+
+namespace Content.Shared.Players;
+
+public static class PlayerDataExt
+{
+ /// <summary>
+ /// Gets the correctly cast instance of content player data from an engine player data storage.
+ /// </summary>
+ public static ContentPlayerData? ContentData(this SessionData data)
+ {
+ return (ContentPlayerData?) data.ContentDataUncast;
+ }
+
+ /// <summary>
+ /// Gets the correctly cast instance of content player data from an engine player data storage.
+ /// </summary>
+ public static ContentPlayerData? ContentData(this ICommonSession session)
+ {
+ return session.Data.ContentData();
+ }
+
+ /// <summary>
+ /// Gets the mind that is associated with this player.
+ /// </summary>
+ public static EntityUid? GetMind(this ICommonSession session)
+ {
+ return session.Data.ContentData()?.Mind;
+ }
+}
\ No newline at end of file
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Shared.Players;
/// </summary>
public abstract class SharedPlayerSystem : EntitySystem
{
- public abstract PlayerData? ContentData(ICommonSession? session);
+ public abstract ContentPlayerData? ContentData(ICommonSession? session);
}
using Robust.Shared.Map;
using Robust.Shared.Player;
-using Robust.Shared.Players;
using Robust.Shared.Serialization;
namespace Content.Shared.Popups
using Robust.Shared.Physics;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
namespace Content.Shared.Pulling
{
using System.Linq;
using Content.Shared.Players;
using Content.Shared.Players.PlayTimeTracking;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
-using Robust.Shared.Players;
+using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;