2022-09-05 05:21:21 +12:00
|
|
|
using Robust.Shared.GameStates;
|
2021-10-15 14:45:04 -07:00
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.StatusEffect
|
|
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
[NetworkedComponent]
|
2022-06-07 15:26:28 +02:00
|
|
|
[Access(typeof(StatusEffectsSystem))]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class StatusEffectsComponent : Component
|
2021-10-15 14:45:04 -07:00
|
|
|
{
|
2021-11-08 15:33:45 -07:00
|
|
|
[ViewVariables]
|
2021-10-15 14:45:04 -07:00
|
|
|
public Dictionary<string, StatusEffectState> ActiveEffects = new();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A list of status effect IDs to be allowed
|
|
|
|
|
/// </summary>
|
2022-07-06 18:06:12 +10:00
|
|
|
[DataField("allowed", required: true), Access(typeof(StatusEffectsSystem), Other = AccessPermissions.ReadExecute)]
|
2021-10-15 14:45:04 -07:00
|
|
|
public List<string> AllowedEffects = default!;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 22:56:07 -07:00
|
|
|
[RegisterComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class ActiveStatusEffectsComponent : Component {}
|
2022-04-04 22:56:07 -07:00
|
|
|
|
2021-10-15 14:45:04 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Holds information about an active status effect.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class StatusEffectState
|
2021-10-15 14:45:04 -07:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The start and end times of the status effect.
|
|
|
|
|
/// </summary>
|
2021-11-08 15:33:45 -07:00
|
|
|
[ViewVariables]
|
2021-10-15 14:45:04 -07:00
|
|
|
public (TimeSpan, TimeSpan) Cooldown;
|
|
|
|
|
|
2021-12-07 09:18:07 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Specifies whether to refresh or accumulate the cooldown of the status effect.
|
|
|
|
|
/// true - refresh time, false - accumulate time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public bool CooldownRefresh = true;
|
|
|
|
|
|
2021-10-15 14:45:04 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// The name of the relevant component that
|
|
|
|
|
/// was added alongside the effect, if any.
|
|
|
|
|
/// </summary>
|
2021-11-08 15:33:45 -07:00
|
|
|
[ViewVariables]
|
2021-10-15 14:45:04 -07:00
|
|
|
public string? RelevantComponent;
|
|
|
|
|
|
2021-12-07 09:18:07 +03:00
|
|
|
public StatusEffectState((TimeSpan, TimeSpan) cooldown, bool refresh, string? relevantComponent=null)
|
2021-10-15 14:45:04 -07:00
|
|
|
{
|
|
|
|
|
Cooldown = cooldown;
|
2021-12-07 09:18:07 +03:00
|
|
|
CooldownRefresh = refresh;
|
2021-10-15 14:45:04 -07:00
|
|
|
RelevantComponent = relevantComponent;
|
|
|
|
|
}
|
2022-09-05 05:21:21 +12:00
|
|
|
|
|
|
|
|
public StatusEffectState(StatusEffectState toCopy)
|
|
|
|
|
{
|
|
|
|
|
Cooldown = (toCopy.Cooldown.Item1, toCopy.Cooldown.Item2);
|
|
|
|
|
CooldownRefresh = toCopy.CooldownRefresh;
|
|
|
|
|
RelevantComponent = toCopy.RelevantComponent;
|
|
|
|
|
}
|
2021-10-15 14:45:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class StatusEffectsComponentState : ComponentState
|
2021-10-15 14:45:04 -07:00
|
|
|
{
|
|
|
|
|
public Dictionary<string, StatusEffectState> ActiveEffects;
|
|
|
|
|
public List<string> AllowedEffects;
|
|
|
|
|
|
|
|
|
|
public StatusEffectsComponentState(Dictionary<string, StatusEffectState> activeEffects, List<string> allowedEffects)
|
|
|
|
|
{
|
|
|
|
|
ActiveEffects = activeEffects;
|
|
|
|
|
AllowedEffects = allowedEffects;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|