Mind tweaks & fixes (#21203)

This commit is contained in:
Leon Friedrich
2023-10-25 01:23:56 +11:00
committed by GitHub
parent a2bbda43cc
commit 0880145ac8
11 changed files with 237 additions and 111 deletions

View File

@@ -1,24 +1,25 @@
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.GameStates;
namespace Content.Shared.Mind.Components
{
/// <summary>
/// Stores a <see cref="MindComponent"/> on a mob.
/// 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))]
[RegisterComponent, Access(typeof(SharedMindSystem)), NetworkedComponent, AutoGenerateComponentState]
public sealed partial class MindContainerComponent : Component
{
/// <summary>
/// The mind controlling this mob. Can be null.
/// </summary>
[ViewVariables]
[DataField, AutoNetworkedField]
[Access(typeof(SharedMindSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends
public EntityUid? Mind { get; set; }
/// <summary>
/// True if we have a mind, false otherwise.
/// </summary>
[ViewVariables]
[MemberNotNullWhen(true, nameof(Mind))]
public bool HasMind => Mind != null;
@@ -26,7 +27,7 @@ namespace Content.Shared.Mind.Components
/// Whether examining should show information about the mind or not.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("showExamineInfo")]
[DataField("showExamineInfo"), AutoNetworkedField]
public bool ShowExamineInfo { get; set; }
/// <summary>
@@ -38,19 +39,59 @@ namespace Content.Shared.Mind.Components
public bool GhostOnShutdown { get; set; } = true;
}
public sealed class MindRemovedMessage : EntityEventArgs
public abstract class MindEvent : EntityEventArgs
{
public EntityUid OldMindId;
public MindComponent OldMind;
public readonly Entity<MindComponent> Mind;
public readonly Entity<MindContainerComponent> Container;
public MindRemovedMessage(EntityUid oldMindId, MindComponent oldMind)
public MindEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
{
OldMindId = oldMindId;
OldMind = oldMind;
Mind = mind;
Container = container;
}
}
public sealed class MindAddedMessage : EntityEventArgs
/// <summary>
/// Event raised directed at a mind-container when a mind gets removed.
/// </summary>
public sealed class MindRemovedMessage : MindEvent
{
public MindRemovedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
: base(mind, container)
{
}
}
/// <summary>
/// Event raised directed at a mind when it gets removed from a mind-container.
/// </summary>
public sealed class MindGotRemovedEvent : MindEvent
{
public MindGotRemovedEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
: base(mind, container)
{
}
}
/// <summary>
/// Event raised directed at a mind-container when a mind gets added.
/// </summary>
public sealed class MindAddedMessage : MindEvent
{
public MindAddedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
: base(mind, container)
{
}
}
/// <summary>
/// Event raised directed at a mind when it gets added to a mind-container.
/// </summary>
public sealed class MindGotAddedEvent : MindEvent
{
public MindGotAddedEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
: base(mind, container)
{
}
}
}