Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOEntityFilterPredicate.m File Reference
import "OOEntityFilterPredicate.h"
import "Entity.h"
import "ShipEntity.h"
import "OOPlanetEntity.h"
import "OORoleSet.h"
+ Include dependency graph for OOEntityFilterPredicate.m:

Go to the source code of this file.

Functions

BOOL YESPredicate (Entity *entity, void *parameter)
 
BOOL NOPredicate (Entity *entity, void *parameter)
 
BOOL NOTPredicate (Entity *entity, void *parameter)
 
BOOL ANDPredicate (Entity *entity, void *parameter)
 
BOOL ORPredicate (Entity *entity, void *parameter)
 
BOOL NORPredicate (Entity *entity, void *parameter)
 
BOOL XORPredicate (Entity *entity, void *parameter)
 
BOOL NANDPredicate (Entity *entity, void *parameter)
 
BOOL HasScanClassPredicate (Entity *entity, void *parameter)
 
BOOL HasClassPredicate (Entity *entity, void *parameter)
 
BOOL IsShipPredicate (Entity *entity, void *parameter)
 
BOOL IsStationPredicate (Entity *entity, void *parameter)
 
BOOL IsPlanetPredicate (Entity *entity, void *parameter)
 
BOOL IsSunPredicate (Entity *entity, void *parameter)
 
BOOL IsVisualEffectPredicate (Entity *entity, void *parameter)
 
BOOL HasRolePredicate (Entity *ship, void *parameter)
 
BOOL HasPrimaryRolePredicate (Entity *ship, void *parameter)
 
BOOL HasRoleInSetPredicate (Entity *ship, void *parameter)
 
BOOL HasPrimaryRoleInSetPredicate (Entity *ship, void *parameter)
 
BOOL IsHostileAgainstTargetPredicate (Entity *ship, void *parameter)
 

Function Documentation

◆ ANDPredicate()

BOOL ANDPredicate ( Entity * entity,
void * parameter )

Definition at line 56 of file OOEntityFilterPredicate.m.

57{
58 BinaryOperationPredicateParameter *param = parameter;
59
60 if (!param->predicate1(entity, param->parameter1)) return NO;
61 if (!param->predicate2(entity, param->parameter2)) return NO;
62 return YES;
63}

References BinaryOperationPredicateParameter::parameter1, BinaryOperationPredicateParameter::parameter2, BinaryOperationPredicateParameter::predicate1, and BinaryOperationPredicateParameter::predicate2.

Referenced by FindShips().

+ Here is the caller graph for this function:

◆ HasClassPredicate()

BOOL HasClassPredicate ( Entity * entity,
void * parameter )

Definition at line 116 of file OOEntityFilterPredicate.m.

117{
118 return [entity isKindOfClass:(Class)parameter];
119}

◆ HasPrimaryRoleInSetPredicate()

BOOL HasPrimaryRoleInSetPredicate ( Entity * ship,
void * parameter )

Definition at line 172 of file OOEntityFilterPredicate.m.

173{
174 return [(NSSet *)parameter containsObject:[(ShipEntity *)ship primaryRole]];
175}

◆ HasPrimaryRolePredicate()

BOOL HasPrimaryRolePredicate ( Entity * ship,
void * parameter )

Definition at line 160 of file OOEntityFilterPredicate.m.

161{
162 return [(ShipEntity *)ship hasPrimaryRole:(NSString *)parameter];
163}

Referenced by SystemShipsWithPrimaryRole().

+ Here is the caller graph for this function:

◆ HasRoleInSetPredicate()

BOOL HasRoleInSetPredicate ( Entity * ship,
void * parameter )

Definition at line 166 of file OOEntityFilterPredicate.m.

167{
168 return [[(ShipEntity *)ship roleSet] intersectsSet:(NSSet *)parameter];
169}

◆ HasRolePredicate()

BOOL HasRolePredicate ( Entity * ship,
void * parameter )

Definition at line 154 of file OOEntityFilterPredicate.m.

155{
156 return [(ShipEntity *)ship hasRole:(NSString *)parameter];
157}

Referenced by SystemShipsWithRole().

+ Here is the caller graph for this function:

◆ HasScanClassPredicate()

BOOL HasScanClassPredicate ( Entity * entity,
void * parameter )

Definition at line 110 of file OOEntityFilterPredicate.m.

111{
112 return [(id)parameter intValue] == [entity scanClass];
113}
OOScanClass scanClass
Definition Entity.h:106

References Entity::scanClass.

Referenced by SystemEntitiesWithScanClass().

+ Here is the caller graph for this function:

◆ IsHostileAgainstTargetPredicate()

BOOL IsHostileAgainstTargetPredicate ( Entity * ship,
void * parameter )

Definition at line 178 of file OOEntityFilterPredicate.m.

179{
180 return [(ShipEntity *)ship hasHostileTarget] && [(ShipEntity *)ship primaryTarget] == (ShipEntity *)parameter;
181}

◆ IsPlanetPredicate()

BOOL IsPlanetPredicate ( Entity * entity,
void * parameter )

Definition at line 134 of file OOEntityFilterPredicate.m.

