refactor: rework the new status effect system to use containers (#38915)

This commit is contained in:
Perry Fraser
2025-07-12 12:49:58 -04:00
committed by GitHub
parent ad34d88a49
commit dbfe05d5cc
18 changed files with 244 additions and 214 deletions

View File

@@ -0,0 +1,26 @@
using Content.Shared.Alert;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.StatusEffectNew.Components;
/// <summary>
/// Used in conjunction with <see cref="StatusEffectComponent"/> to display an alert when the status effect is present.
/// </summary>
[RegisterComponent, NetworkedComponent]
[EntityCategory("StatusEffects")]
public sealed partial class StatusEffectAlertComponent : Component
{
/// <summary>
/// Status effect indication for the player.
/// </summary>
[DataField]
public ProtoId<AlertPrototype> Alert;
/// <summary>
/// If the status effect has a set end time and this is true, a duration
/// indicator will be displayed with the alert.
/// </summary>
[DataField]
public bool ShowDuration = true;
}

View File

@@ -11,7 +11,7 @@ namespace Content.Shared.StatusEffectNew.Components;
/// Provides a link between the effect and the affected entity, and some data common to all status effects.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
[Access(typeof(SharedStatusEffectsSystem))]
[Access(typeof(StatusEffectsSystem))]
[EntityCategory("StatusEffects")]
public sealed partial class StatusEffectComponent : Component
{
@@ -21,12 +21,6 @@ public sealed partial class StatusEffectComponent : Component
[DataField, AutoNetworkedField]
public EntityUid? AppliedTo;
/// <summary>
/// Status effect indication for the player. If Null, no Alert will be displayed.
/// </summary>
[DataField]
public ProtoId<AlertPrototype>? Alert;
/// <summary>
/// When this effect will end. If Null, the effect lasts indefinitely.
/// </summary>

View File

@@ -1,5 +1,5 @@
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.StatusEffectNew.Components;
@@ -9,15 +9,14 @@ namespace Content.Shared.StatusEffectNew.Components;
/// Can be used for tracking currently applied status effects.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedStatusEffectsSystem))]
[Access(typeof(StatusEffectsSystem))]
public sealed partial class StatusEffectContainerComponent : Component
{
[DataField]
public HashSet<EntityUid> ActiveStatusEffects = new();
}
public const string ContainerId = "status-effects";
[Serializable, NetSerializable]
public sealed class StatusEffectContainerComponentState(HashSet<NetEntity> activeStatusEffects) : ComponentState
{
public readonly HashSet<NetEntity> ActiveStatusEffects = activeStatusEffects;
/// <summary>
/// The actual container holding references to the active status effects
/// </summary>
[ViewVariables]
public Container? ActiveStatusEffects;
}