Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPredicateBehaviour.cs
More file actions
Latest commit
46 lines (38 loc) · 1.3 KB
/
Copy pathPredicateBehaviour.cs
File metadata and controls
46 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
usingSystem.Collections;
usingSystem.Collections.Generic;
usingUnityEngine;
usingSystem.Linq;
namespaceReachBeyond.ScriptSupport{
publicabstractclassPredicateBehaviour:MonoBehaviour{
/// <summary>
/// This will attempt whatever the given behaviour's action
/// is. It will return true if successful. (Or if the condition is
/// met). This varies between behaviours.
/// </summary>
/// <returns></returns>
publicabstractboolTryAction();
}
publicstaticclassPredicateBehaviourCollectionExtensions{
publicstaticboolAllPass(thisIEnumerable<PredicateBehaviour>source){
returnsource.All(TryAction);
}
publicstaticboolAnyPass(thisIEnumerable<PredicateBehaviour>source){
returnsource.Any(TryAction);
}
publicstaticboolAllFail(thisIEnumerable<PredicateBehaviour>source){
return!source.AnyPass();
}
publicstaticboolAnyFail(thisIEnumerable<PredicateBehaviour>source){
return!source.AllPass();
}
/// <summary>
/// This is a shortcut method to make it easier to call the Linq
/// extension methods.
/// </summary>
/// <param name="pb">The behaviour to run TryAction on.</param>
/// <returns>Same as pb's local TryAction method.</returns>
privatestaticboolTryAction(PredicateBehaviourpb){
returnpb.TryAction();
}
}
}