1
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
"name": "BITKit.Node.Unity",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:a209c53514018594f9f482516f2a6781",
|
||||
"GUID:517785bb4600a5140b47eac5fa49b8fc",
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:517785bb4600a5140b47eac5fa49b8fc"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
33
Src/Unity/Scripts/Node/MonoConditions.cs
Normal file
33
Src/Unity/Scripts/Node/MonoConditions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
11
Src/Unity/Scripts/Node/MonoConditions.cs.meta
Normal file
11
Src/Unity/Scripts/Node/MonoConditions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0131413e0ad2484f827e007aeeed4d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user