mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 19:01:13 +03:00
* Store last player whose mind was in container * Send last player who controlled the entity's session ID along with other quick info * No more spam * Display last player info if there is no active player on entity * Better looking separator * Better looking separator but I didnt forget to ctrl s this time * newline * Address reviews * cleaning * Tiny tweaks --------- Co-authored-by: ScarKy0 <scarky0@onet.eu> Co-authored-by: Connor Huffine <chuffine@gmail.com>
151 lines
5.5 KiB
C#
151 lines
5.5 KiB
C#
using Robust.Shared.GameStates;
|
|
|
|
namespace Content.Shared.Mind.Components;
|
|
|
|
/// <summary>
|
|
/// This component indicates that this entity may have mind, which is simply an entity with a <see cref="MindComponent"/>.
|
|
/// The mind entity is not actually stored in a "container", but is simply stored in nullspace.
|
|
/// </summary>
|
|
[RegisterComponent, Access(typeof(SharedMindSystem)), NetworkedComponent, AutoGenerateComponentState]
|
|
public sealed partial class MindContainerComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// The mind controlling this mob. Can be null.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public EntityUid? Mind;
|
|
|
|
/// <summary>
|
|
/// True if we have a mind, false otherwise.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadOnly)]
|
|
public bool HasMind;
|
|
|
|
/// <summary>
|
|
/// Whether the mind will be put on a ghost after this component is shutdown.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool GhostOnShutdown = true;
|
|
|
|
/// <summary>
|
|
/// Last mind that had control of this mob. If null, it was never controlled by a player.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Because minds only get networked to their owners, this field will be <see cref="EntityUid.Invalid"/> on client unless the last mind was the one belonging to the local client.
|
|
/// </remarks>
|
|
[DataField, AutoNetworkedField]
|
|
public EntityUid? LastMind;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Base event for all other mind related events.
|
|
/// </summary>
|
|
public abstract class MindEvent : EntityEventArgs
|
|
{
|
|
/// <summary>
|
|
/// <see cref="MindComponent"/> entity currently being handled by the event.
|
|
/// </summary>
|
|
public readonly Entity<MindComponent> Mind;
|
|
|
|
/// <summary>
|
|
/// <see cref="MindContainerComponent"/> entity currently being handled by the event.
|
|
/// </summary>
|
|
public readonly Entity<MindContainerComponent> Container;
|
|
|
|
/// <summary>
|
|
/// The target entity in case the mind is being transferred. In <see cref="MindRemovedMessage" /> it means the entity that is being transferred to, and in <see cref="MindAddedMessage" /> it means the previous entity.
|
|
/// Null if the mind is being added for the first time or fully removed from entities.
|
|
/// </summary>
|
|
public readonly EntityUid? TransferEntity;
|
|
|
|
public MindEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container, EntityUid? transferEntity)
|
|
{
|
|
Mind = mind;
|
|
Container = container;
|
|
TransferEntity = transferEntity;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised directed at a mind-container when a mind gets removed.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Called after the owned entity is already set to null. TransferEntity is the entity this mind will be added to afterward, if any.
|
|
/// </remarks>
|
|
public sealed class MindRemovedMessage : MindEvent
|
|
{
|
|
public MindRemovedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container, EntityUid? transferEntity)
|
|
: base(mind, container, transferEntity)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised directed at a mind when it gets removed from a mind-container.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Called after the owned entity is already set to null. TransferEntity is the entity this mind will be added to afterward, if any.
|
|
/// </remarks>
|
|
public sealed class MindGotRemovedEvent : MindEvent
|
|
{
|
|
public MindGotRemovedEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container, EntityUid? transferEntity)
|
|
: base(mind, container, transferEntity)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised directed at a mind-container before a mind gets removed.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Called before the OwnedEntity is set to null. TransferEntity is the entity this mind will be added to afterward, if any.
|
|
/// </remarks>
|
|
public sealed class BeforeMindRemovedMessage : MindEvent
|
|
{
|
|
public BeforeMindRemovedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container, EntityUid? transferEntity)
|
|
: base(mind, container, transferEntity)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised directed at a mind before it gets removed from a mind-container.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Called before the OwnedEntity is set to null. TransferEntity is the entity this mind will be added to afterward, if any.
|
|
/// </remarks>
|
|
public sealed class BeforeMindGotRemovedEvent : MindEvent
|
|
{
|
|
public BeforeMindGotRemovedEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container, EntityUid? transferEntity)
|
|
: base(mind, container, transferEntity)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised directed at a mind-container when a mind gets added.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Called after the owned entity is already set to the new entity. TransferEntity is the previous entity that this mind owned, if any.
|
|
/// </remarks>
|
|
public sealed class MindAddedMessage : MindEvent
|
|
{
|
|
public MindAddedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container, EntityUid? transferEntity)
|
|
: base(mind, container, transferEntity)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised directed at a mind when it gets added to a mind-container.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Called after the owned entity is already set to the new entity. TransferEntity is the previous entity that this mind owned, if any.
|
|
/// </remarks>
|
|
public sealed class MindGotAddedEvent : MindEvent
|
|
{
|
|
public MindGotAddedEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container, EntityUid? transferEntity)
|
|
: base(mind, container, transferEntity)
|
|
{
|
|
}
|
|
}
|