Oolite
Loading...
Searching...
No Matches
Entity.m
Go to the documentation of this file.
1/*
2
3Entity.m
4
5Oolite
6Copyright (C) 2004-2013 Giles C Williams and contributors
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21MA 02110-1301, USA.
22
23*/
24
25#import "Entity.h"
26#import "EntityOOJavaScriptExtensions.h"
27#import "OOPlanetEntity.h"
28#import "PlayerEntity.h"
29
30#import "GameController.h"
31#import "OOConstToString.h"
32#import "OOMaths.h"
33#import "ResourceManager.h"
34#import "Universe.h"
35
36#import "CollisionRegion.h"
37
40#import "OODebugFlags.h"
41
42#ifdef OO_DEBUG_MONITOR_ENABLED
43uint32_t gLiveEntityCount = 0;
44size_t gTotalEntityMemory = 0;
45#endif
46
47#ifdef OO_DEBUG_MONITOR_ENABLED
48static NSString* const kOOLogEntityAddToList = @"entity.linkedList.add";
49static NSString* const kOOLogEntityAddToListError = @"entity.linkedList.add.error";
50static NSString* const kOOLogEntityRemoveFromList = @"entity.linkedList.remove";
51static NSString* const kOOLogEntityRemoveFromListError = @"entity.linkedList.remove.error";
52static NSString* const kOOLogEntityUpdateError = @"entity.linkedList.update.error";
53#endif
54static NSString* const kOOLogEntityVerificationError = @"entity.linkedList.verify.error";
55
56@interface Entity (OOPrivate)
57
58- (BOOL)checkLinkedLists;
59
60@end
61
62@implementation Entity
63
64- (id)init
65{
66 self = [super init];
67 if (EXPECT_NOT(self == nil))
68 return nil;
69
70 _sessionID = [UNIVERSE sessionID];
71
75
76 no_draw_distance = 100000.0; // 10 km
77
78 collidingEntities = [[NSMutableArray alloc] init];
79
80 scanClass = CLASS_NOT_SET;
81 [self setStatus:STATUS_COCKPIT_DISPLAY];
82
83 spawnTime = [UNIVERSE getTime];
84
85 isSunlit = YES;
86
87 atmosphereFogging = [[OOColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0] retain];
88
89#ifdef OO_DEBUG_MONITOR_ENABLED
90 gLiveEntityCount++;
91 gTotalEntityMemory += [self oo_objectSize];
92#endif
93
95 return self;
96}
97
98- (void)dealloc
99{
100 [UNIVERSE ensureEntityReallyRemoved:self];
103 [self deleteJSSelf];
104 [self setOwner:nil];
105 [atmosphereFogging release];
106
107#ifdef OO_DEBUG_MONITOR_ENABLED
108 gLiveEntityCount--;
109 gTotalEntityMemory -= [self oo_objectSize];
110#endif
111
112 [super dealloc];
113}
114
116{
117 return [NSString stringWithFormat:@"position: %@ scanClass: %@ status: %@", HPVectorDescription([self position]), OOStringFromScanClass([self scanClass]), OOStringFromEntityStatus([self status])];
118}
119
120- (NSUInteger)sessionID
121{
122 return _sessionID;
123}
124
125- (BOOL)isShip
126{
127 return isShip;
128}
129
130- (BOOL)isDock
131{
132 return NO;
133}
134
136{
137 return isStation;
138}
139
141{
142 return isSubEntity;
143}
144
145- (BOOL)isPlayer
146{
147 return isPlayer;
148}
149
150- (BOOL)isPlanet
151{
152 return NO;
153}
154
155- (BOOL)isSun
156{
157 return NO;
158}
159
160- (BOOL)isSunlit
161{
162 return isSunlit;
163}
164
166{
167 return [self isPlanet] || [self isSun];
168}
169
170- (BOOL)isSky
171{
172 return NO;
173}
174
176{
177 return isWormhole;
178}
179
180- (BOOL)isEffect
181{
182 return NO;
183}
184
186{
187 return NO;
188}
189
191{
192 return NO;
193}
194
196{
197 NSUInteger mySessionID = [self sessionID];
198 NSUInteger currentSessionID = [UNIVERSE sessionID];
199 if (EXPECT_NOT(mySessionID != currentSessionID)) {
200 OOLogERR(@"entity.invalidSession", @"Entity %@ from session %zu cannot be added to universe in session %zu. This is an internal error, please report it.", [self shortDescription], mySessionID, currentSessionID);
201 return NO;
202 }
203
204 return YES;
205}
206
208{
209#ifdef OO_DEBUG_MONITOR_ENABLED
211 OOLog(kOOLogEntityAddToList, @"DEBUG adding entity %@ to linked lists", self);
212#endif
213 //
214 // insert at the start
215 if (UNIVERSE) {
216 x_previous = nil;
217 x_next = UNIVERSE->x_list_start;
218 // move UP the list
219 while ((x_next) && (x_next->position.x - x_next->collision_radius < position.x - collision_radius)) {
221 x_next = x_next->x_next;
222 }
223 if (x_next)
224 x_next->x_previous = self;
225 if (x_previous)
226 x_previous->x_next = self;
227 else
228 UNIVERSE->x_list_start = self;
229
230 y_previous = nil;
231 y_next = UNIVERSE->y_list_start;
232 // move UP the list
233 while ((y_next) && (y_next->position.y - y_next->collision_radius < position.y - collision_radius)) {
235 y_next = y_next->y_next;
236 }
237 if (y_next)
238 y_next->y_previous = self;
239 if (y_previous)
240 y_previous->y_next = self;
241 else
242 UNIVERSE->y_list_start = self;
243
244 z_previous = nil;
245 z_next = UNIVERSE->z_list_start;
246 // move UP the list
247 while ((z_next) && (z_next->position.z - z_next->collision_radius < position.z - collision_radius)) {
249 z_next = z_next->z_next;
250 }
251 if (z_next)
252 z_next->z_previous = self;
253 if (z_previous)
254 z_previous->z_next = self;
255 else
256 UNIVERSE->z_list_start = self;
257 }
258
259#ifdef OO_DEBUG_MONITOR_ENABLED
261 if (![self checkLinkedLists]) {
262 OOLog(kOOLogEntityAddToListError, @"DEBUG LINKED LISTS - problem encountered while adding %@ to linked lists", self);
263 [UNIVERSE debugDumpEntities];
264 }
265 }
266#endif
267}
268
270{
271#ifdef OO_DEBUG_MONITOR_ENABLED
273 OOLog(kOOLogEntityRemoveFromList, @"DEBUG removing entity %@ from linked lists", self);
274#endif
275
276 if ((x_next == nil) && (x_previous == nil)) // removed already!
277 return;
278
279 // make sure the starting point is still correct
280 if (UNIVERSE) {
281 if ((UNIVERSE->x_list_start == self) && (x_next))
282 UNIVERSE->x_list_start = x_next;
283 if ((UNIVERSE->y_list_start == self) && (y_next))
284 UNIVERSE->y_list_start = y_next;
285 if ((UNIVERSE->z_list_start == self) && (z_next))
286 UNIVERSE->z_list_start = z_next;
287 }
288 //
289 if (x_previous)
290 x_previous->x_next = x_next;
291 if (x_next)
292 x_next->x_previous = x_previous;
293 //
294 if (y_previous)
295 y_previous->y_next = y_next;
296 if (y_next)
297 y_next->y_previous = y_previous;
298 //
299 if (z_previous)
300 z_previous->z_next = z_next;
301 if (z_next)
302 z_next->z_previous = z_previous;
303 //
304 x_previous = nil;
305 x_next = nil;
306 y_previous = nil;
307 y_next = nil;
308 z_previous = nil;
309 z_next = nil;
310
311#ifdef OO_DEBUG_MONITOR_ENABLED
313 if (![self checkLinkedLists]) {
314 OOLog(kOOLogEntityRemoveFromListError, @"DEBUG LINKED LISTS - problem encountered while removing %@ from linked lists", self);
315 [UNIVERSE debugDumpEntities];
316 }
317 }
318#endif
319}
320
322{
323 // DEBUG check for loops
324 if (UNIVERSE->n_entities > 0) {
325 int n;
326 Entity *check, *last;
327 //
328 last = nil;
329 //
330 n = UNIVERSE->n_entities;
331 check = UNIVERSE->x_list_start;
332 while ((n--) && (check)) {
333 last = check;
334 check = check->x_next;
335 }
336 if ((check) || (n > 0)) {
337 OOLog(kOOLogEntityVerificationError, @"Broken x_next %@ list (%d) ***", UNIVERSE->x_list_start, n);
338 return NO;
339 }
340 //
341 n = UNIVERSE->n_entities;
342 check = last;
343 while ((n--) && (check))
344 check = check->x_previous;
345 if ((check) || (n > 0)) {
346 OOLog(kOOLogEntityVerificationError, @"Broken x_previous %@ list (%d) ***", UNIVERSE->x_list_start, n);
347 return NO;
348 }
349 //
350 n = UNIVERSE->n_entities;
351 check = UNIVERSE->y_list_start;
352 while ((n--) && (check)) {
353 last = check;
354 check = check->y_next;
355 }
356 if ((check) || (n > 0)) {
357 OOLog(kOOLogEntityVerificationError, @"Broken y_next %@ list (%d) ***", UNIVERSE->y_list_start, n);
358 return NO;
359 }
360 //
361 n = UNIVERSE->n_entities;
362 check = last;
363 while ((n--) && (check))
364 check = check->y_previous;
365 if ((check) || (n > 0)) {
366 OOLog(kOOLogEntityVerificationError, @"Broken y_previous %@ list (%d) ***", UNIVERSE->y_list_start, n);
367 return NO;
368 }
369 //
370 n = UNIVERSE->n_entities;
371 check = UNIVERSE->z_list_start;
372 while ((n--) && (check)) {
373 last = check;
374 check = check->z_next;
375 }
376 if ((check) || (n > 0)) {
377 OOLog(kOOLogEntityVerificationError, @"Broken z_next %@ list (%d) ***", UNIVERSE->z_list_start, n);
378 return NO;
379 }
380 //
381 n = UNIVERSE->n_entities;
382 check = last;
383 while ((n--) && (check))
384 check = check->z_previous;
385 if ((check) || (n > 0)) {
386 OOLog(kOOLogEntityVerificationError, @"Broken z_previous %@ list (%d) ***", UNIVERSE->z_list_start, n);
387 return NO;
388 }
389 }
390 return YES;
391}
392
394{
395 if (!UNIVERSE)
396 return; // not in the UNIVERSE - don't do this!
397 if ((x_next == nil) && (x_previous == nil))
398 return; // not in the lists - don't do this!
399
400#ifdef OO_DEBUG_MONITOR_ENABLED
402 if (![self checkLinkedLists]) {
403 OOLog(kOOLogEntityVerificationError, @"DEBUG LINKED LISTS problem encountered before updating linked lists for %@", self);
404 [UNIVERSE debugDumpEntities];
405 }
406 }
407#endif
408
409 // update position in linked list for position.x
410 // take self out of list..
411 if (x_previous)
412 x_previous->x_next = x_next;
413 if (x_next)
414 x_next->x_previous = x_previous;
415 // sink DOWN the list
416 while ((x_previous) && (x_previous->position.x - x_previous->collision_radius > position.x - collision_radius)) {
418 x_previous = x_previous->x_previous;
419 }
420 // bubble UP the list
421 while ((x_next) && (x_next->position.x - x_next->collision_radius < position.x - collision_radius)) {
423 x_next = x_next->x_next;
424 }
425 if (x_next) // insert self into the list before x_next..
426 x_next->x_previous = self;
427 if (x_previous) // insert self into the list after x_previous..
428 x_previous->x_next = self;
429 if ((x_previous == nil) && (UNIVERSE)) // if we're the first then tell the UNIVERSE!
430 UNIVERSE->x_list_start = self;
431
432 // update position in linked list for position.y
433 // take self out of list..
434 if (y_previous)
435 y_previous->y_next = y_next;
436 if (y_next)
437 y_next->y_previous = y_previous;
438 // sink DOWN the list
439 while ((y_previous) && (y_previous->position.y - y_previous->collision_radius > position.y - collision_radius)) {
441 y_previous = y_previous->y_previous;
442 }
443 // bubble UP the list
444 while ((y_next) && (y_next->position.y - y_next->collision_radius < position.y - collision_radius)) {
446 y_next = y_next->y_next;
447 }
448 if (y_next) // insert self into the list before y_next..
449 y_next->y_previous = self;
450 if (y_previous) // insert self into the list after y_previous..
451 y_previous->y_next = self;
452 if ((y_previous == nil) && (UNIVERSE)) // if we're the first then tell the UNIVERSE!
453 UNIVERSE->y_list_start = self;
454
455 // update position in linked list for position.z
456 // take self out of list..
457 if (z_previous)
458 z_previous->z_next = z_next;
459 if (z_next)
460 z_next->z_previous = z_previous;
461 // sink DOWN the list
462 while ((z_previous) && (z_previous->position.z - z_previous->collision_radius > position.z - collision_radius)) {
464 z_previous = z_previous->z_previous;
465 }
466 // bubble UP the list
467 while ((z_next) && (z_next->position.z - z_next->collision_radius < position.z - collision_radius)) {
469 z_next = z_next->z_next;
470 }
471 if (z_next) // insert self into the list before z_next..
472 z_next->z_previous = self;
473 if (z_previous) // insert self into the list after z_previous..
474 z_previous->z_next = self;
475 if ((z_previous == nil) && (UNIVERSE)) // if we're the first then tell the UNIVERSE!
476 UNIVERSE->z_list_start = self;
477
478 // done
479#ifdef OO_DEBUG_MONITOR_ENABLED
481 if (![self checkLinkedLists]) {
482 OOLog(kOOLogEntityUpdateError, @"DEBUG LINKED LISTS problem encountered after updating linked lists for %@", self);
483 [UNIVERSE debugDumpEntities];
484 }
485 }
486#endif
487}
488
490{
491 // Do nothing
492}
493
495{
496 // Do nothing
497}
498
500{
501 // do nothing for now, this can be expanded in sub classes
502 OOLog(@"general.error.subclassResponsibility.Entity-warnAboutHostiles", @"%@", @"***** Entity does nothing in warnAboutHostiles");
503}
504
509
510- (void)setCollisionRegion:(CollisionRegion*)region
511{
512 if (collisionRegion)
513 [collisionRegion release];
514 collisionRegion = [region retain];
515}
516
517- (void)setUniversalID:(OOUniversalID)uid
518{
519 universalID = uid;
520}
521
523{
524 return universalID;
525}
526
528{
529 return throw_sparks;
530}
531
532- (void)setThrowSparks:(BOOL)value
533{
534 throw_sparks = value;
535}
536
538{
539 // do nothing for now
540}
541
542- (void)setOwner:(Entity*)ent
543{
544 [_owner release];
546}
547
548- (id)owner
549{
551}
552
554{
555 id owner = [self owner];
556 if ([owner isShipWithSubEntityShip:self])
557 return owner;
558 return nil;
559}
560
561- (id<OOWeakReferenceSupport>)superShaderBindingTarget
562{
563 return [self parentEntity];
564}
565
567{
568 ShipEntity* parent = [self parentEntity];
569 if (parent != nil)
570 return [parent rootShipEntity];
571 if ([self isShip])
572 return (ShipEntity*)self;
573 return nil;
574}
575
577{
578 return position;
579}
580
585
587{
589}
590
592{
594}
595
596// Exposed to uniform bindings.
597// so needs to remain at OpenGL precision levels
602
603- (Vector)vectorTo:(Entity*)entity
604{
605 return HPVectorToVector(HPvector_subtract([entity position], [self position]));
606}
607
608- (void)setPosition:(HPVector)posn
609{
610 position = posn;
612}
613
614- (void)setPositionX:(OOHPScalar)x y:(OOHPScalar)y z:(OOHPScalar)z
615{
616 position.x = x;
617 position.y = y;
618 position.z = z;
620}
621
626
631
632- (HPVector)absolutePositionForSubentityOffset:(HPVector)offset
633{
635 Entity* last = nil;
636 Entity* father = [self parentEntity];
637
638 while (father != nil && father != last) {
639 abspos = HPvector_add(OOHPVectorMultiplyMatrix(abspos, [father drawRotationMatrix]), [father position]);
640 last = father;
641 if (![last isSubEntity])
642 break;
643 father = [father owner];
644 }
645 return abspos;
646}
647
649{
650 return zero_distance;
651}
652
654{
655 return cam_zero_distance;
656}
657
658- (NSComparisonResult)compareZeroDistance:(Entity*)otherEntity
659{
660 if ((otherEntity) && (zero_distance > otherEntity->zero_distance))
661 return NSOrderedAscending;
662 else
663 return NSOrderedDescending;
664}
665
667{
668 return boundingBox;
669}
670
671- (GLfloat)mass
672{
673 return mass;
674}
675
676- (void)setOrientation:(Quaternion)quat
677{
678 orientation = quat;
679 [self orientationChanged];
680}
681
683{
684 return orientation;
685}
686
688{
689 return [self orientation];
690}
691
692- (void)setNormalOrientation:(Quaternion)quat
693{
694 [self setOrientation:quat];
695}
696
702
703- (void)setVelocity:(Vector)vel
704{
705 velocity = vel;
706}
707
709{
710 return velocity;
711}
712
713- (double)speed
714{
715 return magnitude([self velocity]);
716}
717
719{
720 return distanceTravelled;
721}
722
723- (void)setDistanceTravelled:(GLfloat)value
724{
725 distanceTravelled = value;
726}
727
728- (void)setStatus:(OOEntityStatus)stat
729{
730 _status = stat;
731}
732
734{
735 return _status;
736}
737
738- (void)setScanClass:(OOScanClass)sClass
739{
740 scanClass = sClass;
741}
742
744{
745 return scanClass;
746}
747
748- (void)setEnergy:(GLfloat)amount
749{
750 energy = amount;
751}
752
753- (GLfloat)energy
754{
755 return energy;
756}
757
758- (void)setMaxEnergy:(GLfloat)amount
759{
760 maxEnergy = amount;
761}
762
763- (GLfloat)maxEnergy
764{
765 return maxEnergy;
766}
767
768- (void)applyRoll:(GLfloat)roll andClimb:(GLfloat)climb
769{
770 if ((roll == 0.0) && (climb == 0.0) && (!hasRotated))
771 return;
772
773 if (roll)
775 if (climb)
777
778 [self orientationChanged];
779}
780
781- (void)applyRoll:(GLfloat)roll climb:(GLfloat)climb andYaw:(GLfloat)yaw
782{
783 if ((roll == 0.0) && (climb == 0.0) && (yaw == 0.0) && (!hasRotated))
784 return;
785
786 if (roll)
788 if (climb)
790 if (yaw)
792
793 [self orientationChanged];
794}
795
796- (void)moveForward:(double)amount
797{
799 position = HPvector_add(position, forward);
800 distanceTravelled += amount;
801}
802
804{
805 return rotMatrix;
806}
807
809{
810 return rotMatrix;
811}
812
814{
815 OOMatrix result = rotMatrix;
816 return OOMatrixHPTranslate(result, position);
817}
818
820{
821 OOMatrix result = rotMatrix;
822 return OOMatrixHPTranslate(result, position);
823}
824
826{
827 return YES;
828}
829
831{
832 return collision_radius;
833}
834
836{
837 return collision_radius;
838}
839
840- (void)setCollisionRadius:(GLfloat)amount
841{
842 collision_radius = amount;
843}
844
845- (NSMutableArray*)collisionArray
846{
847 return collidingEntities;
848}
849
850- (void)update:(OOTimeDelta)delta_t
851{
852 if (_status != STATUS_COCKPIT_DISPLAY) {
853 if ([self isSubEntity]) {
857 } else {
859 cam_zero_distance = HPdistance2([PLAYER viewpointPosition], position);
861 }
862 } else {
866 }
867
868 if ([self status] != STATUS_COCKPIT_DISPLAY) {
869 [self applyVelocity:delta_t];
870 }
871
876}
877
878- (void)applyVelocity:(OOTimeDelta)delta_t
879{
881}
882
883- (BOOL)checkCloseCollisionWith:(Entity*)other
884{
885 return other != nil;
886}
887
889{
891 return 0;
892}
893
894- (void)drawImmediate:(bool)immediate translucent:(bool)translucent
895{
897}
898
899- (void)takeEnergyDamage:(double)amount from:(Entity*)ent becauseOf:(Entity*)other weaponIdentifier:(NSString*)weaponIdentifier
900{
901}
902
904{
905 if (OOLogWillDisplayMessagesInClass(@"dumpState")) {
906 OOLog(@"dumpState", @"State for %@:", self);
908 OOLogIndent();
909 @try {
910 [self dumpSelfState];
911 }
912 @catch (id exception) {
913 }
915 }
916}
917
919{
920 NSMutableArray* flags = nil;
921 NSString* flagsString = nil;
922 id owner = [self owner];
923
924 if (owner == self)
925 owner = @"self";
926 else if (owner == nil)
927 owner = @"none";
928
929 OOLog(@"dumpState.entity", @"Universal ID: %u", universalID);
930 OOLog(@"dumpState.entity", @"Scan class: %@", OOStringFromScanClass(scanClass));
931 OOLog(@"dumpState.entity", @"Status: %@", OOStringFromEntityStatus([self status]));
932 OOLog(@"dumpState.entity", @"Position: %@", HPVectorDescription(position));
933 OOLog(@"dumpState.entity", @"Orientation: %@", QuaternionDescription(orientation));
934 OOLog(@"dumpState.entity", @"Distance travelled: %g", distanceTravelled);
935 OOLog(@"dumpState.entity", @"Energy: %g of %g", energy, maxEnergy);
936 OOLog(@"dumpState.entity", @"Mass: %g", mass);
937 OOLog(@"dumpState.entity", @"Owner: %@", owner);
938
939 flags = [NSMutableArray array];
940#define ADD_FLAG_IF_SET(x) \
941 if (x) { \
942 [flags addObject:@ #x]; \
943 }
953 flagsString = [flags count] ? [flags componentsJoinedByString:@", "] : (NSString*)@"none";
954 OOLog(@"dumpState.entity", @"Flags: %@", flagsString);
955 OOLog(@"dumpState.entity", @"Collision Test Filter: %u", collisionTestFilter);
956}
957
958- (void)subEntityReallyDied:(ShipEntity*)sub
959{
960 OOLog(@"entity.bug", @"%s called for non-ship entity %p by %p", __PRETTY_FUNCTION__, self, sub);
961}
962
963- (NSUInteger)lastDrawCounter
964{
965 return lastDrawCounter;
966}
967
968- (void)setLastDrawCounter:(NSUInteger)drawCounter
969{
970 lastDrawCounter = drawCounter;
971 return;
972}
973
974// For shader bindings.
976{
977 return [UNIVERSE getTime];
978}
979
980- (GLfloat)spawnTime
981{
982 return spawnTime;
983}
984
986{
987 return [UNIVERSE getTime] - spawnTime;
988}
989
990- (void)setAtmosphereFogging:(OOColor*)fogging
991{
992 [atmosphereFogging release];
993 atmosphereFogging = [fogging retain];
994}
995
997{
998 return [[atmosphereFogging retain] autorelease];
999}
1000
1001#ifdef OO_DEBUG_MONITOR_ENABLED
1002- (NSString*)descriptionForObjDumpBasic
1003{
1004 NSString* result = [self descriptionComponents];
1005 if (result != nil)
1006 result = [NSString stringWithFormat:@"%@ %@", NSStringFromClass([self class]), result];
1007 else
1008 result = [self description];
1009
1010 return result;
1011}
1012
1013- (NSString*)descriptionForObjDump
1014{
1015 NSString* result = [self descriptionForObjDumpBasic];
1016
1017 result = [result stringByAppendingFormat:@" range: %g (visible: %@)", HPdistance([self position], [PLAYER position]), [self isVisible] ? @"yes" : @"no"];
1018
1019 return result;
1020}
1021
1022- (NSSet*)allTextures
1023{
1024 return nil;
1025}
1026#endif
1027
1029{
1031}
1032
1034{
1035 switch ([self status]) {
1036 case STATUS_IN_FLIGHT:
1037 case STATUS_DOCKING:
1038 case STATUS_LAUNCHING:
1039 case STATUS_AUTOPILOT_ENGAGED:
1040 case STATUS_WITCHSPACE_COUNTDOWN:
1041 case STATUS_BEING_SCOOPED:
1042 case STATUS_EFFECT:
1043 case STATUS_ACTIVE:
1044 return YES;
1045 default:
1046 return NO;
1047 }
1048}
1049
1054
1055@end
OOEntityStatus
Definition Entity.h:60
NSString * OOStringFromScanClass(OOScanClass scanClass) CONST_FUNC
OOScanClass
Definition Entity.h:69
#define ABSOLUTE_NO_DRAW_DISTANCE2
Definition Entity.h:50
NSString * OOStringFromEntityStatus(OOEntityStatus status) CONST_FUNC
#define ADD_FLAG_IF_SET(x)
static NSString *const kOOLogEntityVerificationError
Definition Entity.m:54
#define gDebugFlags
@ DEBUG_LINKED_LISTS
Definition OODebugFlags.h:4
#define DESTROY(x)
#define EXPECT_NOT(x)
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
Definition OOHPVector.h:166
OOINLINE HPVector HPvector_subtract(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:236
OOINLINE HPVector HPvector_multiply_scalar(HPVector v, OOHPScalar s) INLINE_CONST_FUNC
Definition OOHPVector.h:198
const HPVector kZeroHPVector
Definition OOHPVector.m:27
OOINLINE bool HPvector_equal(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:250
OOINLINE Vector HPVectorToVector(HPVector v) INLINE_CONST_FUNC
Definition OOHPVector.h:175
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
Definition OOHPVector.h:293
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:213
OOINLINE OOHPScalar HPmagnitude2(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:255
void OOLogPushIndent(void)
Definition OOLogging.m:301
#define OOLogERR(class, format,...)
Definition OOLogging.h:125
void OOLogPopIndent(void)
Definition OOLogging.m:323
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
Definition OOLogging.m:136
#define OOLogGenericSubclassResponsibility()
Definition OOLogging.h:141
#define OOLog(class, format,...)
Definition OOLogging.h:84
void OOLogIndent(void)
Definition OOLogging.m:345
double OOHPScalar
Definition OOMaths.h:51
const OOMatrix kIdentityMatrix
Definition OOMatrix.m:28
OOINLINE OOMatrix OOMatrixHPTranslate(OOMatrix m, HPVector offset) INLINE_CONST_FUNC
Definition OOMatrix.h:259
HPVector OOHPVectorMultiplyMatrix(HPVector v, OOMatrix m) CONST_FUNC
Definition OOMatrix.m:137
OOMatrix OOMatrixForQuaternionRotation(Quaternion orientation)
Definition OOMatrix.m:56
return nil
OOINLINE bool quaternion_equal(Quaternion a, Quaternion b) INLINE_CONST_FUNC
void quaternion_rotate_about_x(Quaternion *quat, OOScalar angle) NONNULL_FUNC
const Quaternion kIdentityQuaternion
void quaternion_rotate_about_z(Quaternion *quat, OOScalar angle) NONNULL_FUNC
OOINLINE void quaternion_normalize(Quaternion *quat) NONNULL_FUNC ALWAYS_INLINE_FUNC
void quaternion_rotate_about_y(Quaternion *quat, OOScalar angle) NONNULL_FUNC
HPVector HPvector_forward_from_quaternion(Quaternion quat) CONST_FUNC
float y
float x
uint16_t OOUniversalID
Definition OOTypes.h:165
double OOTimeDelta
Definition OOTypes.h:193
OOINLINE OOScalar magnitude(Vector vec) INLINE_CONST_FUNC
Definition OOVector.h:242
#define PLAYER
#define UNIVERSE
Definition Universe.h:827
BOOL checkLinkedLists()
Definition Entity.m:321
OOColor * fogUniform()
Definition Entity.m:996
unsigned isImmuneToBreakPatternHide
Definition Entity.m:1050
unsigned throw_sparks
Definition Entity.h:97
BOOL validForAddToUniverse()
Definition Entity.m:195
void throwSparks()
Definition Entity.m:537
OOWeakReference * _owner
Definition Entity.h:158
void wasAddedToUniverse()
Definition Entity.m:489
OOColor * atmosphereFogging
Definition Entity.h:111
unsigned hasRotated
Definition Entity.h:93
void removeFromLinkedLists()
Definition Entity.m:269
GLfloat collision_radius
Definition Entity.h:107
GLfloat maxEnergy
Definition Entity.m:763
unsigned isVisualEffect
Definition Entity.m:185
GLfloat timeElapsedSinceSpawn()
Definition Entity.m:985
CollisionRegion * collisionRegion
Definition Entity.m:505
OOUniversalID universalID
Definition Entity.m:522
HPVector absolutePositionForSubentity()
Definition Entity.m:627
Entity * z_next
Definition Entity.h:118
NSMutableArray * collisionArray()
Definition Entity.m:845
double camZeroDistance()
Definition Entity.m:653
void dumpState()
Definition Entity.m:903
NSMutableArray * collidingEntities
Definition Entity.h:144
Entity * z_previous
Definition Entity.h:118
Quaternion orientation
Definition Entity.m:682
unsigned isSubEntity
Definition Entity.m:140
BOOL isSun()
Definition Entity.m:155
GLfloat cameraRangeFront()
Definition Entity.m:586
void updateCameraRelativePosition()
Definition Entity.m:622
unsigned hasMoved
Definition Entity.h:92
BOOL checkLinkedLists()
Definition Entity.m:321
void setOrientation:(Quaternion quat)
Definition Entity.m:676
GLfloat energy
Definition Entity.m:753
GLfloat zero_distance
Definition Entity.h:104
unsigned isShip
Definition Entity.m:125
unsigned collisionTestFilter
Definition Entity.h:96
OOTimeAbsolute spawnTime
Definition Entity.m:980
double zeroDistance()
Definition Entity.m:648
GLfloat collisionRadius()
Definition Entity.m:830
OOScanClass scanClass
Definition Entity.m:743
void setOwner:(Entity *ent)
Definition Entity.m:542
Entity * x_previous
Definition Entity.h:116
void wasRemovedFromUniverse()
Definition Entity.m:494
BOOL isDock()
Definition Entity.m:130
BOOL isInSpace()
Definition Entity.m:1033
void orientationChanged()
Definition Entity.m:697
Vector cameraRelativePosition
Definition Entity.m:581
OOEntityStatus status()
Definition Entity.m:733
unsigned isWormhole
Definition Entity.m:175
GLfloat frustumRadius()
Definition Entity.m:835
GLfloat cam_zero_distance
Definition Entity.h:105
GLfloat distanceTravelled
Definition Entity.m:718
OOMatrix transformationMatrix()
Definition Entity.m:813
NSUInteger sessionID()
Definition Entity.m:120
OOMatrix drawTransformationMatrix()
Definition Entity.m:819
NSUInteger lastDrawCounter
Definition Entity.m:963
BOOL isSky()
Definition Entity.m:170
BOOL isEffect()
Definition Entity.m:180
void updateLinkedLists()
Definition Entity.m:393
void warnAboutHostiles()
Definition Entity.m:499
NSString * descriptionComponents()
Definition Entity.m:115
ShipEntity * rootShipEntity()
Definition Entity.m:566
BoundingBox boundingBox
Definition Entity.m:666
id< OOWeakReferenceSupport > superShaderBindingTarget()
Definition Entity.m:561
unsigned isStation
Definition Entity.m:135
unsigned isPlayer
Definition Entity.m:145
BOOL throwingSparks()
Definition Entity.m:527
void dumpSelfState()
Definition Entity.m:918
BOOL isVisible()
Definition Entity.m:1028
NSUInteger _sessionID
Definition Entity.h:156
HPVector position
Definition Entity.m:576
BOOL canCollide()
Definition Entity.m:825
HPVector absolutePositionForSubentityOffset:(HPVector offset)
Definition Entity.m:632
GLfloat cameraRangeBack()
Definition Entity.m:591
Quaternion lastOrientation
Definition Entity.h:130
BOOL isWaypoint()
Definition Entity.m:190
Entity * x_next
Definition Entity.h:116
GLfloat no_draw_distance
Definition Entity.h:106
OOMatrix rotationMatrix()
Definition Entity.m:803
Quaternion normalOrientation()
Definition Entity.m:687
BOOL isStellarObject()
Definition Entity.m:165
Vector velocity
Definition Entity.m:708
GLfloat universalTime()
Definition Entity.m:975
ShipEntity * parentEntity()
Definition Entity.m:553
BOOL isPlanet()
Definition Entity.m:150
void addToLinkedLists()
Definition Entity.m:207
OOEntityStatus _status
Definition Entity.h:159
HPVector lastPosition
Definition Entity.h:129
double speed()
Definition Entity.m:713
OOMatrix rotMatrix
Definition Entity.h:134
id init()
Definition Entity.m:64
Vector relativePosition()
Definition Entity.m:598
void setStatus:(OOEntityStatus stat)
Definition Entity.m:728
id owner()
Definition Entity.m:548
void applyVelocity:(OOTimeDelta delta_t)
Definition Entity.m:878
Entity * y_next
Definition Entity.h:117
unsigned isSunlit
Definition Entity.m:160
Entity * y_previous
Definition Entity.h:117
void dealloc()
Definition Entity.m:98
GLfloat mass
Definition Entity.m:671
double findCollisionRadius()
Definition Entity.m:888
OOMatrix drawRotationMatrix()
Definition Entity.m:808
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:107
voidpf uLong offset
Definition ioapi.h:132