Oolite
Loading...
Searching...
No Matches
OOFlasherEntity Class Reference

#include <OOFlasherEntity.h>

Inheritance diagram for OOFlasherEntity:
Collaboration diagram for OOFlasherEntity:

Instance Methods

(id) - initWithDictionary:
(BOOL) - isActive
(void) - setActive:
(OOColor *) - color
(float) - frequency
(void) - setFrequency:
(float) - phase
(void) - setPhase:
(float) - fraction
(void) - setFraction:
(void) - dealloc [implementation]
(void) - setUpColors: [implementation]
(void) - getCurrentColorComponents [implementation]
(void) - update: [implementation]
(void) - drawImmediate:translucent: [implementation]
(void) - drawSubEntityImmediate:translucent: [implementation]
(BOOL) - isFlasher [implementation]
(double) - findCollisionRadius [implementation]
(void) - rescaleBy: [implementation]
(void) - rescaleBy:writeToCache: [implementation]
(void) - getJSClass:andPrototype:
(NSString *) - oo_jsClassName
(NSString *) - oo_jsClassName
(BOOL) - isVisibleToScripts
(BOOL) - isVisibleToScripts
(JSClassID) - oo_jsClassID
Instance Methods inherited from OOLightParticleEntity
(id) - initWithDiameter:
(float) - diameter
(void) - setDiameter:
(void) - setColor:
(void) - setColor:alpha:
(OOTexture *) - texture
(BOOL) - isEffect [implementation]
(BOOL) - canCollide [implementation]
Instance Methods inherited from Entity
(NSUInteger) - sessionID
(BOOL) - isShip
(BOOL) - isDock
(BOOL) - isStation
(BOOL) - isSubEntity
(BOOL) - isPlayer
(BOOL) - isPlanet
(BOOL) - isSun
(BOOL) - isSunlit
(BOOL) - isStellarObject
(BOOL) - isSky
(BOOL) - isWormhole
(BOOL) - isVisualEffect
(BOOL) - isWaypoint
(BOOL) - validForAddToUniverse
(void) - addToLinkedLists
(void) - removeFromLinkedLists
(void) - updateLinkedLists
(void) - wasAddedToUniverse
(void) - wasRemovedFromUniverse
(void) - warnAboutHostiles
(CollisionRegion *) - collisionRegion
(void) - setCollisionRegion:
(void) - setUniversalID:
(OOUniversalID) - universalID
(BOOL) - throwingSparks
(void) - setThrowSparks:
(void) - throwSparks
(void) - setOwner:
(id) - owner
(ShipEntity *) - parentEntity
(ShipEntity *) - rootShipEntity
(void) - setPosition:
(void) - setPositionX:y:z:
(HPVector) - position
(Vector) - cameraRelativePosition
(GLfloat) - cameraRangeFront
(GLfloat) - cameraRangeBack
(void) - updateCameraRelativePosition
(Vector) - vectorTo:
(HPVector) - absolutePositionForSubentity
(HPVector) - absolutePositionForSubentityOffset:
(double) - zeroDistance
(double) - camZeroDistance
(NSComparisonResult) - compareZeroDistance:
(BoundingBox) - boundingBox
(GLfloat) - mass
(Quaternion) - orientation
(void) - setOrientation:
(Quaternion) - normalOrientation
(void) - setNormalOrientation:
(void) - orientationChanged
(void) - setVelocity:
(Vector) - velocity
(double) - speed
(GLfloat) - distanceTravelled
(void) - setDistanceTravelled:
(void) - setStatus:
(OOEntityStatus) - status
(void) - setScanClass:
(OOScanClass) - scanClass
(void) - setEnergy:
(GLfloat) - energy
(void) - setMaxEnergy:
(GLfloat) - maxEnergy
(void) - applyRoll:andClimb:
(void) - applyRoll:climb:andYaw:
(void) - moveForward:
(OOMatrix) - rotationMatrix
(OOMatrix) - drawRotationMatrix
(OOMatrix) - transformationMatrix
(OOMatrix) - drawTransformationMatrix
(GLfloat) - collisionRadius
(GLfloat) - frustumRadius
(void) - setCollisionRadius:
(NSMutableArray *) - collisionArray
(void) - applyVelocity:
(BOOL) - checkCloseCollisionWith:
(void) - takeEnergyDamage:from:becauseOf:weaponIdentifier:
(void) - dumpState
(void) - dumpSelfState
(NSUInteger) - lastDrawCounter
(void) - setLastDrawCounter:
(BOOL) - isVisible
(BOOL) - isInSpace
(BOOL) - isImmuneToBreakPatternHide
(GLfloat) - universalTime
(GLfloat) - spawnTime
(GLfloat) - timeElapsedSinceSpawn
(void) - setAtmosphereFogging:
(OOColor *) - fogUniform
(id) - init [implementation]
(NSString *) - descriptionComponents [implementation]
(BOOL) - checkLinkedLists [implementation]
(id< OOWeakReferenceSupport >) - superShaderBindingTarget [implementation]
(Vector) - relativePosition [implementation]
(void) - subEntityReallyDied: [implementation]
(BOOL) - isBreakPattern
(BOOL) - isECMBlast
(BOOL) - isExhaust
(void) - deleteJSSelf
(void) - deleteJSSelf
(jsval) - oo_jsValueInContext: [implementation]
(BOOL) - isCascadeWeapon
(BOOL) - isPlayerLikeShip
(GLfloat) - clock [implementation]
(unsigned) - pseudoFixedD100 [implementation]
(unsigned) - pseudoFixedD256 [implementation]
(unsigned) - systemGovernment [implementation]
(unsigned) - systemEconomy [implementation]
(unsigned) - systemTechLevel [implementation]
(unsigned) - systemPopulation [implementation]
(unsigned) - systemProductivity [implementation]
(BOOL) - isShipWithSubEntityShip:
Instance Methods inherited from OOWeakRefObject
(id) - weakSelf
(id) - weakRetain [implementation]
(void) - weakRefDied: [implementation]
Instance Methods inherited from <OOWeakReferenceSupport>
(id) - OO_RETURNS_RETAINED

