26#import "EntityOOJavaScriptExtensions.h"
42#ifdef OO_DEBUG_MONITOR_ENABLED
43uint32_t gLiveEntityCount = 0;
44size_t gTotalEntityMemory = 0;
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";
56@interface Entity (OOPrivate)
89#ifdef OO_DEBUG_MONITOR_ENABLED
91 gTotalEntityMemory += [
self oo_objectSize];
100 [UNIVERSE ensureEntityReallyRemoved:
self];
107#ifdef OO_DEBUG_MONITOR_ENABLED
109 gTotalEntityMemory -= [
self oo_objectSize];
117 return [
NSString stringWithFormat:@"position: %@ scanClass: %@ status: %@", HPVectorDescription([
self position]), OOStringFromScanClass([
self scanClass]), OOStringFromEntityStatus([
self status])];
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);
209#ifdef OO_DEBUG_MONITOR_ENABLED
211 OOLog(kOOLogEntityAddToList,
@"DEBUG adding entity %@ to linked lists",
self);
224 x_next->x_previous =
self;
238 y_next->y_previous =
self;
252 z_next->z_previous =
self;
259#ifdef OO_DEBUG_MONITOR_ENABLED
262 OOLog(kOOLogEntityAddToListError,
@"DEBUG LINKED LISTS - problem encountered while adding %@ to linked lists",
self);
263 [UNIVERSE debugDumpEntities];
271#ifdef OO_DEBUG_MONITOR_ENABLED
273 OOLog(kOOLogEntityRemoveFromList,
@"DEBUG removing entity %@ from linked lists",
self);
311#ifdef OO_DEBUG_MONITOR_ENABLED
314 OOLog(kOOLogEntityRemoveFromListError,
@"DEBUG LINKED LISTS - problem encountered while removing %@ from linked lists",
self);
315 [UNIVERSE debugDumpEntities];
332 while ((n--) && (check)) {
336 if ((check) || (n > 0)) {
343 while ((n--) && (check))
345 if ((check) || (n > 0)) {
352 while ((n--) && (check)) {
356 if ((check) || (n > 0)) {
363 while ((n--) && (check))
365 if ((check) || (n > 0)) {
372 while ((n--) && (check)) {
376 if ((check) || (n > 0)) {
383 while ((n--) && (check))
385 if ((check) || (n > 0)) {
400#ifdef OO_DEBUG_MONITOR_ENABLED
404 [UNIVERSE debugDumpEntities];
426 x_next->x_previous =
self;
449 y_next->y_previous =
self;
472 z_next->z_previous =
self;
479#ifdef OO_DEBUG_MONITOR_ENABLED
482 OOLog(kOOLogEntityUpdateError,
@"DEBUG LINKED LISTS problem encountered after updating linked lists for %@",
self);
483 [UNIVERSE debugDumpEntities];
502 OOLog(
@"general.error.subclassResponsibility.Entity-warnAboutHostiles",
@"%@",
@"***** Entity does nothing in warnAboutHostiles");
532- (void)setThrowSparks:(BOOL)value
556 if ([
owner isShipWithSubEntityShip:
self])
638 while (father !=
nil && father != last) {
658- (NSComparisonResult)compareZeroDistance:(
Entity*)otherEntity
661 return NSOrderedAscending;
663 return NSOrderedDescending;
723- (void)setDistanceTravelled:(GLfloat)value
748- (void)setEnergy:(GLfloat)amount
758- (void)setMaxEnergy:(GLfloat)amount
768- (void)applyRoll:(GLfloat)roll andClimb:(GLfloat)climb
770 if ((roll == 0.0) && (climb == 0.0) && (!
hasRotated))
781- (void)applyRoll:(GLfloat)roll climb:(GLfloat)climb andYaw:(GLfloat)yaw
783 if ((roll == 0.0) && (climb == 0.0) && (yaw == 0.0) && (!
hasRotated))
796- (void)moveForward:(
double)amount
840- (void)setCollisionRadius:(GLfloat)amount
852 if (
_status != STATUS_COCKPIT_DISPLAY) {
868 if ([
self status] != STATUS_COCKPIT_DISPLAY) {
883- (BOOL)checkCloseCollisionWith:(
Entity*)other
894- (void)drawImmediate:(
bool)immediate translucent:(
bool)translucent
899- (void)takeEnergyDamage:(
double)amount from:(
Entity*)ent becauseOf:(
Entity*)other weaponIdentifier:(NSString*)weaponIdentifier
906 OOLog(
@"dumpState",
@"State for %@:",
self);
912 @catch (
id exception) {
920 NSMutableArray* flags =
nil;
921 NSString* flagsString =
nil;
932 OOLog(
@"dumpState.entity",
@"Position: %@", HPVectorDescription(
position));
933 OOLog(
@"dumpState.entity",
@"Orientation: %@", QuaternionDescription(
orientation));
936 OOLog(
@"dumpState.entity",
@"Mass: %g",
mass);
937 OOLog(
@"dumpState.entity",
@"Owner: %@",
owner);
940#define ADD_FLAG_IF_SET(x) \
942 [flags addObject:@ #x]; \
953 flagsString = [
flags count] ? [
flags componentsJoinedByString:@", "] : (NSString*)
@"none";
954 OOLog(
@"dumpState.entity",
@"Flags: %@", flagsString);
960 OOLog(
@"entity.bug",
@"%s called for non-ship entity %p by %p", __PRETTY_FUNCTION__,
self, sub);
968- (void)setLastDrawCounter:(NSUInteger)drawCounter
977 return [UNIVERSE getTime];
1001#ifdef OO_DEBUG_MONITOR_ENABLED
1002- (NSString*)descriptionForObjDumpBasic
1004 NSString* result = [
self descriptionComponents];
1006 result = [NSString stringWithFormat:@"%@ %@", NSStringFromClass([
self class]), result];
1008 result = [
self description];
1013- (NSString*)descriptionForObjDump
1015 NSString* result = [
self descriptionForObjDumpBasic];
1017 result = [result stringByAppendingFormat:@" range: %g (visible: %@)", HPdistance([
self position], [PLAYER position]), [
self isVisible] ? @"yes" : @"no"];
1022- (NSSet*)allTextures
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:
NSString * OOStringFromScanClass(OOScanClass scanClass) CONST_FUNC
#define ABSOLUTE_NO_DRAW_DISTANCE2
NSString * OOStringFromEntityStatus(OOEntityStatus status) CONST_FUNC
#define ADD_FLAG_IF_SET(x)
static NSString *const kOOLogEntityVerificationError
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_subtract(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_multiply_scalar(HPVector v, OOHPScalar s) INLINE_CONST_FUNC
const HPVector kZeroHPVector
OOINLINE bool HPvector_equal(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE Vector HPVectorToVector(HPVector v) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPmagnitude2(HPVector vec) INLINE_CONST_FUNC
void OOLogPushIndent(void)
#define OOLogERR(class, format,...)
void OOLogPopIndent(void)
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
#define OOLogGenericSubclassResponsibility()
#define OOLog(class, format,...)
const OOMatrix kIdentityMatrix
OOINLINE OOMatrix OOMatrixHPTranslate(OOMatrix m, HPVector offset) INLINE_CONST_FUNC
HPVector OOHPVectorMultiplyMatrix(HPVector v, OOMatrix m) CONST_FUNC
OOMatrix OOMatrixForQuaternionRotation(Quaternion orientation)
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
OOINLINE OOScalar magnitude(Vector vec) INLINE_CONST_FUNC
unsigned isImmuneToBreakPatternHide
BOOL validForAddToUniverse()
void wasAddedToUniverse()
OOColor * atmosphereFogging
void removeFromLinkedLists()
GLfloat timeElapsedSinceSpawn()
CollisionRegion * collisionRegion
OOUniversalID universalID
HPVector absolutePositionForSubentity()
NSMutableArray * collisionArray()
NSMutableArray * collidingEntities
GLfloat cameraRangeFront()
void updateCameraRelativePosition()
void setOrientation:(Quaternion quat)
unsigned collisionTestFilter
GLfloat collisionRadius()
void setOwner:(Entity *ent)
void wasRemovedFromUniverse()
void orientationChanged()
Vector cameraRelativePosition
GLfloat cam_zero_distance
GLfloat distanceTravelled
OOMatrix transformationMatrix()
OOMatrix drawTransformationMatrix()
NSUInteger lastDrawCounter
NSString * descriptionComponents()
ShipEntity * rootShipEntity()
id< OOWeakReferenceSupport > superShaderBindingTarget()
HPVector absolutePositionForSubentityOffset:(HPVector offset)
GLfloat cameraRangeBack()
Quaternion lastOrientation
OOMatrix rotationMatrix()
Quaternion normalOrientation()
ShipEntity * parentEntity()
Vector relativePosition()
void setStatus:(OOEntityStatus stat)
void applyVelocity:(OOTimeDelta delta_t)
double findCollisionRadius()
OOMatrix drawRotationMatrix()
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
id weakRefUnderlyingObject()