Revert "Update submodule to 172.0.0 (#21222)" (#21225)

This commit is contained in:
metalgearsloth
2023-10-24 21:55:20 +11:00
committed by GitHub
parent 517aea8bc3
commit a2bbda43cc
249 changed files with 1049 additions and 967 deletions

View File

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

View File

@@ -1,86 +1,84 @@
using Content.Shared.GameTicking;
using Content.Shared.Mind.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Players;
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"/>.
/// This is added as a component to mind entities, not to player entities.
/// <see cref="MindContainerComponent"/> 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.
/// </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)]
[RegisterComponent]
public sealed partial class MindComponent : Component
{
[DataField, AutoNetworkedField]
public List<EntityUid> Objectives = new();
internal readonly List<EntityUid> Objectives = new();
/// <summary>
/// The session ID of the player owning this mind.
/// </summary>
[DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))]
[ViewVariables, Access(typeof(SharedMindSystem))]
public NetUserId? UserId { get; set; }
/// <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))]
[ViewVariables, Access(typeof(SharedMindSystem))]
public NetUserId? OriginalOwnerUserId { get; set; }
/// <summary>
/// The first entity that this mind controlled. Used for round end information.
/// Entity UID for the first entity that this mind controlled. Used for round end.
/// 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.
[ViewVariables] public EntityUid? OriginalOwnedEntity;
[ViewVariables]
public bool IsVisitingEntity => VisitingEntity != null;
[DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))]
[ViewVariables, Access(typeof(SharedMindSystem))]
public EntityUid? VisitingEntity { get; set; }
[ViewVariables]
public EntityUid? CurrentEntity => VisitingEntity ?? OwnedEntity;
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
[ViewVariables(VVAccess.ReadWrite)]
public string? CharacterName { get; set; }
/// <summary>
/// The time of death for this Mind.
/// Can be null - will be null if the Mind is not considered "dead".
/// </summary>
[DataField]
[ViewVariables]
public TimeSpan? TimeOfDeath { get; set; }
/// <summary>
/// The component currently owned by this mind.
/// Can be null.
/// </summary>
[ViewVariables] public MindContainerComponent? OwnedComponent;
/// <summary>
/// The entity currently owned by this mind.
/// Can be null.
/// </summary>
[DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))]
[ViewVariables, Access(typeof(SharedMindSystem))]
public EntityUid? OwnedEntity { get; set; }
// TODO move objectives out of mind component
/// <summary>
/// An enumerable over all the objective entities this mind has.
/// </summary>
[ViewVariables, Obsolete("Use Objectives field")]
[ViewVariables]
public IEnumerable<EntityUid> AllObjectives => Objectives;
/// <summary>
@@ -102,7 +100,6 @@ namespace Content.Shared.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; }
}
}

View File