Class Methods

(instancetype) + flasherWithDictionary:
Class Methods inherited from OOLightParticleEntity
(void) + setUpTexture
(OOTexture *) + defaultParticleTexture
(void) + resetGraphicsState [implementation]

Private Attributes

float _frequency
float _phase
float _wave
float _brightfraction
NSArray * _colors
NSUInteger _activeColor
OOTimeDelta _time
BOOL _active
BOOL _justSwitched

Additional Inherited Members

Public Attributes inherited from Entity
OOUniversalID universalID
unsigned isShip: 1
unsigned isStation: 1
unsigned isPlayer: 1
unsigned isWormhole: 1
unsigned isSubEntity: 1
unsigned hasMoved: 1
unsigned hasRotated: 1
unsigned hasCollided: 1
unsigned isSunlit: 1
unsigned collisionTestFilter: 2
unsigned throw_sparks: 1
unsigned isImmuneToBreakPatternHide: 1
unsigned isExplicitlyNotMainStation: 1
unsigned isVisualEffect: 1
OOScanClass scanClass
GLfloat zero_distance
GLfloat cam_zero_distance
GLfloat no_draw_distance
GLfloat collision_radius
HPVector position
Vector cameraRelativePosition
Quaternion orientation
OOColor * atmosphereFogging
int zero_index
Entity * x_previous
Entity * x_next
Entity * y_previous
Entity * y_next
Entity * z_previous
Entity * z_next
Entity * collision_chain
OOUniversalID shadingEntityID
Entity * collider
CollisionRegion * collisionRegion
Protected Attributes inherited from OOLightParticleEntity
GLfloat _colorComponents [4]
float _diameter
Protected Attributes inherited from Entity
HPVector lastPosition
Quaternion lastOrientation
GLfloat distanceTravelled
OOMatrix rotMatrix
Vector velocity
GLfloat energy
GLfloat maxEnergy
BoundingBox boundingBox
GLfloat mass
NSMutableArray * collidingEntities
OOTimeAbsolute spawnTime
struct JSObject * _jsSelf
NSUInteger lastDrawCounter
Protected Attributes inherited from OOWeakRefObject
OOWeakReference * weakSelf

Detailed Description

Definition at line 31 of file OOFlasherEntity.h.

