Merge ActorSystem and IPlayerManager (#21314)

This commit is contained in:
Leon Friedrich
2023-11-11 13:08:10 +11:00
committed by GitHub
parent a367097c33
commit 654cc7f071
25 changed files with 42 additions and 42 deletions

View File

@@ -6,6 +6,7 @@ using Robust.Client.Player;
using Robust.Shared.ContentPack;
using Robust.Shared.GameStates;
using Robust.Shared.Input.Binding;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Client.Player;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Client.Alerts;

View File

@@ -12,6 +12,7 @@ using Robust.Client.Player;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Client.Construction

View File

@@ -1,6 +1,7 @@
using Content.Shared.Drugs;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Drugs;

View File

@@ -1,6 +1,7 @@
using Content.Shared.Drunk;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Drunk;

View File

@@ -2,6 +2,7 @@ using Robust.Client.Graphics;
using Robust.Client.Player;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.GameTicking;
using Robust.Shared.Player;
namespace Content.Client.Eye.Blinding;

View File

@@ -1,6 +1,7 @@
using Content.Shared.Eye.Blinding.Components;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Eye.Blinding;

View File

@@ -5,6 +5,7 @@ using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Client.Eye;

View File

@@ -5,6 +5,7 @@ using Robust.Client.Console;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Ghost
{

View File

@@ -13,6 +13,7 @@ using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Client.Hands.Systems

View File

@@ -14,6 +14,7 @@ using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Containers;
using Robust.Shared.Input.Binding;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Client.Inventory

View File

@@ -2,6 +2,7 @@ using Content.Shared.GameTicking;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Overlays;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Pulling.Components;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Client.Physics.Controllers

View File

@@ -1,8 +1,8 @@
using Content.Shared.Movement.Components;
using Robust.Client.Player;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Network;
using Robust.Shared.Player;
namespace Content.Client.Replay.Spectator;

View File

@@ -6,6 +6,7 @@ using Robust.Client.Player;
using Robust.Client.Replays.Playback;
using Robust.Client.State;
using Robust.Shared.Console;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Markdown.Mapping;
namespace Content.Client.Replay.Spectator;

View File

@@ -2,6 +2,7 @@ using System.Numerics;
using Content.Shared.Traits.Assorted;
using Robust.Shared.Random;
using Robust.Client.Player;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Client.Traits;

View File

@@ -8,6 +8,7 @@ using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Player;
namespace Content.Client.UserInterface.Systems.DamageOverlays;

View File

@@ -5,7 +5,6 @@ using Content.Client.Construction;
using Content.Client.Examine;
using Content.IntegrationTests.Pair;
using Content.Server.Body.Systems;
using Content.Server.Players;
using Content.Server.Stack;
using Content.Server.Tools;
using Content.Shared.Body.Part;
@@ -17,8 +16,6 @@ using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Map;
@@ -102,7 +99,6 @@ public abstract partial class InteractionTest
protected ToolSystem ToolSys = default!;
protected InteractionTestSystem STestSystem = default!;
protected SharedTransformSystem Transform = default!;
protected ActorSystem Actor = default!;
protected ISawmill SLogger = default!;
// CLIENT dependencies
@@ -161,7 +157,6 @@ public abstract partial class InteractionTest
SConstruction = SEntMan.System<Server.Construction.ConstructionSystem>();
STestSystem = SEntMan.System<InteractionTestSystem>();
Stack = SEntMan.System<StackSystem>();
Actor = SEntMan.System<ActorSystem>();
SLogger = Server.ResolveDependency<ILogManager>().RootSawmill;
// client dependencies
@@ -197,17 +192,17 @@ public abstract partial class InteractionTest
// Mind system is a time vampire
SEntMan.System<SharedMindSystem>().WipeMind(ServerSession.ContentData()?.Mind);
old = cPlayerMan.LocalPlayer.ControlledEntity;
old = cPlayerMan.LocalEntity;
Player = SEntMan.GetNetEntity(SEntMan.SpawnEntity(PlayerPrototype, SEntMan.GetCoordinates(PlayerCoords)));
var serverPlayerEnt = SEntMan.GetEntity(Player);
Actor.Attach(serverPlayerEnt, ServerSession);
Server.PlayerMan.SetAttachedEntity(ServerSession, serverPlayerEnt);
Hands = SEntMan.GetComponent<HandsComponent>(serverPlayerEnt);
DoAfters = SEntMan.GetComponent<DoAfterComponent>(serverPlayerEnt);
});
// Check player got attached.
await RunTicks(5);
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalPlayer.ControlledEntity), Is.EqualTo(Player));
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalEntity), Is.EqualTo(Player));
// Delete old player entity.
await Server.WaitPost(() =>
@@ -234,7 +229,7 @@ public abstract partial class InteractionTest
await Pair.ReallyBeIdle(5);
Assert.Multiple(() =>
{
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalPlayer.ControlledEntity), Is.EqualTo(Player));
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalEntity), Is.EqualTo(Player));
Assert.That(sPlayerMan.GetSessionByUserId(ClientSession.UserId).AttachedEntity, Is.EqualTo(SEntMan.GetEntity(Player)));
});
}

View File

@@ -1,19 +1,7 @@
using Content.Shared.Alert;
using Robust.Server.GameObjects;
namespace Content.Server.Alert;
internal sealed class ServerAlertsSystem : AlertsSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AlertsComponent, PlayerAttachedEvent>(OnPlayerAttached);
}
private void OnPlayerAttached(EntityUid uid, AlertsComponent component, PlayerAttachedEvent args)
{
Dirty(component);
}
}

