using System; using System.Collections.Generic; using Robust.Shared.Analyzers; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Shared.StatusEffect { [RegisterComponent] [NetworkedComponent] [Friend(typeof(StatusEffectsSystem))] public class StatusEffectsComponent : Component { public override string Name => "StatusEffects"; [ViewVariables] public Dictionary ActiveEffects = new(); /// /// A list of status effect IDs to be allowed /// [DataField("allowed", required: true)] public List AllowedEffects = default!; } /// /// Holds information about an active status effect. /// [Serializable, NetSerializable] public class StatusEffectState { /// /// The start and end times of the status effect. /// [ViewVariables] public (TimeSpan, TimeSpan) Cooldown; /// /// Specifies whether to refresh or accumulate the cooldown of the status effect. /// true - refresh time, false - accumulate time. /// [ViewVariables] public bool CooldownRefresh = true; /// /// The name of the relevant component that /// was added alongside the effect, if any. /// [ViewVariables] public string? RelevantComponent; public StatusEffectState((TimeSpan, TimeSpan) cooldown, bool refresh, string? relevantComponent=null) { Cooldown = cooldown; CooldownRefresh = refresh; RelevantComponent = relevantComponent; } } [Serializable, NetSerializable] public class StatusEffectsComponentState : ComponentState { public Dictionary ActiveEffects; public List AllowedEffects; public StatusEffectsComponentState(Dictionary activeEffects, List allowedEffects) { ActiveEffects = activeEffects; AllowedEffects = allowedEffects; } } }