Method Documentation

◆ color

- (OOColor *) color

Definition at line 97 of file OOFlasherEntity.m.

98{
99 return [OOColor colorWithRed:_colorComponents[0]
100 green:_colorComponents[1]
101 blue:_colorComponents[2]
102 alpha:_colorComponents[3]];
103}
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:107

References color, and OOColor::colorWithRed:green:blue:alpha:.

Referenced by color, FlasherGetProperty(), and FlasherGetProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Reimplemented from Entity.

Definition at line 64 of file OOFlasherEntity.m.

65{
66 [_colors release];
67
68 [super dealloc];
69}

References Entity::dealloc, and dealloc.

Referenced by dealloc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawImmediate:translucent:

- (void) drawImmediate: (bool) immediate
translucent: (bool) translucent 
implementation

Reimplemented from OOLightParticleEntity.

Definition at line 173 of file OOFlasherEntity.m.

173 :(bool)immediate translucent:(bool)translucent
174{
175 if (_active) {
176 [super drawImmediate:immediate translucent:translucent];
177 }
178}

References _active, and OOLightParticleEntity::drawImmediate:translucent:.

Here is the call graph for this function:

◆ drawSubEntityImmediate:translucent:

- (void) drawSubEntityImmediate: (bool) immediate
translucent: (bool) translucent 
implementation

Reimplemented from OOLightParticleEntity.

Definition at line 180 of file OOFlasherEntity.m.

180 :(bool)immediate translucent:(bool)translucent
181{
182 if (_active) {
183 [super drawSubEntityImmediate:immediate translucent:translucent];
184 }
185}

References _active, and OOLightParticleEntity::drawSubEntityImmediate:translucent:.

Here is the call graph for this function:

◆ findCollisionRadius

- (double) findCollisionRadius
implementation

Reimplemented from Entity.

Definition at line 192 of file OOFlasherEntity.m.

193{
194 return [self diameter] / 2.0;
195}

References OOLightParticleEntity::diameter, and findCollisionRadius.

Referenced by findCollisionRadius.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flasherWithDictionary:

+ (instancetype) flasherWithDictionary: (NSDictionary*) dictionary

Definition at line 42 of file OOFlasherEntity.m.

42 :(NSDictionary*)dictionary
43{
44 return [[[OOFlasherEntity alloc] initWithDictionary:dictionary] autorelease];
45}

Referenced by OOVisualEffectEntity(Private)::setUpOneFlasher:, and ShipEntity(Private)::setUpOneFlasher:.

Here is the caller graph for this function:

◆ fraction

- (float) fraction

Definition at line 125 of file OOFlasherEntity.m.

126{
127 return _brightfraction;
128}

References _brightfraction, and fraction.

Referenced by fraction, and setFraction:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ frequency

- (float) frequency

Definition at line 105 of file OOFlasherEntity.m.

106{
107 return _frequency;
108}

References _frequency, and frequency.

Referenced by frequency, and setFrequency:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCurrentColorComponents

- (void) getCurrentColorComponents
implementation

Provided by category OOFlasherEntity(Internal).

Definition at line 82 of file OOFlasherEntity.m.

83{
84 [self setColor:[_colors objectAtIndex:_activeColor] alpha:_colorComponents[3]];
85}

References OOFlasherEntity(Internal)::getCurrentColorComponents, and OOLightParticleEntity::setColor:alpha:.

Referenced by OOFlasherEntity(Internal)::getCurrentColorComponents, and initWithDictionary:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getJSClass:andPrototype:

- (void) getJSClass: (JSClass**) outClass
andPrototype: (JSObject**) outPrototype 

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

Definition at line 118 of file OOJSFlasher.m.

118 :(JSClass**)outClass andPrototype:(JSObject**)outPrototype
119{
120 *outClass = &sFlasherClass;
121 *outPrototype = sFlasherPrototype;
122}
static JSObject * sFlasherPrototype
Definition OOJSFlasher.m:33
static JSClass sFlasherClass
Definition OOJSFlasher.m:42

◆ initWithDictionary:

- (id) initWithDictionary: (NSDictionary*) dictionary

Definition at line 47 of file OOFlasherEntity.m.