@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Examine;
@@ -13,7 +12,7 @@ using Content.Shared.Objectives.Systems;
using Content.Shared.Players;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Utility;
namespace Content.Shared.Mind;
@@ -26,7 +25,7 @@ public abstract class SharedMindSystem : EntitySystem
[Dependency] private readonly SharedPlayerSystem _player = default!;
[Dependency] private readonly MetaDataSystem _metadata = default!;
[ViewVariables]
// This is dictionary is required to track the minds of disconnected players that may have had their entity deleted.
protected readonly Dictionary<NetUserId, EntityUid> UserMinds = new();
public override void Initialize()
@@ -37,7 +36,6 @@ public abstract class SharedMindSystem : EntitySystem
SubscribeLocalEvent<MindContainerComponent, SuicideEvent>(OnSuicide);
SubscribeLocalEvent<VisitingMindComponent, EntityTerminatingEvent>(OnVisitingTerminating);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnReset);
SubscribeLocalEvent<MindComponent, ComponentStartup>(OnMindStartup);
}
public override void Shutdown()
@@ -46,29 +44,6 @@ public abstract class SharedMindSystem : EntitySystem
WipeAllMinds();
}
private void OnMindStartup(EntityUid uid, MindComponent component, ComponentStartup args)
{
if (component.UserId == null)
return;
if (UserMinds.TryAdd(component.UserId.Value, uid))
return;
var existing = UserMinds[component.UserId.Value];
if (existing == uid)
return;
if (!Exists(existing))
{
Log.Error($"Found deleted entity in mind dictionary while initializing mind {ToPrettyString(uid)}");
UserMinds[component.UserId.Value] = uid;
return;
}
Log.Error($"Encountered a user {component.UserId} that is already assigned to a mind while initializing mind {ToPrettyString(uid)}. Ignoring user field.");
component.UserId = null;
}
private void OnReset(RoundRestartCleanupEvent ev)
{
WipeAllMinds();
@@ -76,22 +51,12 @@ public abstract class SharedMindSystem : EntitySystem
public virtual void WipeAllMinds()
{
Log.Info($"Wiping all minds");
foreach (var mind in UserMinds.Values.ToArray())
foreach (var mind in UserMinds.Values)
{
WipeMind(mind);
}
if (UserMinds.Count == 0)
return;
foreach (var mind in UserMinds.Values)
{
if (Exists(mind))
Log.Error($"Failed to wipe mind: {ToPrettyString(mind)}");
}
UserMinds.Clear();
DebugTools.Assert(UserMinds.Count == 0);
}
public EntityUid? GetMind(NetUserId user)
@@ -115,26 +80,6 @@ public abstract class SharedMindSystem : EntitySystem
return false;
}
public bool TryGetMind(NetUserId user, [NotNullWhen(true)] out Entity<MindComponent>? mind)
{
if (!TryGetMind(user, out var mindId, out var mindComp))
{
mind = null;
return false;
}
mind = (mindId.Value, mindComp);
return true;
}
public Entity<MindComponent> GetOrCreateMind(NetUserId user)
{
if (!TryGetMind(user, out var mind))
mind = CreateMind(user);
return mind.Value;
}
private void OnVisitingTerminating(EntityUid uid, VisitingMindComponent component, ref EntityTerminatingEvent args)
{
if (component.MindId != null)
@@ -183,7 +128,7 @@ public abstract class SharedMindSystem : EntitySystem
return null;
}
public Entity<MindComponent> CreateMind(NetUserId? userId, string? name = null)
public EntityUid CreateMind(NetUserId? userId, string? name = null)
{
var mindId = Spawn(null, MapCoordinates.Nullspace);
_metadata.SetEntityName(mindId, name == null ? "mind" : $"mind ({name})");
@@ -191,7 +136,7 @@ public abstract class SharedMindSystem : EntitySystem
mind.CharacterName = name;
SetUserId(mindId, userId, mind);
return (mindId, mind);
return mindId;
}
/// <summary>
@@ -250,7 +195,7 @@ public abstract class SharedMindSystem : EntitySystem
/// Cleans up the VisitingEntity.
/// </summary>
/// <param name="mind"></param>
protected void RemoveVisitingEntity(EntityUid mindId, MindComponent mind)
protected void RemoveVisitingEntity(MindComponent mind)
{
if (mind.VisitingEntity == null)
return;
@@ -265,7 +210,6 @@ public abstract class SharedMindSystem : EntitySystem
RemCompDeferred(oldVisitingEnt, visitComp);
}
Dirty(mindId, mind);
RaiseLocalEvent(oldVisitingEnt, new MindUnvisitedMessage(), true);
}
@@ -284,7 +228,7 @@ public abstract class SharedMindSystem : EntitySystem
if (mindId == null || !Resolve(mindId.Value, ref mind, false))
return;
TransferTo(mindId.Value, null, createGhost:false, mind: mind);
TransferTo(mindId.Value, null, mind: mind);
SetUserId(mindId.Value, null, mind: mind);
}
@@ -409,11 +353,11 @@ public abstract class SharedMindSystem : EntitySystem
}
public bool TryGetMind(
ContentPlayerData contentPlayer,
PlayerData player,
out EntityUid mindId,
[NotNullWhen(true)] out MindComponent? mind)
{
mindId = contentPlayer.Mind ?? default;
mindId = player.Mind ?? default;
return TryComp(mindId, out mind);
}
@@ -447,6 +391,21 @@ public abstract class SharedMindSystem : EntitySystem
return TryComp(mindContainer.Mind, out role);
}
/// <summary>
/// Sets the Mind's OwnedComponent and OwnedEntity
/// </summary>
/// <param name="mind">Mind to set OwnedComponent and OwnedEntity on</param>
/// <param name="uid">Entity owned by <paramref name="mind"/></param>
/// <param name="mindContainerComponent">MindContainerComponent owned by <paramref name="mind"/></param>
protected void SetOwnedEntity(MindComponent mind, EntityUid? uid, MindContainerComponent? mindContainerComponent)
{
if (uid != null)
Resolve(uid.Value, ref mindContainerComponent);
mind.OwnedEntity = uid;
mind.OwnedComponent = mindContainerComponent;
}
/// <summary>
/// Sets the Mind's UserId, Session, and updates the player's PlayerData. This should have no direct effect on the
/// entity that any mind is connected to, except as a side effect of the fact that it may change a player's