namespace Zinnia.Rule
{
using UnityEngine;
using Zinnia.Data.Collection.List;
using Zinnia.Data.Type;
using Zinnia.Extension;
///
/// Determines whether a has any component found in a list.
///
public class AnyComponentTypeRule : GameObjectRule
{
[Tooltip("The component types to look for.")]
[SerializeField]
private SerializableTypeComponentObservableList componentTypes;
///
/// The component types to look for.
///
public SerializableTypeComponentObservableList ComponentTypes
{
get
{
return componentTypes;
}
set
{
componentTypes = value;
}
}
///
protected override bool Accepts(GameObject targetGameObject)
{
if (ComponentTypes == null)
{
return false;
}
foreach (SerializableType serializedType in ComponentTypes.NonSubscribableElements)
{
if (serializedType.ActualType != null && targetGameObject.TryGetComponent(serializedType) != null)
{
return true;
}
}
return false;
}
}
}