using Content.Shared.GameTicking;
using Content.Shared.Mind.Components;
using Robust.Shared.Network;
using Robust.Shared.Players;
namespace Content.Shared.Mind
{
///
/// This is added as a component to mind entities, not to player entities.
/// for the one that is added to players.
/// A mind represents the IC "mind" of a player.
/// Roles are attached as components to its owning entity.
///
///
/// 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.
///
[RegisterComponent]
public sealed partial class MindComponent : Component
{
internal readonly List Objectives = new();
///
/// The session ID of the player owning this mind.
///
[ViewVariables, Access(typeof(SharedMindSystem))]
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(SharedMindSystem))]
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(SharedMindSystem))]
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(SharedMindSystem))]
public EntityUid? OwnedEntity { get; set; }
// TODO move objectives out of mind component
///
/// An enumerable over all the objective entities 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(SharedMindSystem), typeof(SharedGameTicker))]
public ICommonSession? Session { get; set; }
}
}