-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameplayKit.framework.h
More file actions
3711 lines (3024 loc) · 126 KB
/
Copy pathGameplayKit.framework.h
File metadata and controls
3711 lines (3024 loc) · 126 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
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========== GameplayKit.framework/Headers/GKRandomDistribution.h
//
// GKRandomDistribution.h
// GameplayKit
//
// Copyright © 2015 Apple. All rights reserved.
//
#import <GameplayKit/GKRandomSource.h>
NS_ASSUME_NONNULL_BEGIN
/**
* A random distribution is a random source itself with a specific mapping from the input source to the output values.
* The distribution is uniform, meaning there is no bias towards any of the possible outcomes.
*/
GK_BASE_AVAILABILITY @interface GKRandomDistribution : NSObject<GKRandom>
/**The lowest value the distribution will output.*/
@property (nonatomic, assign, readonly) NSInteger lowestValue;
/**The highest value the distribution will output.*/
@property (nonatomic, assign, readonly) NSInteger highestValue;
/**The number of unique possible outcomes, depending on the distribution type this is not always highest - lowest + 1.*/
@property (nonatomic, assign, readonly) NSUInteger numberOfPossibleOutcomes;
/**Initializes a random distribution within the range [lowest, highest] using a source to grab input values from.*/
- (instancetype)initWithRandomSource:(id<GKRandom>)source lowestValue:(NSInteger)lowestInclusive highestValue:(NSInteger)highestInclusive NS_DESIGNATED_INITIALIZER;
/**
* Returns the next integer in the distribution sequence and moves ahead to the next one.
* The value is in the range of [lowest, highest].
*/
- (NSInteger)nextInt;
/**
* Returns the next unsigned value in the distribution sequence that is less than upperBound.
* The value never equals or exceeeds upperBounds, and in this case it will also never exceed
* the highest value of the distribution.
*/
- (NSUInteger)nextIntWithUpperBound:(NSUInteger)upperBound;
/**
* Returns the next uniform float in the random sequence and moves ahead to the next one.
* The value is in the range of [lowest / higest, 1.0].
*
* The value is quantized to the distribution's lowest and highest bounds. Thus on a d20
* distribution the value is quantized to 5% increments. The output value 0 is not possible
* to get unless the lowest value bound is also 0 or below.
*
* @see nextInt
*/
- (float)nextUniform;
/**
* Returns the next true or false value in the distribution sequence and moves ahead to the next one.
* The value is either nonzero (true) or zero (false).
* Use this for simple boolean switches in logic that don't require fuzzy evaluation.
* For fuzzy evaluation use nextUniform.
*
* By default this is based on the referenced source's definition of nextBool.
*
* @see GKRandomSource.nextBool
*/
- (BOOL)nextBool;
/**
* Convenience creation of random distribution within the range [lowest, highest] using an isolated source to grab input values from.
* This is equivalent to calling alloc followed by initWithSource:lowest:highest:, where source is [[GKRandomSource alloc] init].
* @see initWithRandomSource:lowestValue:highestValue:
*/
+ (instancetype)distributionWithLowestValue:(NSInteger)lowestInclusive highestValue:(NSInteger)highestInclusive;
/**
* Convenience creation of random distribution with the die like range [1, sideCount] using an isolated source to grab input values from.
* This is equivalent to calling alloc followed by initWithSource:lowest:highest:, where source is [[GKRandomSource alloc] init].
* @see initWithRandomSource:lowestValue:highestValue:
*/
+ (instancetype)distributionForDieWithSideCount:(NSInteger)sideCount;
/**
* Convenience creation for the very common d6 range [1, 6] with an isolated random source
* shielded from outside sources.
*/
+ (instancetype)d6;
/**
* Convenience creation for the very common d20 range [1, 20] with an isolated random source
* shielded from outside sources.
*/
+ (instancetype)d20;
@end
/**
* A gaussian distribution is biased towards the mean value, the possible outcomes are spread out from the mean
* with decreasing probability. Values within 1 deviation of the mean make up 68.27% of the distribution, values
* within 2 deviations make up 95% and values within 3 deviations make up 99.7%.
*
* Note that a gaussian distribution's unbounded behavior beyond 3 deviations is undesired,
* thus this distribution deviates nominally by modifying the bounds to 3 deviations.
* Thus values within 3 deviations actually make up 100% of the distribution.
*/
GK_BASE_AVAILABILITY @interface GKGaussianDistribution : GKRandomDistribution
/**
* The mean, or expected, value of the distribution. Values are more probable the closer to the mean they are.
*/
@property (nonatomic, assign, readonly) float mean;
/**
* The deviation, often called 'sigma', is the deviation from the mean that would include roughly 68% of the distribution.
* The range of the distribution is [mean - 3 * deviation, mean + 3 * deviation]. Values beyond 3 deviations
* are considered so improbable that they are removed from the output set.
*/
@property (nonatomic, assign, readonly) float deviation;
/**
* Initializes a Gaussian random distribution within the range [lowest, highest] using a source to grab input values from.
* This sets the gaussian parameters to:
*
* mean = (highest + lowest) / 2
* deviation = (highest - lowest) / 6
*
* The mean and deviation will be floating point numbers even if the distribution is meant to produce integer values.
* @see mean
* @see deviation
*/
- (instancetype)initWithRandomSource:(id<GKRandom>)source lowestValue:(NSInteger)lowestInclusive highestValue:(NSInteger)highestInclusive NS_DESIGNATED_INITIALIZER;
/**
* Initializes a Gaussian random distribution within the range [mean - 3 * deviation, mean + 3 * deviation]
* using a source to grab input values from.
*/
- (instancetype)initWithRandomSource:(id<GKRandom>)source mean:(float)mean deviation:(float)deviation NS_DESIGNATED_INITIALIZER;
@end
/**
* A shuffled distribution tries to make sure individual samples are not clustered whilst retaining a uniform distribution of values
* over time. This is often referred to as fair or less random, as the predicatability of the outcomes in a series is vastly increased,
* yet the distribution of values is uniform.
*
* Do not use with distributions ranging more than 256 between lowest and highest as the shuffling seqeunce is stored internally in memory.
*/
GK_BASE_AVAILABILITY @interface GKShuffledDistribution : GKRandomDistribution
@end
NS_ASSUME_NONNULL_END
// ========== GameplayKit.framework/Headers/GKState.h
//
// GKState.h
// GameplayKit
//
// Copyright (c) 2014 Apple. All rights reserved.
//
#import <GameplayKit/GameplayKit.h>
NS_ASSUME_NONNULL_BEGIN
@class GKStateMachine;
/**
* Represents a single state in a state machine.
* By default, states allow transitions freely to and from the states in the machine.
*
* If a more restricted set of valid transitions are needed in the state machine, you may override isValidNextState: where applicable.
*
* @see GKStateMachine
* @see isValidNextState:
*/
GK_BASE_AVAILABILITY @interface GKState : NSObject
/**
* The state machine that this state is associated with.
* This is nil if this state hasn't been added to a state machine yet.
*/
@property (nullable, nonatomic, readonly, weak) GKStateMachine *stateMachine;
/**
* Creates a new state to be used in a state machine.
*
* @see GKStateMachine
*/
+ (instancetype)state;
- (instancetype)init NS_DESIGNATED_INITIALIZER;
/**
* Returns YES if the given class is a valid next state to enter.
*
* By default GKState will return YES for any class that is subclass of GKState.
* Override this in a subclass to enforce limited edge traversals in the state machine.
*
* @see GKStateMachine.canEnterState:
* @see GKStateMachine.enterState:
*
* @param stateClass the class to be checked
* @return YES if the class is kind of GKState and the state transition is valid, else NO.
*/
- (BOOL)isValidNextState:(Class)stateClass;
/**
* Called by GKStateMachine when this state is entered.
*
* @param previousState the state that was exited to enter this state. This is nil if this is the state machine's first entered state.
* @see stateMachineWithStates:initialStateClass:
*/
- (void)didEnterWithPreviousState:(nullable GKState *)previousState;
/**
* Called by GKStateMachine when it is updated
*
* @param seconds the time in seconds since the last update
*/
- (void)updateWithDeltaTime:(NSTimeInterval)seconds;
/**
* Called by GKStateMachine when this state is exited
*
* @param nextState the state that is being entered next
*/
- (void)willExitWithNextState:(GKState *)nextState;
@end
NS_ASSUME_NONNULL_END
// ========== GameplayKit.framework/Headers/GKNoiseSource.h
//
// GKNoiseSource.h
// GameplayKit
//
// Copyright © 2016 Apple. All rights reserved.
//
#import <GameplayKit/GameplayKitBase.h>
NS_ASSUME_NONNULL_BEGIN
/**
* A GKNoiseSource instance is a description of procedural noise in 3D space. Noise sources generate values
* between -1.0 and 1.0, inclusive, for any position in continuous 3D space.
* Subclasses represent specific types of noise, each with their own parameters that affect the nature of the noise.
* Noise sources are the starting point for generating and using procedural noise. The 3D noise values may be manipulated and
* combined with the GKNoise class. Portions of this 3D noise can be extracted and utilized via the GKNoiseMap class.
* Extracted portions of noise are useful in both 2D and 3D games. Applications include creating realistic textures,
* height maps for 2D and 3D game world terrain, tile maps for 2D games, and intentionally imperfect game object and
* camera movements in 2D and 3D games.
* This class is not intended to be instantiated.
*
* @see GKNoise
* @see GKNoiseMap
*/
GK_BASE_AVAILABILITY_2 @interface GKNoiseSource : NSObject
@end
/**
* Coherent noise is smoothly-changing, semi-random noise. A given input always produces the same output.
* A small change in input produces a small change in output. A large change in input produces a random
* change in output. This class is not intended to be instantiated.
*/
GK_BASE_AVAILABILITY_2 @interface GKCoherentNoiseSource : GKNoiseSource
@property (nonatomic) double frequency;
@property (nonatomic) NSInteger octaveCount;
@property (nonatomic) double lacunarity;
@property (nonatomic) int32_t seed;
@end
/**
* Perlin noise is useful for creating natural-looking textures and realistic-looking terrain.
*/
GK_BASE_AVAILABILITY_2 @interface GKPerlinNoiseSource : GKCoherentNoiseSource
@property (nonatomic) double persistence;
+ (instancetype)perlinNoiseSourceWithFrequency:(double)frequency octaveCount:(NSInteger)octaveCount persistence:(double)persistence lacunarity:(double)lacunarity seed:(int32_t)seed;
- (instancetype)initWithFrequency:(double)frequency octaveCount:(NSInteger)octaveCount persistence:(double)persistence lacunarity:(double)lacunarity seed:(int32_t)seed NS_DESIGNATED_INITIALIZER;
@end
/**
* Billow noise is similar to Perlin noise, with more rounded shapes and clearly-defined transitions beween values.
*/
GK_BASE_AVAILABILITY_2 @interface GKBillowNoiseSource : GKCoherentNoiseSource
@property (nonatomic) double persistence;
+ (instancetype)billowNoiseSourceWithFrequency:(double)frequency octaveCount:(NSInteger)octaveCount persistence:(double)persistence lacunarity:(double)lacunarity seed:(int32_t)seed;
- (instancetype)initWithFrequency:(double)frequency octaveCount:(NSInteger)octaveCount persistence:(double)persistence lacunarity:(double)lacunarity seed:(int32_t)seed NS_DESIGNATED_INITIALIZER;
@end
/**
* Ridged noise is similar to Perlin noise, with sharply-defined, relatively thin peaks.
*/
GK_BASE_AVAILABILITY_2 @interface GKRidgedNoiseSource : GKCoherentNoiseSource
+ (instancetype)ridgedNoiseSourceWithFrequency:(double)frequency octaveCount:(NSInteger)octaveCount lacunarity:(double)lacunarity seed:(int32_t)seed;
- (instancetype)initWithFrequency:(double)frequency octaveCount:(NSInteger)octaveCount lacunarity:(double)lacunarity seed:(int32_t)seed NS_DESIGNATED_INITIALIZER;
@end
/**
* Voronoi noise partitions the space into angular, polygonal "cells", which are reminiscent
* of stained glass or crystal-like structures.
*/
GK_BASE_AVAILABILITY_2 @interface GKVoronoiNoiseSource : GKNoiseSource
@property (nonatomic) double frequency;
@property (nonatomic) double displacement;
@property (nonatomic, getter=isDistanceEnabled) BOOL distanceEnabled;
@property (nonatomic) int32_t seed;
+ (instancetype)voronoiNoiseWithFrequency:(double)frequency displacement:(double)displacement distanceEnabled:(BOOL)distanceEnabled seed:(int32_t)seed;
- (instancetype)initWithFrequency:(double)frequency displacement:(double)displacement distanceEnabled:(BOOL)distanceEnabled seed:(int32_t)seed NS_DESIGNATED_INITIALIZER;
@end
/**
* Produces a single, constant value at all positions in the space.
*/
GK_BASE_AVAILABILITY_2 @interface GKConstantNoiseSource : GKNoiseSource
@property (nonatomic) double value;
+ (instancetype)constantNoiseWithValue:(double)value;
- (instancetype)initWithValue:(double)value NS_DESIGNATED_INITIALIZER;
@end
/**
* Produces 3D cylindrical noise with an infinite number of cylinders-within-cyliners of constantly-increasing radius.
*/
GK_BASE_AVAILABILITY_2 @interface GKCylindersNoiseSource : GKNoiseSource
@property (nonatomic) double frequency;
+ (instancetype)cylindersNoiseWithFrequency:(double)frequency;
- (instancetype)initWithFrequency:(double)frequency NS_DESIGNATED_INITIALIZER;
@end
/**
* Produces 3D spherical noise with an infinite number of spheres-within-spheres of constantly-increasing radius.
*/
GK_BASE_AVAILABILITY_2 @interface GKSpheresNoiseSource : GKNoiseSource
@property (nonatomic) double frequency;
+ (instancetype)spheresNoiseWithFrequency:(double)frequency;
- (instancetype)initWithFrequency:(double)frequency NS_DESIGNATED_INITIALIZER;
@end
/**
* Produces noise in a checkerboard pattern.
*/
GK_BASE_AVAILABILITY_2 @interface GKCheckerboardNoiseSource : GKNoiseSource
@property (nonatomic) double squareSize;
+ (instancetype)checkerboardNoiseWithSquareSize:(double)squareSize;
- (instancetype)initWithSquareSize:(double)squareSize NS_DESIGNATED_INITIALIZER;
@end
NS_ASSUME_NONNULL_END
// ========== GameplayKit.framework/Headers/GameplayKit.h
//
// GameplayKit.h
// GameplayKit
//
// Copyright (c) 2014 Apple. All rights reserved.
//
#pragma once
#import <GameplayKit/GameplayKitBase.h>
#import <GameplayKit/GKAgent.h>
#import <GameplayKit/GKBehavior.h>
#import <GameplayKit/GKComponent.h>
#import <GameplayKit/GKCompositeBehavior.h>
#import <GameplayKit/GKEntity.h>
#import <GameplayKit/GKGameModel.h>
#import <GameplayKit/GKGoal.h>
#import <GameplayKit/GKGraph.h>
#import <GameplayKit/GKGridGraph.h>
#import <GameplayKit/GKObstacleGraph.h>
#import <GameplayKit/GKGraphNode.h>
#import <GameplayKit/GKStrategist.h>
#import <GameplayKit/GKMeshGraph.h>
#import <GameplayKit/GKMinmaxStrategist.h>
#import <GameplayKit/GKMonteCarloStrategist.h>
#import <GameplayKit/GKDecisionTree.h>
#import <GameplayKit/GKNoiseSource.h>
#import <GameplayKit/GKNoise.h>
#import <GameplayKit/GKNoiseMap.h>
#import <GameplayKit/GKObstacle.h>
#import <GameplayKit/GKOctree.h>
#import <GameplayKit/GKPath.h>
#import <GameplayKit/GKPrimitives.h>
#import <GameplayKit/GKQuadtree.h>
#import <GameplayKit/GKRandomDistribution.h>
#import <GameplayKit/GKRTree.h>
#import <GameplayKit/GKRuleSystem.h>
#import <GameplayKit/GKState.h>
#import <GameplayKit/GKStateMachine.h>
#import <GameplayKit/GKScene.h>
#import <GameplayKit/GKSKNodeComponent.h>
#import <GameplayKit/SpriteKit+Additions.h>
#import <GameplayKit/GKSCNNodeComponent.h>
#import <GameplayKit/SceneKit+Additions.h>
// ========== GameplayKit.framework/Headers/GKStateMachine.h
//
// GKStateMachine.h
// GameplayKit
//
// Copyright (c) 2014 Apple. All rights reserved.
//
#import <GameplayKit/GameplayKit.h>
NS_ASSUME_NONNULL_BEGIN
@class GKState;
/**
* Models a finite state machine that has a single current state.
*/
GK_BASE_AVAILABILITY @interface GKStateMachine : NSObject
/**
* The current state that the state machine is in.
* Prior to the first called to enterState this is equal to nil.
*/
@property (nullable, nonatomic, readonly) GKState* currentState;
/**
* Creates a state machine with an array of possible states and an initial state.
*
* @param states a list of possible states for this state machine.
*/
+ (instancetype)stateMachineWithStates:(NSArray<GKState *> *)states;
- (instancetype)initWithStates:(NSArray<GKState *> *)states NS_DESIGNATED_INITIALIZER;
/**
* Updates the current state machine.
*
* @param sec the time, in seconds, since the last frame
*/
- (void)updateWithDeltaTime:(NSTimeInterval)sec;
/**
* Gets the instance of the indicated state class from this state machine.
* Returns nil if the state does not exist
*
* @param stateClass the class of the state to be retrieved
*/
- (nullable GKState*)stateForClass:(Class)stateClass NS_SWIFT_UNAVAILABLE("Exposed in Swift as stateForClass<StateType: GKState>(stateClass: StateType.Type) -> StateType?");
/**
* Returns YES if the indicated class is a a valid next state or if currentState is nil
*
* @param stateClass the class of the state to be tested
*/
- (BOOL)canEnterState:(Class)stateClass;
/**
* Calls canEnterState to check if we can enter the given state and then enters that state if so.
* [GKState willExitWithNextState:] is called on the old current state.
* [GKState didEnterWithPreviousState:] is called on the new state.
*
* @param stateClass the class of the state to switch to
* @return YES if state was entered. NO otherwise.
*/
- (BOOL)enterState:(Class)stateClass;
@end
NS_ASSUME_NONNULL_END
// ========== GameplayKit.framework/Headers/GKRuleSystem.h
//
// GKRuleSystem.h
// GameplayKit
//
// Copyright © 2015 Apple. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GameplayKitBase.h"
NS_ASSUME_NONNULL_BEGIN
@class GKRule;
/**
* A rule system consists of 3 things:
* - The current state, which upon creation is considered the inital state.
* - The current set of rules.
* - The current set of facts.
*
* Each time a fact is added to the system, the set of rules are evaluated in order and their actions executed in the system if their predicates are true.
* Rules can be fuzzy, allowing predicates and facts to be asserted to a degree of confidence instead of just boolean on/off.
*
* The facts can be any kind of objects as long as they correctly determine equality using isEqual:
* The simplest approach is to use strings or dictionaries as they provide the most flexibility in defining
* facts, but user defined classes work just as well and may describe the problem space better.
*
* The fact set is at all times a fuzzy set, as defined by fact membership in the set being modulated by their
* grade of membership. The rules may use the grade of membership to predicate their actions and in such a
* manner create fuzzy logic. The fuzzy logic Zadeh operators are available on the system itself in order
* to query multiple facts for combined membership grade.
*/
GK_BASE_AVAILABILITY @interface GKRuleSystem : NSObject
/**
* Initializes a clean rule system with no state, rules or facts.
*/
- (instancetype)init NS_DESIGNATED_INITIALIZER;
/**
* Explicitly evaluate the agenda of the rule system based on the current state and the current set of facts.
*
* This may in turn assert or retract more facts or change the state of the system, including activating more
* rules in the agenda.
*/
- (void)evaluate;
/**
* The implementation-defined state. If any changes are made on this outside the system you must
* call evaluate to have the system take account of the changes.
*
* @see evaluate
*/
@property (nonatomic, retain, readonly) NSMutableDictionary *state;
#pragma mark Rules
/**
* The current set of rules that will be used to set the agenda when rules are first added to the system.
* They will also be used to refill the agenda whenever it is set.
*
* This is at all times the union of the agenda and executed sets.
*
* @see agenda
* @see executed
*/
@property (nonatomic, retain, readonly) NSArray<GKRule *> *rules;
/**
* Adds a rule to the system. Also adds it to the agenda in salience order.
*/
- (void)addRule:(GKRule *)rule;
/**
* Adds rules to the system. Also adds them to the agenda in salience order.
*/
- (void)addRulesFromArray:(NSArray<GKRule *> *)rules;
/**
* Removes all rules from the system. This also removes them from the agenda and executed sets.
*/
- (void)removeAllRules;
/**
* The current set of rules to be evaluated, in salience order, where if the salience is equivalent
* the order of insertion into the agenda is used to decide which is first.
* Adjust salience of your rules to adjust the order the next time the agenda is reset. Changing salience
* on a rule currently in the agenda does not change its order in the agenda.
*
* This is at all times the difference between the rules and executed sets.
*
* @see rules
* @see executed
* @see reset
*/
@property (nonatomic, retain, readonly) NSArray<GKRule *> *agenda;
/**
* The current set of rules that have already executed. Rules in this set will not be executed again until
* the system is reset.
*
* This is at all times the difference between the rules and agenda sets.
*
* @see rules
* @see agenda
* @see reset
*/
@property (nonatomic, retain, readonly) NSArray<GKRule *> *executed;
#pragma mark Facts
/**
* The current set of facts. Facts have a grade of membership that is >= 0.0. Query the system for the
* individual grades of membership with gradeForFact:
*
* @see gradeForFact:
*/
@property (nonatomic, retain, readonly) NSArray *facts;
#pragma mark Zadeh operators
/**
* Returns the current membership grade for the given fact, which is 0.0 if the fact
* is not a member of the current set of facts.
*
* @return The membership grade of the given fact, in the range [0.0, 1.0].
*/
- (float)gradeForFact:(id<NSObject>)fact;
/**
* Returns the combined membership grade for the all the given facts.
*
* This performs the logical AND operation between the given facts.
*
* @return The membership grade by applying the AND operator on the given facts, in the range [0.0, 1.0].
*/
- (float)minimumGradeForFacts:(NSArray *)facts;
/**
* Returns the maximum membership grade for the any one of the given facts.
*
* This performs the logical OR operation between the given facts.
*
* @return The membership grade by applying the OR operator on the given facts, in the range [0.0, 1.0].
*/
- (float)maximumGradeForFacts:(NSArray *)facts;
#pragma mark Asserting Facts
/**
* Asserts a fact with membership grade of 1.0.
*
* This will cause the current rules to be evaluated, which may in turn assert or retract more facts
* or change the state of the system.
*
* This is shorthand for calling assertFact:grade: with a grade of 1.0
*
* @see assertFact:grade:
* @see evaluate
* @see NSObject.isEqual:
*/
- (void)assertFact:(id<NSObject>)fact;
/**
* Asserts a fact with the supplied membership grade.
*
* This will cause the current rules to be evaluated, which may in turn assert or retract more facts
* or change the state of the system.
*
* @see evaluate
*/
- (void)assertFact:(id<NSObject>)fact grade:(float)grade;
#pragma mark Retracting Facts
/**
* Retracts a fact, setting its membership grade to 0, which also removes it from the fact set.
*
* This will cause the current rules to be evaluated, which may in turn assert or retract more facts
* or change the state of the system.
*
* This is short hand for calling retractFact:grade: with a grade of 1.0
*
* @see retractFact:grade:
* @see evaluate
*/
- (void)retractFact:(id<NSObject>)fact;
/**
* Retracts a fact, reducing its membership grade by the supplied grade. If this brings the grade to 0
* it is also removed from the fact set.
*
* This will cause the current rules to be evaluated, which may in turn assert or retract more facts
* or change the state of the system.
*
* @see evaluate
*/
- (void)retractFact:(id<NSObject>)fact grade:(float)grade;
#pragma mark Resetting the system
/**
* Clears the agenda and executed sets and removes all facts currently in the system.
* It then fills the agenda with rules from the rule set, in salience order.
* @see rules
* @see facts
*/
- (void)reset;
@end
/**
* The concrete class that the GKRuleSystem uses to evaluate the current state and facts with predicated rules.
* These are sharable between systems, so don't retain any state in the rules themselves. Use the system-provided
* state storage.
*
* @see GKRuleSystem.state
*/
GK_BASE_AVAILABILITY @interface GKRule : NSObject
/**
* Salience defines the order in the rule agenda that the system will evaluate. A rule with higher salience will
* be evaluated before another rule in the agenda that has a lower salience.
*
* Defaults to 0.
* @see GKRuleSystem.agenda
*/
@property (nonatomic, assign) NSInteger salience;
/**
* Called by the rule system when it is this rule's turn to be evaluated. If the predicate returns YES then
* the action for the rule will be performed. Once the action is performed the rule will move to the system's
* executed list until the agenda is reset.
*
* @see performAction
* @see GKRuleSystem.agenda
* @see GKRuleSystem.executed
* @see GKRuleSystem.reset
* @return YES is the predicate passes and the action needs to be performed, NO otherwise.
*/
- (BOOL)evaluatePredicateWithSystem:(GKRuleSystem *)system;
/**
* Performs the action consequence for the rule. This will only be called if the predicate evaluates to YES.
* Any facts asserted or retracted by the action on the system will cause the system to evaluate the agenda
* rule set again once the action completes.
*/
- (void)performActionWithSystem:(GKRuleSystem *)system;
/**
* Create a data-driven rule that uses NSPredicate and a single assert as the action.
*/
+ (instancetype)ruleWithPredicate:(NSPredicate *)predicate assertingFact:(id<NSObject>)fact grade:(float)grade;
/**
* Short hand for data-driven rule that uses NSPredicate and a single retract as the action.
*/
+ (instancetype)ruleWithPredicate:(NSPredicate *)predicate retractingFact:(id<NSObject>)fact grade:(float)grade;
/**
* Short hand for making a rule that uses blocks for the predicate and action. This rule is not able to be archived
* using NSKeyedArchiver so use a subclass or NSPredicate based rule if serialization of the rule is needed.
*/
+ (instancetype)ruleWithBlockPredicate:(BOOL (^)(GKRuleSystem *))predicate action:(void (^)(GKRuleSystem *))action;
@end
/**
* A convenient subclass of GKRule that leverages existing NSPRedicate functionality for evaluating the predicate
* of the rule.
*/
GK_BASE_AVAILABILITY @interface GKNSPredicateRule : GKRule
/**
* The NSPredicate that is used inside this subclass's implementation of evaluatePredicateWithSystem:
* In order to effectively use this class you must still override performActionWithSystem:
*
* @see GKRule.evaluatePredicateWithSystem:
*/
@property (nonatomic, retain, readonly) NSPredicate *predicate;
/**
* Initializes a new rule with the given NSPredicate
*/
- (instancetype)initWithPredicate:(NSPredicate *)predicate;
/**
* Overridden here to call the predicate's evaluateWithObject:substitutionVariables:, using sys
* as the object and the system's state dictionary as the source of the substitution variables.
*
* @return YES if the NSPredicate evaluation passes and the action needs to be performed, NO otherwise.
*/
- (BOOL)evaluatePredicateWithSystem:(GKRuleSystem *)system;
@end
NS_ASSUME_NONNULL_END
// ========== GameplayKit.framework/Headers/GKScene.h
//
// GKScene.h
// GameplayKit
//
// Copyright © 2016 Apple. All rights reserved.
//
#import <GameplayKit/GameplayKitBase.h>
@class GKEntity, GKGraph;
NS_ASSUME_NONNULL_BEGIN
/**
Protocol that specifies the type of objects that can be used as root nodes of a GKScene.
@see GKScene.rootNode
*/
@protocol GKSceneRootNodeType <NSObject>
@end
/**
A scene stores and handles loading of data related to a particular scene.
*/
GK_BASE_AVAILABILITY_2 @interface GKScene : NSObject <NSCopying, NSSecureCoding>
/**
Loads a scene from a file contained within the bundle.
*/
+ (nullable instancetype)sceneWithFileNamed:(NSString *)filename;
/**
Loads a scene from a file contained within the bundle and link with the specified rootNode.
*/
+ (nullable instancetype)sceneWithFileNamed:(NSString *)filename rootNode:(id <GKSceneRootNodeType>) rootNode;
/**
The entities of this scene.
*/
@property (nonatomic, readonly) NSArray<GKEntity *> *entities;
/**
The root node for the scene.
@see GKSceneRootNodeType
*/
@property (nonatomic, nullable) id <GKSceneRootNodeType> rootNode;
/**
The navigational graphs of this scene.
*/
@property (nonatomic, readonly) NSDictionary<NSString*, GKGraph *> *graphs;
/**
Adds an entity to the scene's list of entities.
@param entity the entity to add.
*/
- (void)addEntity:(GKEntity *)entity;
/**
Removes an entity from the scene's list of entities.
@param entity the entity to remove.
*/
- (void)removeEntity:(GKEntity *)entity;
/**
Adds a graph to the scene's list of graphs.
@param graph the graph to add.
*/
- (void)addGraph:(GKGraph *)graph name:(NSString*)name;
/**
Removes a graph from the scene's list of graphs.
@param name the name of the corresponding graph as added via addGraph:
*/
- (void)removeGraph:(NSString*)name;
@end
NS_ASSUME_NONNULL_END
// ========== GameplayKit.framework/Headers/GKSCNNodeComponent.h
//
// GKSCNNodeComponent.h
// GameplayKit
//
// Copyright © 2017 Apple. All rights reserved.
//
#import <GameplayKit/GKComponent.h>
#import <GameplayKit/GKAgent.h>
NS_ASSUME_NONNULL_BEGIN
@class SCNNode;
/**
A component that encapsulates a SceneKit node.
*/
GK_BASE_AVAILABILITY_3 @interface GKSCNNodeComponent : GKComponent <GKAgentDelegate>
/**
* Creates a component that encapsulate the given SceneKit node. When the component is
* added to an entity, the SCNNode's entity property will be set.
*
* @param node Node to associate with the component.
* @see SCNNode.entity
*/
+ (instancetype)componentWithNode:(SCNNode *)node;
/**
* Initializes component to encapsulate the given SceneKit node. When the component is
* added to an entity, the SCNNode's entity property will be set.
*
* @param node Node to associate with the component.
* @see SCNNode.entity
*/
- (instancetype)initWithNode:(SCNNode *)node;
/**
* The SceneKit node this component encapsulates.
*/
@property (nonatomic, readonly) SCNNode *node;
@end
NS_ASSUME_NONNULL_END
// ========== GameplayKit.framework/Headers/GKPrimitives.h
//
// GKPrimitives.h
// GameplayKit
//
// Copyright © 2016 Apple. All rights reserved.
//
#include <simd/vector_types.h>
/**
* Representation of an axis aligned box via its min corner (lower-left) and max corner (upper-right)
*/
struct GKBox
{
vector_float3 boxMin;
vector_float3 boxMax;
};
typedef struct GKBox GKBox;
/**
* Representation of an axis aligned quad via its min corner (lower-left) and max corner (upper-right)
*/
struct GKQuad
{
vector_float2 quadMin;
vector_float2 quadMax;
};
typedef struct GKQuad GKQuad;
struct GKTriangle
{
vector_float3 points[3];
};
typedef struct GKTriangle GKTriangle;
// ========== GameplayKit.framework/Headers/GKObstacleGraph.h
//
// GKObstacleGraph.h
// GameplayKit
//
// Copyright © 2015 Apple. All rights reserved.
//
#import <GameplayKit/GKGraph.h>
NS_ASSUME_NONNULL_BEGIN
/**
* A collection of GKGraphNodes that are governed by a set of extruded GKPolygonObstacles
*/
GK_BASE_AVAILABILITY @interface GKObstacleGraph<NodeType : GKGraphNode2D*> : GKGraph
/*
* Array of the extruded obstacles currently represented by this graph
*/
@property (nonatomic, readonly, nonnull) NSArray<GKPolygonObstacle *> *obstacles;
/*
* The distance by which all obstacles are extruded.
* This is most commonly the spatial bounding radius of a potential traveler on this path
*/
@property (nonatomic, readonly) float bufferRadius;
/**
* Creates an optimal bidirectional graph based on a list of obstacles.
* Each vertex of each obstacle is extruded and a connection is made between each vertex that does not intersect an obstacle
* Guaranteed not to have any edges which intersect obstacles.
* Same effect as [[GKObstacleGraph alloc] init], setting bufferRadius, and then calling addObstacles.
* @param obstacles a list of obstacles to create the graph from
* @param bufferRadius the circular radius of a potential agent that will navigate this graph. Obstacles are extruded by this amount to create the graph. Must be positive. Negative values are clipped to 0.0f
*/
+ (instancetype)graphWithObstacles:(NSArray<GKPolygonObstacle *> *)obstacles bufferRadius:(float)bufferRadius;
- (instancetype)initWithObstacles:(NSArray<GKPolygonObstacle *> *)obstacles bufferRadius:(float)bufferRadius;
/**
* Creates an optimal bidirectional graph based on a list of obstacles.
* Each vertex of each obstacle is extruded and a connection is made between each vertex that does not intersect an obstacle
* Guaranteed not to have any edges which intersect obstacles.
* Same effect as [[GKObstacleGraph alloc] init], setting bufferRadius, and then calling addObstacles.
* @param obstacles a list of obstacles to create the graph from
* @param bufferRadius the circular radius of a potential agent that will navigate this graph. Obstacles are extruded by this amount to create the graph. Must be positive. Negative values are clipped to 0.0f