2021-02-05 13:41:05 +01:00
|
|
|
|
#nullable enable
|
|
|
|
|
|
using System;
|
2021-02-09 12:57:21 +01:00
|
|
|
|
using System.Collections.Generic;
|
2021-02-05 13:41:05 +01:00
|
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
|
|
|
|
|
using Content.Shared.GameObjects.Components.Damage;
|
2021-02-08 22:46:28 +01:00
|
|
|
|
using Robust.Shared.Interfaces.Serialization;
|
2021-02-05 13:41:05 +01:00
|
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Triggers
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2021-02-09 12:57:21 +01:00
|
|
|
|
/// A trigger that will activate when any of its triggers have activated.
|
2021-02-05 13:41:05 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Serializable]
|
2021-02-09 12:57:21 +01:00
|
|
|
|
public class OrTrigger : IThresholdTrigger
|
2021-02-05 13:41:05 +01:00
|
|
|
|
{
|
2021-02-09 12:57:21 +01:00
|
|
|
|
public List<IThresholdTrigger> Triggers { get; } = new();
|
2021-02-05 13:41:05 +01:00
|
|
|
|
|
2021-02-08 22:46:28 +01:00
|
|
|
|
void IExposeData.ExposeData(ObjectSerializer serializer)
|
2021-02-05 13:41:05 +01:00
|
|
|
|
{
|
2021-02-09 12:57:21 +01:00
|
|
|
|
serializer.DataField(this, x => x.Triggers, "triggers", new List<IThresholdTrigger>());
|
2021-02-05 13:41:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Reached(IDamageableComponent damageable, DestructibleSystem system)
|
|
|
|
|
|
{
|
2021-02-09 12:57:21 +01:00
|
|
|
|
foreach (var trigger in Triggers)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (trigger.Reached(damageable, system))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
2021-02-05 13:41:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|