135{
136 if (![entity isPlanet]) return NO;
137 OOStellarBodyType type = [(OOPlanetEntity *)entity planetType];
138 return (type == STELLAR_TYPE_NORMAL_PLANET || type == STELLAR_TYPE_MOON);
139}
OOStellarBodyType
@ STELLAR_TYPE_MOON
@ STELLAR_TYPE_NORMAL_PLANET

References STELLAR_TYPE_MOON, and STELLAR_TYPE_NORMAL_PLANET.

◆ IsShipPredicate()

BOOL IsShipPredicate ( Entity * entity,
void * parameter )

Definition at line 122 of file OOEntityFilterPredicate.m.

123{
124 return [entity isShip] && ![entity isSubEntity];
125}
unsigned isSubEntity
Definition Entity.h:95
unsigned isShip
Definition Entity.h:91

References Entity::isShip, and Entity::isSubEntity.

Referenced by FindShips().

+ Here is the caller graph for this function:

◆ IsStationPredicate()

BOOL IsStationPredicate ( Entity * entity,
void * parameter )

Definition at line 128 of file OOEntityFilterPredicate.m.

129{
130 return [entity isStation];
131}
unsigned isStation
Definition Entity.h:92

References Entity::isStation.

◆ IsSunPredicate()

BOOL IsSunPredicate ( Entity * entity,
void * parameter )

Definition at line 142 of file OOEntityFilterPredicate.m.

143{
144 return [entity isSun];
145}
BOOL isSun()
Definition Entity.m:167

References Entity::isSun.

+ Here is the call graph for this function:

◆ IsVisualEffectPredicate()

BOOL IsVisualEffectPredicate ( Entity * entity,
void * parameter )

Definition at line 148 of file OOEntityFilterPredicate.m.

149{
150 return [entity isVisualEffect] && ![entity isSubEntity];
151}
unsigned isVisualEffect
Definition Entity.h:104

References Entity::isSubEntity, and Entity::isVisualEffect.

◆ NANDPredicate()

BOOL NANDPredicate ( Entity * entity,
void * parameter )

Definition at line 98 of file OOEntityFilterPredicate.m.

99{
100 BinaryOperationPredicateParameter *param = parameter;
101 BOOL A, B;
102
103 A = param->predicate1(entity, param->parameter1);
104 B = param->predicate2(entity, param->parameter2);
105
106 return !(A && B);
107}

References BinaryOperationPredicateParameter::parameter1, BinaryOperationPredicateParameter::parameter2, BinaryOperationPredicateParameter::predicate1, and BinaryOperationPredicateParameter::predicate2.

◆ NOPredicate()

BOOL NOPredicate ( Entity * entity,
void * parameter )

Definition at line 41 of file OOEntityFilterPredicate.m.

42{
43 return NO;
44}

◆ NORPredicate()

BOOL NORPredicate ( Entity * entity,
void * parameter )

Definition at line 76 of file OOEntityFilterPredicate.m.

77{
78 BinaryOperationPredicateParameter *param = parameter;
79
80 if (param->predicate1(entity, param->parameter1)) return NO;
81 if (param->predicate2(entity, param->parameter2)) return NO;
82 return YES;
83}

References BinaryOperationPredicateParameter::parameter1, BinaryOperationPredicateParameter::parameter2, BinaryOperationPredicateParameter::predicate1, and BinaryOperationPredicateParameter::predicate2.

◆ NOTPredicate()

BOOL NOTPredicate ( Entity * entity,
void * parameter )

Definition at line 47 of file OOEntityFilterPredicate.m.

48{
49 ChainedEntityPredicateParameter *param = parameter;
50 if (param == NULL || param->predicate == NULL) return NO;
51
52 return !param->predicate(entity, param->parameter);
53}

References ChainedEntityPredicateParameter::parameter, and ChainedEntityPredicateParameter::predicate.

◆ ORPredicate()

BOOL ORPredicate ( Entity * entity,
void * parameter )

Definition at line 66 of file OOEntityFilterPredicate.m.

67{
68 BinaryOperationPredicateParameter *param = parameter;
69
70 if (param->predicate1(entity, param->parameter1)) return YES;
71 if (param->predicate2(entity, param->parameter2)) return YES;
72 return NO;
73}

References BinaryOperationPredicateParameter::parameter1, BinaryOperationPredicateParameter::parameter2, BinaryOperationPredicateParameter::predicate1, and BinaryOperationPredicateParameter::predicate2.

◆ XORPredicate()

BOOL XORPredicate ( Entity * entity,
void * parameter )

Definition at line 86 of file OOEntityFilterPredicate.m.

87{
88 BinaryOperationPredicateParameter *param = parameter;
89 BOOL A, B;
90
91 A = param->predicate1(entity, param->parameter1);
92 B = param->predicate2(entity, param->parameter2);
93
94 return (A || B) && !(A && B);
95}

References BinaryOperationPredicateParameter::parameter1, BinaryOperationPredicateParameter::parameter2, BinaryOperationPredicateParameter::predicate1, and BinaryOperationPredicateParameter::predicate2.

◆ YESPredicate()

BOOL YESPredicate ( Entity * entity,
void * parameter )

Definition at line 35 of file OOEntityFilterPredicate.m.

36{
37 return YES;
38}