54#import "MyOpenGLView.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;
75- (id)initWithKey:(NSString *)key definition:(NSDictionary *)dict
79 NSParameterAssert(dict !=
nil);
82 if (
self ==
nil)
return nil;
86 if (![
self setUpVisualEffectFromDictionary:dict])
100- (BOOL) setUpVisualEffectFromDictionary:(NSDictionary *) effectDict
112 NSString *modelName = [
effectDict oo_stringForKey:@"model"];
113 if (modelName !=
nil)
225 [subEntities makeObjectsPerformSelector:@selector(setOwner:) withObject:nil];
226 [subEntities release];
246 NSArray *subs = [effectinfoDictionary oo_arrayForKey:@"subentities"];
248 for (i = 0; i < [
subs count]; i++)
259- (void) removeSubEntity:(
Entity<OOSubEntity> *)sub
262 [subEntities removeObject:sub];
274- (BOOL) setUpOneSubentity:(NSDictionary *) subentDict
276 NSString *type = [
subentDict oo_stringForKey:@"type"];
277 if ([type isEqualToString:
@"flasher"])
290- (BOOL) setUpOneFlasher:(NSDictionary *) subentDict
299- (BOOL) setUpOneStandardSubentity:(NSDictionary *)subentDict
302 NSString *subentKey =
nil;
303 HPVector subPosition;
304 Quaternion subOrientation;
306 subentKey = [
subentDict oo_stringForKey:@"subentity_key"];
307 if (subentKey ==
nil) {
308 OOLog(
@"setup.visualeffect.badEntry.subentities",
@"Failed to set up entity - no subentKey in %@",subentDict);
312 subentity = [UNIVERSE newVisualEffectWithName:subentKey];
313 if (subentity ==
nil) {
314 OOLog(
@"setup.visualeffect.badEntry.subentities",
@"Failed to set up entity %@",subentKey);
318 subPosition = [
subentDict oo_hpvectorForKey:@"position"];
319 subOrientation = [
subentDict oo_quaternionForKey:@"orientation"];
332- (void) addSubEntity:(
Entity<OOSubEntity> *)sub
334 if (sub ==
nil)
return;
342 double distance = HPmagnitude([sub position]) + [
sub findCollisionRadius];
343 if (distance > _profileRadius)
345 _profileRadius = distance;
352 return [[subEntities copy] autorelease];
358 return [subEntities count];
364 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isVisualEffect)];
368- (BOOL) hasSubEntity:(
Entity<OOSubEntity> *)sub
370 return [subEntities containsObject:sub];
382 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isVisualEffect)];
388 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isFlasher)];
392- (void) drawSubEntityImmediate:(
bool)immediate translucent:(
bool)translucent
394 if (cam_zero_distance > no_draw_distance)
408- (void) rescaleBy:(GLfloat)factor
419 [
se rescaleBy:factor];
427- (void) rescaleBy:(GLfloat)factor writeToCache:(BOOL)writeToCache
465- (void) setScaleX:(GLfloat)factor
469 GLfloat flasher_factor = pow(factor/
scaleX,1.0/3.0);
481 [
se rescaleBy:flasher_factor];
496- (void) setScaleY:(GLfloat)factor
500 GLfloat flasher_factor = pow(factor/
scaleY,1.0/3.0);
512 [
se rescaleBy:flasher_factor];
527- (void) setScaleZ:(GLfloat)factor
531 GLfloat flasher_factor = pow(factor/
scaleZ,1.0/3.0);
543 [
se rescaleBy:flasher_factor];
601- (void)setScannerDisplayColor1:(
OOColor *)color
610- (void)setScannerDisplayColor2:(
OOColor *)color
621- (GLfloat *) scannerDisplayColorForShip:(BOOL)flash :(
OOColor *)scannerDisplayColor1 :(
OOColor *)scannerDisplayColor2
650- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
700- (void) setIsBreakPattern:(BOOL)bp
714- (void) setScript:(NSString *)script_name
716 NSMutableDictionary *properties =
nil;
719 [
properties setObject:
self forKey:@"visualEffect"];
743- (void) doScriptEvent:(jsid)message
754 [UNIVERSE removeEntity:(Entity*)
self];
760- (NSComparisonResult) compareBeaconCodeWith:(
Entity<OOBeaconEntity> *) other
762 return [[
self beaconCode] compare:[
other beaconCode] options: NSCaseInsensitiveSearch];
772- (void) setBeaconCode:(NSString *)bcode
774 if ([bcode length] == 0) bcode =
nil;
778 [_beaconCode release];
798- (void) setBeaconLabel:(NSString *)blabel
800 if ([blabel length] == 0) blabel =
nil;
804 [_beaconLabel release];
821 NSUInteger length = [beaconCode length];
825 NSArray *iconData = [[UNIVERSE descriptions] oo_arrayForKey:beaconCode];
831 if (length > 0)
_beaconDrawable = [[beaconCode substringToIndex:1] retain];
852- (void) setPrevBeacon:(
Entity <OOBeaconEntity> *)beaconShip
862- (void) setNextBeacon:(
Entity <OOBeaconEntity> *)beaconShip
887- (void)setHullHeatLevel:(GLfloat)value
899- (void)setShaderFloat1:(GLfloat)value
911- (void)setShaderFloat2:(GLfloat)value
923- (void)setShaderInt1:(
int)value
935- (void)setShaderInt2:(
int)value
947- (void)setShaderVector1:(Vector)value
959- (void)setShaderVector2:(Vector)value
967@implementation OOVisualEffectEntity (SubEntityRelationship)
970- (BOOL) isShipWithSubEntityShip:(
Entity *)other
972 assert ([
self isVisualEffect]);
974 if (![other isVisualEffect])
return NO;
975 if (![other isSubEntity])
return NO;
976 if ([other owner] !=
self)
return NO;
982 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
#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_up_from_quaternion(Quaternion quat)
Vector vector_right_from_quaternion(Quaternion quat)
Vector vector_forward_from_quaternion(Quaternion quat)
const Quaternion kIdentityQuaternion
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
void doScriptEvent:(jsid message)
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)
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