File size: 6,251 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
using Photon.Deterministic;
using System;

namespace Quantum
{
	[System.Serializable]
	public unsafe sealed class AIParamInt : AIParam<int>
	{
		public static implicit operator AIParamInt(int value) { return new AIParamInt() { DefaultValue = value }; }

		public AssetRefAIFunctionInt FunctionRef;

		[NonSerialized] private AIFunctionInt _cachedFunction;

		protected override int GetBlackboardValue(BlackboardValue value)
		{
			return *value.IntegerValue;
		}

		protected override int GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.Integer;
		}

		protected override int GetFunctionValue(Frame frame, EntityRef entity)
		{
			if (_cachedFunction == null)
			{
				_cachedFunction = frame.FindAsset<AIFunctionInt>(FunctionRef.Id);
			}

			return _cachedFunction.Execute(frame, entity);
		}
	}

	[System.Serializable]
	public unsafe sealed class AIParamBool : AIParam<bool>
	{
		public static implicit operator AIParamBool(bool value) { return new AIParamBool() { DefaultValue = value }; }

		public AssetRefAIFunctionBool FunctionRef;

		[NonSerialized] private AIFunctionBool _cachedFunction;

		protected override bool GetBlackboardValue(BlackboardValue value)
		{
			return *value.BooleanValue;
		}

		protected override bool GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.Boolean;
		}

		protected override bool GetFunctionValue(Frame frame, EntityRef entity)
		{
			if (_cachedFunction == null)
			{
				_cachedFunction = frame.FindAsset<AIFunctionBool>(FunctionRef.Id);
			}

			return _cachedFunction.Execute(frame, entity);
		}
	}

	[System.Serializable]
	public unsafe sealed class AIParamByte : AIParam<byte>
	{
		public static implicit operator AIParamByte(byte value) { return new AIParamByte() { DefaultValue = value }; }

		public AssetRefAIFunctionByte FunctionRef;

		[NonSerialized] private AIFunctionByte _cachedFunction;

		protected override byte GetBlackboardValue(BlackboardValue value)
		{
			return *value.ByteValue;
		}

		protected override byte GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.Byte;
		}

		protected override byte GetFunctionValue(Frame frame, EntityRef entity)
		{
			if (_cachedFunction == null)
			{
				_cachedFunction = frame.FindAsset<AIFunctionByte>(FunctionRef.Id);
			}

			return _cachedFunction.Execute(frame, entity);
		}
	}

	[System.Serializable]
	public unsafe sealed class AIParamFP : AIParam<FP>
	{
		public static implicit operator AIParamFP(FP value) { return new AIParamFP() { DefaultValue = value }; }

		public AssetRefAIFunctionFP FunctionRef;

		[NonSerialized] private AIFunctionFP _cachedFunction;

		protected override FP GetBlackboardValue(BlackboardValue value)
		{
			return *value.FPValue;
		}

		protected override FP GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.FP;
		}

		protected override FP GetFunctionValue(Frame frame, EntityRef entity)
		{
			if (_cachedFunction == null)
			{
				_cachedFunction = frame.FindAsset<AIFunctionFP>(FunctionRef.Id);
			}

			return _cachedFunction.Execute(frame, entity);
		}
	}

	[System.Serializable]
	public unsafe sealed class AIParamFPVector2 : AIParam<FPVector2>
	{
		public static implicit operator AIParamFPVector2(FPVector2 value) { return new AIParamFPVector2() { DefaultValue = value }; }

		public AssetRefAIFunctionFPVector2 FunctionRef;

		[NonSerialized] private AIFunctionFPVector2 _cachedFunction;

		protected override FPVector2 GetBlackboardValue(BlackboardValue value)
		{
			return *value.FPVector2Value;
		}

		protected override FPVector2 GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.FPVector2;
		}

		protected override FPVector2 GetFunctionValue(Frame frame, EntityRef entity)
		{
			if (_cachedFunction == null)
			{
				_cachedFunction = frame.FindAsset<AIFunctionFPVector2>(FunctionRef.Id);
			}

			return _cachedFunction.Execute(frame, entity);
		}
	}

	[System.Serializable]
	public unsafe sealed class AIParamFPVector3 : AIParam<FPVector3>
	{
		public static implicit operator AIParamFPVector3(FPVector3 value) { return new AIParamFPVector3() { DefaultValue = value }; }

		public AssetRefAIFunctionFPVector3 FunctionRef;

		[NonSerialized] private AIFunctionFPVector3 _cachedFunction;

		protected override FPVector3 GetBlackboardValue(BlackboardValue value)
		{
			return *value.FPVector3Value;
		}

		protected override FPVector3 GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.FPVector3;
		}

		protected override FPVector3 GetFunctionValue(Frame frame, EntityRef entity)
		{
			if (_cachedFunction == null)
			{
				_cachedFunction = frame.FindAsset<AIFunctionFPVector3>(FunctionRef.Id);
			}

			return _cachedFunction.Execute(frame, entity);
		}
	}

	[System.Serializable]
	public unsafe sealed class AIParamString : AIParam<string>
	{
		public static implicit operator AIParamString(string value) { return new AIParamString() { DefaultValue = value }; }

		protected override string GetBlackboardValue(BlackboardValue value)
		{
			throw new NotSupportedException("Blackboard variables as strings are not supported.");
		}

		protected override string GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.String;
		}

		protected override string GetFunctionValue(Frame frame, EntityRef entity)
		{
			return default;
		}
	}

	[System.Serializable]
	public unsafe sealed class AIParamEntityRef : AIParam<EntityRef>
	{
		public static implicit operator AIParamEntityRef(EntityRef value) { return new AIParamEntityRef() { DefaultValue = value }; }

		public AssetRefAIFunctionEntityRef FunctionRef;

		[NonSerialized] private AIFunctionEntityRef _cachedFunction;

		protected override EntityRef GetBlackboardValue(BlackboardValue value)
		{
			return *value.EntityRefValue;
		}

		protected override EntityRef GetConfigValue(AIConfig.KeyValuePair configPair)
		{
			return configPair.Value.EntityRef;
		}

		protected override EntityRef GetFunctionValue(Frame frame, EntityRef entity)
		{
			if (_cachedFunction == null)
			{
				_cachedFunction = frame.FindAsset<AIFunctionEntityRef>(FunctionRef.Id);
			}

			return _cachedFunction.Execute(frame, entity);
		}
	}
}