Oolite 1.91.0.7644-241112-7f5034b
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
 
(BOOL) - isVisibleToScripts
 
- Instance Methods inherited from OOLightParticleEntity
(id) - initWithDiameter:
 
(float) - diameter
 
(void) - setDiameter:
 
(void) - setColor:
 
(void) - setColor:alpha:
 
(OOTexture *) - texture
 
(BOOL) - isEffect [implementation]
 
(BOOL) - canCollide [implementation]
 
(NSSet *) - allTextures [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
 
(BOOL) - isVisible
 
(BOOL) - isInSpace
 
(BOOL) - isImmuneToBreakPatternHide
 
(GLfloat) - universalTime
 
(GLfloat) - spawnTime
 
(GLfloat) - timeElapsedSinceSpawn
 
(void) - setAtmosphereFogging:
 
(OOColor *) - fogUniform
 
(NSString *) - descriptionForObjDumpBasic
 
(NSString *) - descriptionForObjDump
 
(id) - init [implementation]
 
(NSString *) - descriptionComponents [implementation]
 
(BOOL) - checkLinkedLists [implementation]
 
(id< OOWeakReferenceSupport >) - superShaderBindingTarget [implementation]
 
(Vector) - relativePosition [implementation]
 
(void) - subEntityReallyDied: [implementation]
 
(BOOL) - isBreakPattern
 
(void) - inspect [implementation]
 
(BOOL) - isECMBlast
 
(NSArray *) - debugInspectorModules [implementation]
 
(NSString *) - inspScanClassLine
 
(NSString *) - inspStatusLine
 
(NSString *) - inspRetainCountLine
 
(NSString *) - inspPositionLine
 
(NSString *) - inspVelocityLine
 
(NSString *) - inspOrientationLine
 
(NSString *) - inspEnergyLine
 
(NSString *) - inspOwnerLine
 
(NSString *) - inspTargetLine
 
(NSString *) - inspDescription [implementation]
 
(NSString *) - inspBasicIdentityLine [implementation]
 
(BOOL) - isExhaust
 
(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
 
- Instance Methods inherited from <OOSubEntity>

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
 
OOColoratmosphereFogging
 
int zero_index
 
Entityx_previous
 
Entityx_next
 
Entityy_previous
 
Entityy_next
 
Entityz_previous
 
Entityz_next
 
Entitycollision_chain
 
OOUniversalID shadingEntityID
 
Entitycollider
 
CollisionRegioncollisionRegion
 
- 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
 
- Protected Attributes inherited from OOWeakRefObject
OOWeakReferenceweakSelf
 

Detailed Description

Definition at line 32 of file OOFlasherEntity.h.

Method Documentation

◆ color

- (OOColor *) color

Definition at line 1 of file OOFlasherEntity.m.

110{
111 return [OOColor colorWithRed:_colorComponents[0]
112 green:_colorComponents[1]
113 blue:_colorComponents[2]
114 alpha:_colorComponents[3]];
115}
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:95

Referenced by FlasherGetProperty().

+ Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Reimplemented from Entity.

Definition at line 1 of file OOFlasherEntity.m.

70{
71 [_colors release];
72
73 [super dealloc];
74}

◆ drawImmediate:translucent:

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

Reimplemented from OOLightParticleEntity.

Definition at line 1 of file OOFlasherEntity.m.

202 :(bool)immediate translucent:(bool)translucent
203{
204 if (_active)
205 {
206 [super drawImmediate:immediate translucent:translucent];
207 }
208}

◆ drawSubEntityImmediate:translucent:

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

Reimplemented from OOLightParticleEntity.

Definition at line 1 of file OOFlasherEntity.m.

211 :(bool)immediate translucent:(bool)translucent
212{
213 if (_active)
214 {
215 [super drawSubEntityImmediate:immediate translucent:translucent];
216 }
217}

◆ findCollisionRadius

- (double) findCollisionRadius
implementation

Reimplemented from Entity.

Definition at line 1 of file OOFlasherEntity.m.

227{
228 return [self diameter] / 2.0;
229}

◆ flasherWithDictionary:

+ (instancetype) flasherWithDictionary: (NSDictionary *) dictionary

Definition at line 1 of file OOFlasherEntity.m.

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

◆ fraction

- (float) fraction

Definition at line 1 of file OOFlasherEntity.m.

143{
144 return _brightfraction;
145}

◆ frequency

- (float) frequency

Definition at line 1 of file OOFlasherEntity.m.

119{
120 return _frequency;
121}

◆ getCurrentColorComponents

- (void) getCurrentColorComponents
implementation

Provided by category OOFlasherEntity(Internal).

Definition at line 1 of file OOFlasherEntity.m.

92{
93 [self setColor:[_colors objectAtIndex:_activeColor] alpha:_colorComponents[3]];
94}

◆ getJSClass:andPrototype:

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

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

Definition at line 288 of file OOJSFlasher.m.

128 :(JSClass **)outClass andPrototype:(JSObject **)outPrototype
129{
130 *outClass = &sFlasherClass;
131 *outPrototype = sFlasherPrototype;
132}
static JSObject * sFlasherPrototype
Definition OOJSFlasher.m:34
static JSClass sFlasherClass
Definition OOJSFlasher.m:45

◆ initWithDictionary:

- (id) initWithDictionary: (NSDictionary *) dictionary

Definition at line 1 of file OOFlasherEntity.m.

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

◆ isActive

- (BOOL) isActive

Definition at line 1 of file OOFlasherEntity.m.

98{
99 return _active;
100}

◆ isFlasher

- (BOOL) isFlasher
implementation

Reimplemented from Entity.

Definition at line 1 of file OOFlasherEntity.m.

221{
222 return YES;
223}

◆ isVisibleToScripts

- (BOOL) isVisibleToScripts

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

Definition at line 288 of file OOJSFlasher.m.

141{
142 return YES;
143}

◆ oo_jsClassName

- (NSString *) oo_jsClassName

Reimplemented from Entity.

Provided by category OOFlasherEntity(OOJavaScriptExtensions).

Definition at line 288 of file OOJSFlasher.m.

136{
137 return @"Flasher";
138}

◆ phase

- (float) phase

Definition at line 1 of file OOFlasherEntity.m.

131{
132 return _phase;
133}

◆ rescaleBy:

- (void) rescaleBy: (GLfloat) factor
implementation

Reimplemented from <OOSubEntity>.

Definition at line 1 of file OOFlasherEntity.m.

232 :(GLfloat)factor
233{
234 [self setDiameter:[self diameter] * factor];
235}

◆ rescaleBy:writeToCache:

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

Reimplemented from <OOSubEntity>.

Definition at line 1 of file OOFlasherEntity.m.

238 :(GLfloat)factor writeToCache:(BOOL)writeToCache
239{
240 /* Do nothing; this is only needed because of OOEntityWithDrawable
241 implementation requirements */
242}

◆ setActive:

- (void) setActive: (BOOL) active

Definition at line 1 of file OOFlasherEntity.m.

103 :(BOOL)active
104{
105 _active = !!active;
106}

Referenced by FlasherSetProperty().

+ Here is the caller graph for this function:

◆ setFraction:

- (void) setFraction: (float) fraction

Definition at line 1 of file OOFlasherEntity.m.

148 :(float)fraction
149{
151}

Referenced by FlasherSetProperty().

+ Here is the caller graph for this function:

◆ setFrequency:

- (void) setFrequency: (float) frequency

Definition at line 1 of file OOFlasherEntity.m.

124 :(float)frequency
125{
127}

Referenced by FlasherSetProperty().

+ Here is the caller graph for this function:

◆ setPhase:

- (void) setPhase: (float) phase

Definition at line 1 of file OOFlasherEntity.m.

136 :(float)phase
137{
138 _phase = phase;
139}

Referenced by FlasherSetProperty().

+ Here is the caller graph for this function:

◆ setUpColors:

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

Provided by category OOFlasherEntity(Internal).

Definition at line 1 of file OOFlasherEntity.m.

77 :(NSArray *)colorSpecifiers
78{
79 NSMutableArray *colors = [NSMutableArray arrayWithCapacity:[colorSpecifiers count]];
80 id specifier = nil;
81 NSEnumerator *specEnum = [colorSpecifiers objectEnumerator];
82 while ((specifier = [specEnum nextObject]))
83 {
84 [colors addObject:[OOColor colorWithDescription:specifier saturationFactor:0.75f]];
85 }
86
87 _colors = [colors copy];
88}
return nil
OOColor * colorWithDescription:saturationFactor:(id description,[saturationFactor] float factor)
Definition OOColor.m:133

◆ update:

- (void) update: (OOTimeDelta) delta_t
implementation

Reimplemented from Entity.

Definition at line 1 of file OOFlasherEntity.m.

154 :(OOTimeDelta) delta_t
155{
156 [super update:delta_t];
157
158 _time += delta_t;
159
160 if (_frequency != 0)
161 {
162 float wave = sinf(_frequency * M_PI * (_time + _phase));
163 NSUInteger count = [_colors count];
164 if (count > 1 && wave < 0)
165 {
166 if (!_justSwitched && wave > _wave) // don't test for wave >= _wave - could give wrong results with very low frequencies
167 {
168 _justSwitched = YES;
169 ++_activeColor;
170 _activeColor %= count; //_activeColor = ++_activeColor % count; is potentially undefined operation
171 [self setColor:[_colors objectAtIndex:_activeColor]];
172 }
173 }
174 else if (_justSwitched)
175 {
176 _justSwitched = NO;
177 }
178
179 float threshold = cosf(_brightfraction * M_PI);
180
181 float brightness = _brightfraction;
182 if (wave > threshold)
183 {
184 brightness = _brightfraction + (((1-_brightfraction)/(1-threshold))*(wave-threshold));
185 }
186 else if (wave < threshold)
187 {
188 brightness = _brightfraction + ((_brightfraction/(threshold+1))*(wave-threshold));
189 }
190
191 _colorComponents[3] = brightness;
192
193 _wave = wave;
194 }
195 else
196 {
197 _colorComponents[3] = 1.0;
198 }
199}
#define M_PI
Definition OOMaths.h:73
unsigned count
double OOTimeDelta
Definition OOTypes.h:224
NSUInteger _activeColor
OOTimeDelta _time

Member Data Documentation

◆ _active

- (BOOL) _active
private

Definition at line 45 of file OOFlasherEntity.h.

◆ _activeColor

- (NSUInteger) _activeColor
private

Definition at line 41 of file OOFlasherEntity.h.

◆ _brightfraction

- (float) _brightfraction
private

Definition at line 39 of file OOFlasherEntity.h.

◆ _colors

- (NSArray*) _colors
private

Definition at line 40 of file OOFlasherEntity.h.

◆ _frequency

- (float) _frequency
private

Definition at line 36 of file OOFlasherEntity.h.

◆ _justSwitched

- (BOOL) _justSwitched
private

Definition at line 46 of file OOFlasherEntity.h.

◆ _phase

- (float) _phase
private

Definition at line 37 of file OOFlasherEntity.h.

◆ _time

- (OOTimeDelta) _time
private

Definition at line 43 of file OOFlasherEntity.h.

◆ _wave

- (float) _wave
private

Definition at line 38 of file OOFlasherEntity.h.


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