47 :(NSDictionary*)dictionary
48{
49 float size = [dictionary oo_floatForKey:@"size" defaultValue:1.0f];
50
51 if ((self = [super initWithDiameter:size])) {
52 _frequency = [dictionary oo_floatForKey:@"frequency" defaultValue:1.0f] * 2.0f;
53 _phase = [dictionary oo_floatForKey:@"phase" defaultValue:0.0f];
54 _brightfraction = [dictionary oo_floatForKey:@"bright_fraction" defaultValue:0.5f];
55
56 [self setUpColors:[dictionary oo_arrayForKey:@"colors"]];
57 [self getCurrentColorComponents];
58
59 [self setActive:[dictionary oo_boolForKey:@"initially_on" defaultValue:YES]];
60 }
61 return self;
62}
voidpf void uLong size
Definition ioapi.h:126

References _brightfraction, _frequency, _phase, getCurrentColorComponents, setActive:, and setUpColors:.

Here is the call graph for this function:

◆ isActive

- (BOOL) isActive

Definition at line 87 of file OOFlasherEntity.m.

88{
89 return _active;
90}

References _active, and isActive.

Referenced by isActive.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFlasher

- (BOOL) isFlasher
implementation

Reimplemented from Entity.

Definition at line 187 of file OOFlasherEntity.m.

188{
189 return YES;
190}

References isFlasher.

Referenced by isFlasher.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isVisibleToScripts [1/2]

- (BOOL) isVisibleToScripts

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

Definition at line 127 of file OOJSFlasher.m.

128{
129 return YES;
130}

◆ isVisibleToScripts [2/2]

- (BOOL) isVisibleToScripts

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

◆ oo_jsClassID

- (JSClassID) oo_jsClassID

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

Definition at line 117 of file OOJSFlasher.m.

118{
119 return sFlasherClassID;
120}
static JSClassID sFlasherClassID
Definition OOJSFlasher.m:33

◆ oo_jsClassName [1/2]

- (NSString *) oo_jsClassName

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

Definition at line 122 of file OOJSFlasher.m.

123{
124 return @"Flasher";
125}

◆ oo_jsClassName [2/2]

- (NSString *) oo_jsClassName

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

◆ phase

- (float) phase

Definition at line 115 of file OOFlasherEntity.m.

116{
117 return _phase;
118}

References _phase, and phase.

Referenced by phase, and setPhase:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rescaleBy:

- (void) rescaleBy: (GLfloat) factor
implementation

Reimplemented from <OOSubEntity>.

Definition at line 197 of file OOFlasherEntity.m.

197 :(GLfloat)factor
198{
199 [self setDiameter:[self diameter] * factor];
200}

References OOLightParticleEntity::diameter, and OOLightParticleEntity::setDiameter:.

Referenced by ShipEntity(Private)::setUpOneFlasher:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rescaleBy:writeToCache:

- (void) rescaleBy: (GLfloat) factor
writeToCache: (BOOL) writeToCache 
implementation

Reimplemented from <OOSubEntity>.

Definition at line 202 of file OOFlasherEntity.m.

202 :(GLfloat)factor writeToCache:(BOOL)writeToCache
203{
204 /* Do nothing; this is only needed because of OOEntityWithDrawable
205 implementation requirements */
206}

◆ setActive:

- (void) setActive: (BOOL) active

Definition at line 92 of file OOFlasherEntity.m.

92 :(BOOL)active
93{
94 _active = !!active;
95}

References _active.

Referenced by FlasherSetProperty(), FlasherSetProperty(), and initWithDictionary:.

Here is the caller graph for this function:

◆ setFraction:

- (void) setFraction: (float) fraction

Definition at line 130 of file OOFlasherEntity.m.

130 :(float)fraction
131{
133}

References _brightfraction, and fraction.

Referenced by FlasherSetProperty(), and FlasherSetProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFrequency:

- (void) setFrequency: (float) frequency

Definition at line 110 of file OOFlasherEntity.m.

110 :(float)frequency
111{
113}

References _frequency, and frequency.

Referenced by FlasherSetProperty(), and FlasherSetProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPhase:

- (void) setPhase: (float) phase

Definition at line 120 of file OOFlasherEntity.m.

