34#import "OOConstToJSString.h"
56@interface OOVisualEffectEntity (Private)
58- (void)drawSubEntityImmediate:(
bool)immediate translucent:(
bool)translucent;
60- (void)addSubEntity:(
Entity<OOSubEntity>*)subent;
61- (BOOL)setUpOneSubentity:(NSDictionary*)subentDict;
62- (BOOL)setUpOneFlasher:(NSDictionary*)subentDict;
63- (BOOL)setUpOneStandardSubentity:(NSDictionary*)subentDict;
74- (id)initWithKey:(NSString*)key definition:(NSDictionary*)dict
78 NSParameterAssert(dict !=
nil);
86 if (![
self setUpVisualEffectFromDictionary:dict]) {
98- (BOOL)setUpVisualEffectFromDictionary:(NSDictionary*)effectDict
111 NSString* modelName = [
effectDict oo_stringForKey:@"model"];
112 if (modelName !=
nil) {
214 [subEntities makeObjectsPerformSelector:@selector(setOwner:) withObject:nil];
215 [subEntities release];
231 NSArray* subs = [effectinfoDictionary oo_arrayForKey:@"subentities"];
233 for (i = 0; i < [
subs count]; i++) {
242- (void)removeSubEntity:(
Entity<OOSubEntity>*)sub
245 [subEntities removeObject:sub];
254- (BOOL)setUpOneSubentity:(NSDictionary*)subentDict
256 NSString* type = [
subentDict oo_stringForKey:@"type"];
257 if ([type isEqualToString:
@"flasher"]) {
264- (BOOL)setUpOneFlasher:(NSDictionary*)subentDict
272- (BOOL)setUpOneStandardSubentity:(NSDictionary*)subentDict
275 NSString* subentKey =
nil;
279 subentKey = [
subentDict oo_stringForKey:@"subentity_key"];
280 if (subentKey ==
nil) {
281 OOLog(
@"setup.visualeffect.badEntry.subentities",
@"Failed to set up entity - no subentKey in %@", subentDict);
285 subentity = [UNIVERSE newVisualEffectWithName:subentKey];
286 if (subentity ==
nil) {
287 OOLog(
@"setup.visualeffect.badEntry.subentities",
@"Failed to set up entity %@", subentKey);
291 subPosition = [
subentDict oo_hpvectorForKey:@"position"];
292 subOrientation = [
subentDict oo_quaternionForKey:@"orientation"];
304- (void)addSubEntity:(
Entity<OOSubEntity>*)sub
309 if (subEntities ==
nil)
324 return [[subEntities copy] autorelease];
329 return [subEntities count];
334 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isVisualEffect)];
337- (BOOL)hasSubEntity:(
Entity<OOSubEntity>*)sub
339 return [subEntities containsObject:sub];
349 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isVisualEffect)];
354 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isFlasher)];
357- (void)drawSubEntityImmediate:(
bool)immediate translucent:(
bool)translucent
359 if (cam_zero_distance > no_draw_distance)
372- (void)rescaleBy:(GLfloat)factor
382 [
se rescaleBy:factor];
389- (void)rescaleBy:(GLfloat)factor writeToCache:(BOOL)writeToCache
417- (void)setScaleX:(GLfloat)factor
421 GLfloat flasher_factor = pow(factor /
scaleX, 1.0 / 3.0);
429 [
se rescaleBy:flasher_factor];
442- (void)setScaleY:(GLfloat)factor
446 GLfloat flasher_factor = pow(factor /
scaleY, 1.0 / 3.0);
454 [
se rescaleBy:flasher_factor];
467- (void)setScaleZ:(GLfloat)factor
471 GLfloat flasher_factor = pow(factor /
scaleZ, 1.0 / 3.0);
479 [
se rescaleBy:flasher_factor];
529- (void)setScannerDisplayColor1:(
OOColor*)color
538- (void)setScannerDisplayColor2:(
OOColor*)color
550- (GLfloat*)scannerDisplayColorForShip:(BOOL)flash scannerDisplayColor1:(
OOColor*)scannerDisplayColor1 scannerDisplayColor2:(
OOColor*)scannerDisplayColor2
575- (void)drawImmediate:(
bool)immediate translucent:(
bool)translucent
618- (void)setIsBreakPattern:(BOOL)bp
630- (void)setScript:(NSString*)script_name
632 NSMutableDictionary* properties =
nil;
635 [
properties setObject:
self forKey:@"visualEffect"];
667 [UNIVERSE removeEntity:(Entity*)
self];
672- (NSComparisonResult)compareBeaconCodeWith:(
Entity<OOBeaconEntity>*)other
674 return [[
self beaconCode] compare:[
other beaconCode] options:NSCaseInsensitiveSearch];
682- (void)setBeaconCode:(NSString*)bcode
684 if ([bcode length] == 0)
688 [_beaconCode release];
704- (void)setBeaconLabel:(NSString*)blabel
706 if ([blabel length] == 0)
710 [_beaconLabel release];
724 NSUInteger length = [beaconCode length];
727 NSArray* iconData = [[UNIVERSE descriptions] oo_arrayForKey:beaconCode];
753- (void)setPrevBeacon:(
Entity<OOBeaconEntity>*)beaconShip
761- (void)setNextBeacon:(
Entity<OOBeaconEntity>*)beaconShip
782- (void)setHullHeatLevel:(GLfloat)value
792- (void)setShaderFloat1:(GLfloat)value
802- (void)setShaderFloat2:(GLfloat)value
812- (void)setShaderInt1:(
int)value
822- (void)setShaderInt2:(
int)value
849@implementation OOVisualEffectEntity (SubEntityRelationship)
852- (BOOL)isShipWithSubEntityShip:(
Entity*)other
854 assert([
self isVisualEffect]);
856 if (![other isVisualEffect])
858 if (![other isSubEntity])
860 if ([other owner] !=
self)
866 OOLogERR(
@"visualeffect.subentity.sanityCheck.failed",
@"%@ thinks it's a subentity of %@, but the supposed parent does not agree. %@", [other shortDescription], [
self shortDescription],
@"This is an internal error, please report it.");
#define NO_DRAW_DISTANCE_FACTOR
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
OOINLINE Vector HPVectorToVector(HPVector v) INLINE_CONST_FUNC
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
#define OOLogERR(class, format,...)
#define OOLog(class, format,...)
const OOMatrix kIdentityMatrix
void OOGLScaleModelView(Vector scale)
void OOGLPushModelView(void)
void OOGLTranslateModelView(Vector vector)
void OOGLMultModelView(OOMatrix matrix)
OOMatrix OOGLPopModelView(void)
Vector vector_forward_from_quaternion(Quaternion quat) CONST_FUNC
const Quaternion kIdentityQuaternion
Vector vector_up_from_quaternion(Quaternion quat) CONST_FUNC
Vector vector_right_from_quaternion(Quaternion quat) CONST_FUNC
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
OOINLINE OOScalar distance(Vector v1, Vector v2) INLINE_CONST_FUNC
static GLfloat scripted_color[4]
static GLfloat default_color[4]
unsigned isImmuneToBreakPatternHide
void setOrientation:(Quaternion quat)
void update:(OOTimeDelta delta_t)
void setOwner:(Entity *ent)
void orientationChanged()
void drawSubEntityImmediate:translucent:(bool immediate, [translucent] bool translucent)
GLfloat cam_zero_distance
void setStatus:(OOEntityStatus stat)
void setPosition:(HPVector posn)
OOColor * colorWithDescription:(id description)
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
double findCollisionRadius()
void setDrawable:(OODrawable *drawable)
void drawImmediate:translucent:(bool immediate, [translucent] bool translucent)
instancetype flasherWithDictionary:(NSDictionary *dictionary)
BOOL callMethod:inContext:withArguments:count:result:(jsid methodID,[inContext] JSContext *context,[withArguments] jsval *argv,[count] intN argc,[result] jsval *outResult)
OOMesh * meshRescaledBy:(GLfloat scaleFactor)
instancetype meshWithName:cacheKey:materialDictionary:shadersDictionary:smooth:shaderMacros:shaderBindingTarget:(NSString *name,[cacheKey] NSString *cacheKey,[materialDictionary] NSDictionary *materialDict,[shadersDictionary] NSDictionary *shadersDict,[smooth] BOOL smooth,[shaderMacros] NSDictionary *macros,[shaderBindingTarget] id< OOWeakReferenceSupport > object)
id jsScriptFromFileNamed:properties:(NSString *fileName,[properties] NSDictionary *properties)
void drawImmediate:translucent:(bool immediate, [translucent] bool translucent)
void setMesh:(OOMesh *mesh)
OOColor * scannerDisplayColor2()
id< OOHUDBeaconIcon > _beaconDrawable
void setScaleZ:(GLfloat factor)
id initWithKey:definition:(NSString *key,[definition] NSDictionary *dict)
OOWeakReference * _prevBeacon
GLfloat collisionRadius()
BOOL setUpOneStandardSubentity:(NSDictionary *subentDict)
BOOL setUpOneSubentity:(NSDictionary *subentDict)
OOColor * scanner_display_color1
NSEnumerator * flasherEnumerator()
Entity< OOBeaconEntity > * prevBeacon()
Entity< OOBeaconEntity > * nextBeacon()
void setScannerDisplayColor1:(OOColor *color)
OOColor * scannerDisplayColor1()
OOColor * scanner_display_color2
void setScannerDisplayColor2:(OOColor *color)
NSUInteger subEntityCount()
void setScaleY:(GLfloat factor)
void doScriptEvent:(OOJSPropID message)
BOOL setUpOneFlasher:(NSDictionary *subentDict)
void setScaleX:(GLfloat factor)
NSDictionary * effectInfoDictionary()
NSDictionary * effectinfoDictionary
NSEnumerator * visualEffectSubEntityEnumerator()
void setBeaconLabel:(NSString *blabel)
id< OOHUDBeaconIcon > beaconDrawable()
NSEnumerator * subEntityEnumerator()
BOOL _haveExecutedSpawnAction
void setScript:(NSString *script_name)
NSDictionary * scriptInfo
void addSubEntity:(Entity< OOSubEntity > *sub)
NSEnumerator * effectSubEntityEnumerator()
void orientationChanged()
NSMutableArray * subEntities
OOWeakReference * _nextBeacon
void setBeaconCode:(NSString *bcode)
id weakRefUnderlyingObject()
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque