blob: b483e9a1abbf09d05691c5dd618aea9d822a95c2 (
plain)
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
|
using UnityEngine;
using System.Linq;
namespace BehaviorDesigner.Runtime.Tasks.Basic.SharedVariables
{
[TaskCategory("Basic/SharedVariable")]
[TaskDescription("Returns success if the variable value is equal to the compareTo value.")]
public class CompareSharedGameObjectList : Conditional
{
[Tooltip("The first variable to compare")]
public SharedGameObjectList variable;
[Tooltip("The variable to compare to")]
public SharedGameObjectList compareTo;
public override TaskStatus OnUpdate()
{
if (variable.Value == null && compareTo.Value != null)
return TaskStatus.Failure;
if (variable.Value == null && compareTo.Value == null)
return TaskStatus.Success;
if (variable.Value.Count != compareTo.Value.Count)
return TaskStatus.Failure;
return variable.Value.Except(compareTo.Value).Count() > 0 ? TaskStatus.Failure : TaskStatus.Success;
}
public override void OnReset()
{
variable = null;
compareTo = null;
}
}
}
|