120 :(float)phase
121{
122 _phase = phase;
123}

References _phase, and phase.

Referenced by FlasherSetProperty(), and FlasherSetProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUpColors:

- (void) setUpColors: (NSArray*) colorSpecifiers
implementation

Provided by category OOFlasherEntity(Internal).

Definition at line 71 of file OOFlasherEntity.m.

71 :(NSArray*)colorSpecifiers
72{
73 NSMutableArray* colors = [NSMutableArray arrayWithCapacity:[colorSpecifiers count]];
74 id specifier = nil;
75 foreach (specifier, colorSpecifiers) {
76 [colors addObject:[OOColor colorWithDescription:specifier saturationFactor:0.75f]];
77 }
78
79 _colors = [colors copy];
80}
return nil
OOColor * colorWithDescription:saturationFactor:(id description,[saturationFactor] float factor)
Definition OOColor.m:140

References OOColor::colorWithDescription:saturationFactor:, and nil.

Referenced by initWithDictionary:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update:

- (void) update: (OOTimeDelta) delta_t
implementation

Reimplemented from Entity.

Definition at line 135 of file OOFlasherEntity.m.

135 :(OOTimeDelta)delta_t
136{
137 [super update:delta_t];
138
139 _time += delta_t;
140
141 if (_frequency != 0) {
142 float wave = sinf(_frequency * M_PI * (_time + _phase));
143 NSUInteger count = [_colors count];
144 if (count > 1 && wave < 0) {
145 if (!_justSwitched && wave > _wave) // don't test for wave >= _wave - could give wrong results with very low frequencies
146 {
147 _justSwitched = YES;
148 ++_activeColor;
149 _activeColor %= count; //_activeColor = ++_activeColor % count; is potentially undefined operation
150 [self setColor:[_colors objectAtIndex:_activeColor]];
151 }
152 } else if (_justSwitched) {
153 _justSwitched = NO;
154 }
155
156 float threshold = cosf(_brightfraction * M_PI);
157
158 float brightness = _brightfraction;
159 if (wave > threshold) {
160 brightness = _brightfraction + (((1 - _brightfraction) / (1 - threshold)) * (wave - threshold));
161 } else if (wave < threshold) {
162 brightness = _brightfraction + ((_brightfraction / (threshold + 1)) * (wave - threshold));
163 }
164
165 _colorComponents[3] = brightness;
166
167 _wave = wave;
168 } else {
169 _colorComponents[3] = 1.0;
170 }
171}
#define M_PI
Definition OOMaths.h:54
unsigned count
double OOTimeDelta
Definition OOTypes.h:193
NSUInteger _activeColor
OOTimeDelta _time

References _activeColor, _brightfraction, OOLightParticleEntity::_colorComponents, _frequency, _justSwitched, _phase, _time, _wave, count, M_PI, OOLightParticleEntity::setColor:, and Entity::update:.

Here is the call graph for this function:

Member Data Documentation

◆ _active

- (BOOL) _active
private

◆ _activeColor

- (NSUInteger) _activeColor
private

Definition at line 38 of file OOFlasherEntity.h.

Referenced by update:.

◆ _brightfraction

- (float) _brightfraction
private

Definition at line 36 of file OOFlasherEntity.h.

Referenced by fraction, initWithDictionary:, setFraction:, and update:.

◆ _colors

- (NSArray*) _colors
private

Definition at line 37 of file OOFlasherEntity.h.

◆ _frequency

- (float) _frequency
private

Definition at line 33 of file OOFlasherEntity.h.

Referenced by frequency, initWithDictionary:, setFrequency:, and update:.

◆ _justSwitched

- (BOOL) _justSwitched
private

Definition at line 43 of file OOFlasherEntity.h.

Referenced by update:.

◆ _phase

- (float) _phase
private

Definition at line 34 of file OOFlasherEntity.h.

Referenced by initWithDictionary:, phase, setPhase:, and update:.

◆ _time

- (OOTimeDelta) _time
private

Definition at line 40 of file OOFlasherEntity.h.

Referenced by update:.

◆ _wave

- (float) _wave
private

Definition at line 35 of file OOFlasherEntity.h.

Referenced by update:.


The documentation for this class was generated from the following files: