This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace BITKit
{
public sealed class MonoConditions : MonoBehaviour,ICondition
{
[SerializeReference,SubclassSelector] private ICondition[] conditions;
[SerializeReference,SubclassSelector] private IReference[] customReason;
public bool OnCheck() => conditions.All(OnCheck);
public string Reason
{
get
{
return customReason switch
{
not null when customReason.Length > 0 => string.Join("\n", customReason.Select(x => x.Value)),
_ => string.Join("\n", conditions.Where(OnCheck))
};
}
}
private static bool OnCheck(ICondition condition) => condition.Allow;
[BIT]
private void ManualCheck()
{
Debug.Log(OnCheck() ? "Success" : Reason);
}
}
}