Files
tbd-station-14/Content.Server/GameObjects/Components/Destructible/Thresholds/Triggers/OrTrigger.cs
2021-05-04 15:37:16 +02:00

34 lines
960 B
C#

#nullable enable
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Damage;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Triggers
{
/// <summary>
/// A trigger that will activate when any of its triggers have activated.
/// </summary>
[Serializable]
[DataDefinition]
public class OrTrigger : IThresholdTrigger
{
[DataField("triggers")]
public List<IThresholdTrigger> Triggers { get; } = new();
public bool Reached(IDamageableComponent damageable, DestructibleSystem system)
{
foreach (var trigger in Triggers)
{
if (trigger.Reached(damageable, system))
{
return true;
}
}
return false;
}
}
}