using System.Linq; using Content.Server.GameTicking; using Content.Server.Mind.Components; using Content.Server.Objectives; using Content.Server.Roles; using Robust.Server.Player; using Robust.Shared.Network; namespace Content.Server.Mind { /// /// A mind represents the IC "mind" of a player. Stores roles currently. /// /// /// Think of it like this: if a player is supposed to have their memories, /// their mind follows along. /// /// Things such as respawning do not follow, because you're a new character. /// Getting borged, cloned, turned into a catbeast, etc... will keep it following you. /// public sealed class Mind { internal readonly ISet Roles = new HashSet(); internal readonly List Objectives = new(); public string Briefing = String.Empty; /// /// Creates the new mind. /// Note: the Mind is NOT initially attached! /// The provided UserId is solely for tracking of intended owner. /// public Mind() { } /// /// The session ID of the player owning this mind. /// [ViewVariables, Access(typeof(MindSystem))] public NetUserId? UserId { get; set; } /// /// The session ID of the original owner, if any. /// May end up used for round-end information (as the owner may have abandoned Mind since) /// [ViewVariables, Access(typeof(MindSystem))] public NetUserId? OriginalOwnerUserId { get; set; } /// /// Entity UID for the first entity that this mind controlled. Used for round end. /// Might be relevant if the player has ghosted since. /// [ViewVariables] public EntityUid? OriginalOwnedEntity; [ViewVariables] public bool IsVisitingEntity => VisitingEntity != null; [ViewVariables, Access(typeof(MindSystem))] public EntityUid? VisitingEntity { get; set; } [ViewVariables] public EntityUid? CurrentEntity => VisitingEntity ?? OwnedEntity; [ViewVariables(VVAccess.ReadWrite)] public string? CharacterName { get; set; } /// /// The time of death for this Mind. /// Can be null - will be null if the Mind is not considered "dead". /// [ViewVariables] public TimeSpan? TimeOfDeath { get; set; } /// /// The component currently owned by this mind. /// Can be null. /// [ViewVariables] public MindContainerComponent? OwnedComponent { get; internal set; } /// /// The entity currently owned by this mind. /// Can be null. /// [ViewVariables, Access(typeof(MindSystem))] public EntityUid? OwnedEntity { get; set; } /// /// An enumerable over all the roles this mind has. /// [ViewVariables] public IEnumerable AllRoles => Roles; /// /// An enumerable over all the objectives this mind has. /// [ViewVariables] public IEnumerable AllObjectives => Objectives; /// /// Prevents user from ghosting out /// [ViewVariables(VVAccess.ReadWrite)] [DataField("preventGhosting")] public bool PreventGhosting { get; set; } /// /// Prevents user from suiciding /// [ViewVariables(VVAccess.ReadWrite)] [DataField("preventSuicide")] public bool PreventSuicide { get; set; } /// /// The session of the player owning this mind. /// Can be null, in which case the player is currently not logged in. /// [ViewVariables, Access(typeof(MindSystem), typeof(GameTicker))] public IPlayerSession? Session { get; internal set; } /// /// Gets the current job /// public Job? CurrentJob => Roles.OfType().SingleOrDefault(); } }