2023-11-03 19:55:32 -04:00
|
|
|
using Content.Shared.GameTicking;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind.Components;
|
2023-10-25 01:23:56 +11:00
|
|
|
using Robust.Shared.GameStates;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Shared.Network;
|
2023-10-28 09:59:53 +11:00
|
|
|
using Robust.Shared.Player;
|
2018-08-21 00:59:04 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
namespace Content.Shared.Mind;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This component stores information about a player/mob mind. The component will be attached to a mind-entity
|
|
|
|
|
/// which is stored in null-space. The entity that is currently "possessed" by the mind will have a
|
|
|
|
|
/// <see cref="MindContainerComponent"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Roles are attached as components on the mind-entity 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.
|
|
|
|
|
///
|
|
|
|
|
/// Minds are stored in null-space, and are thus generally not set to players unless that player is the owner
|
|
|
|
|
/// of the mind. As a result it should be safe to network "secret" information like roles & objectives
|
|
|
|
|
/// </remarks>
|
|
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
|
|
|
|
public sealed partial class MindComponent : Component
|
2018-08-21 00:59:04 +02:00
|
|
|
{
|
2024-08-15 20:26:57 +02:00
|
|
|
[DataField, AutoNetworkedField]
|
|
|
|
|
public List<EntityUid> Objectives = new();
|
|
|
|
|
|
2018-08-21 00:59:04 +02:00
|
|
|
/// <summary>
|
2024-08-15 20:26:57 +02:00
|
|
|
/// The session ID of the player owning this mind.
|
2018-08-21 00:59:04 +02:00
|
|
|
/// </summary>
|
2024-08-15 20:26:57 +02:00
|
|
|
[DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))]
|
|
|
|
|
public NetUserId? UserId { get; set; }
|
2018-08-21 00:59:04 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// 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)
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))]
|
|
|
|
|
public NetUserId? OriginalOwnerUserId { get; set; }
|
2021-11-15 18:14:34 +00:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// The first entity that this mind controlled. Used for round end information.
|
|
|
|
|
/// Might be relevant if the player has ghosted since.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField, AutoNetworkedField]
|
|
|
|
|
public NetEntity? OriginalOwnedEntity;
|
|
|
|
|
// This is a net entity, because this field currently ddoes not get set to null when this entity is deleted.
|
|
|
|
|
// This is a lazy way to ensure that people check that the entity still exists.
|
|
|
|
|
// TODO MIND Fix this properly by adding an OriginalMindContainerComponent or something like that.
|
2023-08-01 10:46:06 +12:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
[ViewVariables]
|
|
|
|
|
public bool IsVisitingEntity => VisitingEntity != null;
|
2018-09-20 18:19:04 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
[DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))]
|
|
|
|
|
public EntityUid? VisitingEntity { get; set; }
|
2018-09-20 18:19:04 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
[ViewVariables]
|
|
|
|
|
public EntityUid? CurrentEntity => VisitingEntity ?? OwnedEntity;
|
2018-09-20 18:19:04 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public string? CharacterName { get; set; }
|
2020-04-18 00:38:19 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// The time of death for this Mind.
|
|
|
|
|
/// Can be null - will be null if the Mind is not considered "dead".
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField]
|
|
|
|
|
public TimeSpan? TimeOfDeath { get; set; }
|
2021-11-11 11:17:23 -04:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// The entity currently owned by this mind.
|
|
|
|
|
/// Can be null.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))]
|
|
|
|
|
public EntityUid? OwnedEntity { get; set; }
|
2018-08-21 00:59:04 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// An enumerable over all the objective entities this mind has.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables, Obsolete("Use Objectives field")]
|
|
|
|
|
public IEnumerable<EntityUid> AllObjectives => Objectives;
|
2020-11-22 08:38:07 +01:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Prevents user from ghosting out
|
|
|
|
|
/// </summary>
|
2024-10-10 10:48:56 +02:00
|
|
|
[DataField]
|
2024-08-15 20:26:57 +02:00
|
|
|
public bool PreventGhosting { get; set; }
|
2022-12-19 21:55:45 -06:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Prevents user from suiciding
|
|
|
|
|
/// </summary>
|
2024-10-10 10:48:56 +02:00
|
|
|
[DataField]
|
2024-08-15 20:26:57 +02:00
|
|
|
public bool PreventSuicide { get; set; }
|
2023-02-16 18:36:10 -06:00
|
|
|
|
2024-10-10 10:48:56 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Mind Role Entities belonging to this Mind
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField, AutoNetworkedField]
|
|
|
|
|
public List<EntityUid> MindRoles = new List<EntityUid>();
|
|
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
/// <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; }
|
2018-08-21 00:59:04 +02:00
|
|
|
}
|