@@ -8,6 +8,7 @@ using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Bed.Cryostorage;
|
||||
@@ -17,13 +18,14 @@ namespace Content.Shared.Bed.Cryostorage;
|
||||
/// </summary>
|
||||
public abstract class SharedCryostorageSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly ISharedAdminLogManager AdminLog = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ISharedPlayerManager _player = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] protected readonly IGameTiming Timing = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] protected readonly ISharedAdminLogManager AdminLog = default!;
|
||||
[Dependency] protected readonly SharedMindSystem Mind = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
|
||||
protected EntityUid? PausedMap { get; private set; }
|
||||
|
||||
@@ -123,7 +125,8 @@ public abstract class SharedCryostorageSystem : EntitySystem
|
||||
if (args.Dragged == args.User)
|
||||
return;
|
||||
|
||||
if (!Mind.TryGetMind(args.Dragged, out _, out var mindComp) || mindComp.Session?.AttachedEntity != args.Dragged)
|
||||
if (!_player.TryGetSessionByEntity(args.Dragged, out var session) ||
|
||||
session.AttachedEntity != args.Dragged)
|
||||
return;
|
||||
|
||||
args.CanDrop = false;
|
||||
|
||||
@@ -113,12 +113,4 @@ public sealed partial class MindComponent : Component
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId? Subtype;
|
||||
|
||||
/// <summary>
|
||||
/// The session of the player owning this mind.
|
||||
/// Can be null, in which case the player is currently not logged in.
|
||||
/// </summary>
|
||||
[ViewVariables, Access(typeof(SharedMindSystem), typeof(SharedGameTicker))]
|
||||
// TODO remove this after moving IPlayerManager functions to shared
|
||||
public ICommonSession? Session { get; set; }
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public abstract partial class SharedMindSystem : EntitySystem
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedObjectivesSystem _objectives = default!;
|
||||
[Dependency] private readonly SharedPlayerSystem _player = default!;
|
||||
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
||||
|
||||
@@ -153,23 +154,31 @@ public abstract partial class SharedMindSystem : EntitySystem
|
||||
if (!mindContainer.ShowExamineInfo || !args.IsInDetailsRange)
|
||||
return;
|
||||
|
||||
// TODO predict we can't right now because session stuff isnt networked
|
||||
// TODO: Move this out of the SharedMindSystem into its own comp and predict it
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
var dead = _mobState.IsDead(uid);
|
||||
var hasUserId = CompOrNull<MindComponent>(mindContainer.Mind)?.UserId;
|
||||
var hasSession = CompOrNull<MindComponent>(mindContainer.Mind)?.Session;
|
||||
var mind = CompOrNull<MindComponent>(mindContainer.Mind);
|
||||
var hasUserId = mind?.UserId;
|
||||
var hasActiveSession = hasUserId != null && _playerManager.ValidSessionId(hasUserId.Value);
|
||||
|
||||
// Scenarios:
|
||||
// 1. Dead + No User ID: Entity is permanently dead with no player ever attached
|
||||
// 2. Dead + Has User ID + No Session: Player died and disconnected
|
||||
// 3. Dead + Has Session: Player is dead but still connected
|
||||
// 4. Alive + No User ID: Entity was never controlled by a player
|
||||
// 5. Alive + No Session: Player disconnected while alive (SSD)
|
||||
|
||||
if (dead && hasUserId == null)
|
||||
args.PushMarkup($"[color=mediumpurple]{Loc.GetString("comp-mind-examined-dead-and-irrecoverable", ("ent", uid))}[/color]");
|
||||
else if (dead && hasSession == null)
|
||||
else if (dead && !hasActiveSession)
|
||||
args.PushMarkup($"[color=yellow]{Loc.GetString("comp-mind-examined-dead-and-ssd", ("ent", uid))}[/color]");
|
||||
else if (dead)
|
||||
args.PushMarkup($"[color=red]{Loc.GetString("comp-mind-examined-dead", ("ent", uid))}[/color]");
|
||||
else if (hasUserId == null)
|
||||
args.PushMarkup($"[color=mediumpurple]{Loc.GetString("comp-mind-examined-catatonic", ("ent", uid))}[/color]");
|
||||
else if (hasSession == null)
|
||||
else if (!hasActiveSession)
|
||||
args.PushMarkup($"[color=yellow]{Loc.GetString("comp-mind-examined-ssd", ("ent", uid))}[/color]");
|
||||
}
|
||||
|
||||
@@ -460,12 +469,6 @@ public abstract partial class SharedMindSystem : EntitySystem
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetSession(EntityUid? mindId, [NotNullWhen(true)] out ICommonSession? session)
|
||||
{
|
||||
session = null;
|
||||
return TryComp(mindId, out MindComponent? mind) && (session = mind.Session) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a mind from uid and/or MindContainerComponent. Used for null checks.
|
||||
/// </summary>
|
||||
|
||||
@@ -10,6 +10,7 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -18,12 +19,13 @@ namespace Content.Shared.Roles;
|
||||
|
||||
public abstract class SharedRoleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly SharedMindSystem _minds = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] protected readonly ISharedPlayerManager Player = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedMindSystem _minds = default!;
|
||||
|
||||
private JobRequirementOverridePrototype? _requirementOverride;
|
||||
|
||||
@@ -256,7 +258,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
Dirty(mind, comp);
|
||||
|
||||
// Update player character window
|
||||
if (_minds.TryGetSession(mind, out var session))
|
||||
if (Player.TryGetSessionById(comp.UserId, out var session))
|
||||
RaiseNetworkEvent(new MindRoleTypeChangedEvent(), session.Channel);
|
||||
else
|
||||
{
|
||||
@@ -589,8 +591,11 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
/// </summary>
|
||||
public void MindPlaySound(EntityUid mindId, SoundSpecifier? sound, MindComponent? mind = null)
|
||||
{
|
||||
if (Resolve(mindId, ref mind) && mind.Session != null)
|
||||
_audio.PlayGlobal(sound, mind.Session);
|
||||
if (!Resolve(mindId, ref mind))
|
||||
return;
|
||||
|
||||
if (Player.TryGetSessionById(mind.UserId, out var session))
|
||||
_audio.PlayGlobal(sound, session);
|
||||
}
|
||||
|
||||
// TODO ROLES Change to readonly.
|
||||
|
||||
Reference in New Issue
Block a user