File size: 1,176 Bytes
00437a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
using Quantum.Collections;

namespace Quantum
{
	public unsafe partial struct BlackboardEntry
	{
		/// <summary>
		/// Iterate through all Decorators that watches this Blackboard entry
		/// Re-check the Decorators so it can check if an abort is needed
		/// </summary>
		/// <param name="btParams"></param>
		public void TriggerDecorators(BTParams btParams)
		{
			var frame = btParams.Frame;

			// If the reactive decorators list was already allocated...
			if (ReactiveDecorators.Ptr != default)
			{
				// Solve it and trigger the decorators checks
				var reactiveDecorators = frame.ResolveList(ReactiveDecorators);
				for (int i = 0; i < reactiveDecorators.Count; i++)
				{
					var reactiveDecoratorRef = reactiveDecorators[i];
					var decoratorInstance = frame.FindAsset<BTDecorator>(reactiveDecoratorRef.Id);
					btParams.Agent->OnDecoratorReaction(btParams, decoratorInstance, decoratorInstance.AbortType, out bool abortSelf, out bool abortLowerPriority);

					// If at least one Decorator resulted in abort, we stop and return already
					if (abortSelf == true)
					{
						btParams.Agent->AbortNodeId = decoratorInstance.Id;
					}
				}
			}
		}
	}
}