Un-revert IPlayerManager refactor (#21244)

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

View File

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

View File

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

View File

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

View File

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