View File

@@ -1,6 +1,6 @@
using Content.Shared.ActionBlocker;
using Content.Shared.Chat.TypingIndicator;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
namespace Content.Server.Chat.TypingIndicator;

View File

@@ -4,7 +4,6 @@ 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;
@@ -18,7 +17,6 @@ namespace Content.Server.GameTicking
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IServerDbManager _dbManager = default!;
[Dependency] private readonly ActorSystem _actor = default!;
private void InitializePlayer()
{
@@ -102,7 +100,7 @@ namespace Content.Server.GameTicking
}
else
{
if (_actor.Attach(mind.CurrentEntity, session))
if (_playerManager.SetAttachedEntity(session, mind.CurrentEntity))
{
PlayerJoinGame(session);
}

View File

@@ -7,10 +7,8 @@ using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Players;
using Robust.Server.GameObjects;
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;
@@ -21,10 +19,8 @@ namespace Content.Server.Mind;
public sealed class MindSystem : SharedMindSystem
{
[Dependency] private readonly ActorSystem _actor = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IMapManager _maps = default!;
[Dependency] private readonly IPlayerManager _players = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly SharedGhostSystem _ghosts = default!;
@@ -176,7 +172,7 @@ public sealed class MindSystem : SharedMindSystem
}
if (GetSession(mind) is { } session)
_actor.Attach(entity, session);
_players.SetAttachedEntity(session, entity);
mind.VisitingEntity = entity;
@@ -203,7 +199,7 @@ public sealed class MindSystem : SharedMindSystem
var owned = mind.OwnedEntity;
if (GetSession(mind) is { } session)
_actor.Attach(owned, session);
_players.SetAttachedEntity(session, owned);
if (owned.HasValue)
{
@@ -292,7 +288,7 @@ public sealed class MindSystem : SharedMindSystem
var session = GetSession(mind);
if (session != null && !alreadyAttached && mind.VisitingEntity == null)
{
_actor.Attach(entity, session, true);
_players.SetAttachedEntity(session, entity, true);
DebugTools.Assert(session.AttachedEntity == entity, $"Failed to attach entity.");
Log.Info($"Session {session.Name} transferred to entity {entity}.");
}
@@ -333,7 +329,7 @@ public sealed class MindSystem : SharedMindSystem
if (mind.Session != null)
{
_actor.Attach(null, GetSession(mind)!);
_players.SetAttachedEntity(GetSession(mind), null);
mind.Session = null;
}
@@ -367,7 +363,7 @@ public sealed class MindSystem : SharedMindSystem
{
mind.Session = ret;
_pvsOverride.AddSessionOverride(mindId, ret);
_actor.Attach(mind.CurrentEntity, ret);
_players.SetAttachedEntity(ret, mind.CurrentEntity);
}
// session may be null, but user data may still exist for disconnected players.

View File

@@ -1,16 +1,14 @@
using System.Numerics;
using Content.Server.Cargo.Components;
using Content.Server.Shuttle.Components;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Pulling.Components;
using Content.Shared.Shuttles.Components;
using Content.Shared.Shuttles.Systems;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
namespace Content.Server.Physics.Controllers
{

View File

@@ -1,8 +1,8 @@
using Content.Server.Administration.Logs;
using Content.Shared.Database;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Placement;
using Robust.Shared.Player;
namespace Content.Server.Placement;
@@ -10,7 +10,7 @@ public sealed class PlacementLoggerSystem : EntitySystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly ActorSystem _actorSystem = default!;
[Dependency] private readonly ISharedPlayerManager _player = default!;
public override void Initialize()
{
@@ -21,7 +21,8 @@ public sealed class PlacementLoggerSystem : EntitySystem
private void OnEntityPlacement(PlacementEntityEvent ev)
{
_actorSystem.TryGetActorFromUserId(ev.PlacerNetUserId, out var actor, out var actorEntity);
_player.TryGetSessionById(ev.PlacerNetUserId, out var actor);
var actorEntity = actor?.AttachedEntity;
var logType = ev.PlacementEventAction switch
{
@@ -43,7 +44,8 @@ public sealed class PlacementLoggerSystem : EntitySystem
private void OnTilePlacement(PlacementTileEvent ev)
{
_actorSystem.TryGetActorFromUserId(ev.PlacerNetUserId, out var actor, out var actorEntity);
_player.TryGetSessionById(ev.PlacerNetUserId, out var actor);
var actorEntity = actor?.AttachedEntity;
if (actorEntity != null)
_adminLogger.Add(LogType.Tile, LogImpact.High,

View File

@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Shared.Alert;
@@ -166,6 +167,7 @@ public abstract class AlertsSystem : EntitySystem
SubscribeLocalEvent<AlertsComponent, ComponentStartup>(HandleComponentStartup);
SubscribeLocalEvent<AlertsComponent, ComponentShutdown>(HandleComponentShutdown);
SubscribeLocalEvent<AlertsComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeNetworkEvent<ClickAlertEvent>(HandleClickAlert);
@@ -239,4 +241,9 @@ public abstract class AlertsSystem : EntitySystem
alert.OnClick?.AlertClicked(player.Value);
}
private void OnPlayerAttached(EntityUid uid, AlertsComponent component, PlayerAttachedEvent args)
{
Dirty(uid, component);
}
}