Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
Universe.h
Go to the documentation of this file.
1/*
2
3Universe.h
4
5Manages a lot of stuff that isn't managed somewhere else.
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import "OOCocoa.h"
28#import "OOOpenGL.h"
29#import "OOShaderProgram.h"
30#import "legacy_random.h"
31#import "OOMaths.h"
32#import "OOColor.h"
33#import "OOWeakReference.h"
34#import "OOTypes.h"
35#import "OOSound.h"
36#import "OOJSPropID.h"
37#import "OOStellarBody.h"
39#import "OOCommodities.h"
41
42#if OOLITE_ESPEAK
43#include <espeak/speak_lib.h>
44#endif
45
47 Entity, ShipEntity, StationEntity, OOPlanetEntity, OOSunEntity,
50
51
52typedef BOOL (*EntityFilterPredicate)(Entity *entity, void *parameter);
53
54#ifndef OO_SCANCLASS_TYPE
55#define OO_SCANCLASS_TYPE
56typedef enum OOScanClass OOScanClass;
57#endif
58
59
60#define CROSSHAIR_SIZE 32.0
61
62enum
63{
73 MARKET_UNITS = 9
74};
75
76
77enum
78{
85};
86
87
88enum
89{
99 OO_POSTFX_ENDOFLIST // keep this for last
101
102
103#define SHADERS_MIN SHADERS_OFF
104
105
106#define MAX_MESSAGES 5
107
108#define PROXIMITY_WARN_DISTANCE 4 // Eric 2010-10-17: old value was 20.0
109#define PROXIMITY_WARN_DISTANCE2 (PROXIMITY_WARN_DISTANCE * PROXIMITY_WARN_DISTANCE)
110#define PROXIMITY_AVOID_DISTANCE_FACTOR 10.0
111#define SAFE_ADDITION_FACTOR2 800 // Eric 2010-10-17: used to be "2 * PROXIMITY_WARN_DISTANCE2"
112
113#define SUN_SKIM_RADIUS_FACTOR 1.15470053838 // 2 sqrt(3) / 3. Why? I have no idea. -- Ahruman 2009-10-04
114#define SUN_SPARKS_RADIUS_FACTOR 2.0
115
116#define KEY_TECHLEVEL @"techlevel"
117#define KEY_ECONOMY @"economy"
118#define KEY_ECONOMY_DESC @"economy_description"
119#define KEY_GOVERNMENT @"government"
120#define KEY_GOVERNMENT_DESC @"government_description"
121#define KEY_POPULATION @"population"
122#define KEY_POPULATION_DESC @"population_description"
123#define KEY_PRODUCTIVITY @"productivity"
124#define KEY_RADIUS @"radius"
125#define KEY_NAME @"name"
126#define KEY_INHABITANT @"inhabitant"
127#define KEY_INHABITANTS @"inhabitants"
128#define KEY_DESCRIPTION @"description"
129#define KEY_SHORT_DESCRIPTION @"short_description"
130#define KEY_PLANETNAME @"planet_name"
131#define KEY_SUNNAME @"sun_name"
132
133#define KEY_CHANCE @"chance"
134#define KEY_PRICE @"price"
135#define KEY_OPTIONAL_EQUIPMENT @"optional_equipment"
136#define KEY_STANDARD_EQUIPMENT @"standard_equipment"
137#define KEY_EQUIPMENT_MISSILES @"missiles"
138#define KEY_EQUIPMENT_FORWARD_WEAPON @"forward_weapon_type"
139#define KEY_EQUIPMENT_AFT_WEAPON @"aft_weapon_type"
140#define KEY_EQUIPMENT_PORT_WEAPON @"port_weapon_type"
141#define KEY_EQUIPMENT_STARBOARD_WEAPON @"starboard_weapon_type"
142#define KEY_EQUIPMENT_EXTRAS @"extras"
143#define KEY_WEAPON_FACINGS @"weapon_facings"
144#define KEY_RENOVATION_MULTIPLIER @"renovation_multiplier"
145
146#define SHIPYARD_KEY_ID @"id"
147#define SHIPYARD_KEY_SHIPDATA_KEY @"shipdata_key"
148#define SHIPYARD_KEY_SHIP @"ship"
149#define SHIPYARD_KEY_PRICE @"price"
150#define SHIPYARD_KEY_PERSONALITY @"personality"
151// default passenger berth required space
152#define PASSENGER_BERTH_SPACE 5
153
154#define PLANETINFO_UNIVERSAL_KEY @"universal"
155#define PLANETINFO_INTERSTELLAR_KEY @"interstellar space"
156
157#define OOLITE_EXCEPTION_LOOPING @"OoliteLoopingException"
158#define OOLITE_EXCEPTION_DATA_NOT_FOUND @"OoliteDataNotFoundException"
159#define OOLITE_EXCEPTION_FATAL @"OoliteFatalException"
160
161// the distance the sky backdrop is from the camera
162// though it appears at infinity
163#define BILLBOARD_DEPTH 75000.0
164
165#define TIME_ACCELERATION_FACTOR_MIN 0.0625f
166#define TIME_ACCELERATION_FACTOR_DEFAULT 1.0f
167#define TIME_ACCELERATION_FACTOR_MAX 16.0f
168
169#define DEMO_LIGHT_POSITION 5000.0f, 25000.0f, -10000.0f
170
171#define MIN_DISTANCE_TO_BUOY 750.0f // don't add ships within this distance
172#define MIN_DISTANCE_TO_BUOY2 (MIN_DISTANCE_TO_BUOY * MIN_DISTANCE_TO_BUOY)
173
174// if this is changed, also change oolite-populator.js
175// once this number has been in a stable release, cannot easily be changed
176#define SYSTEM_REPOPULATION_INTERVAL 20.0f;
177
178#ifndef OO_LOCALIZATION_TOOLS
179#define OO_LOCALIZATION_TOOLS 1
180#endif
181
182#ifndef MASS_DEPENDENT_FUEL_PRICES
183#define MASS_DEPENDENT_FUEL_PRICES 1
184#endif
185
186
188{
189@public
190 // use a sorted list for drawing and other activities
191 Entity *sortedEntities[UNIVERSE_MAX_ENTITIES + 1]; // One extra for padding; see -doRemoveEntity:.
192 unsigned n_entities;
193
195
196 // collision optimisation sorted lists
198
199 GLfloat stars_ambient[4];
200
201@private
202 NSUInteger _sessionID;
203
204 // colors
205 GLfloat sun_diffuse[4];
206 GLfloat sun_specular[4];
207
209
210 OOMatrix viewMatrix;
211
213
215
217 Entity *entity_for_uid[MAX_ENTITY_UID];
218
219 NSMutableArray *entities;
220
223 NSMutableDictionary *waypoints;
224
225 GLfloat skyClearColor[4];
226
227 NSString *currentMessage;
229 OOTimeAbsolute countdown_messageRepeatTime; // Getafix(4/Aug/2010) - Quickfix countdown messages colliding with weapon overheat messages.
230 // For proper handling of message dispatching, code refactoring is needed.
234
237
242// Above entry replaces these two
243// BOOL reducedDetail;
244// OOShaderSetting shaderEffectsLevel;
245
247
250
255 NSUInteger demo_ship_index;
257 NSArray *demo_ships;
258
260
262
265
266
267 NSDictionary *_descriptions; // holds descriptive text for lots of stuff, loaded at initialisation
268 NSDictionary *customSounds; // holds descriptive audio for lots of stuff, loaded at initialisation
269 NSDictionary *characters; // holds descriptons of characters
270 NSArray *_scenarios; // game start scenarios
271 NSDictionary *globalSettings; // miscellaneous global game settings
272 OOSystemDescriptionManager *systemManager; // planetinfo data manager
273 NSDictionary *missiontext; // holds descriptive text for missions, loaded at initialisation
274 NSArray *equipmentData; // holds data on available equipment, loaded at initialisation
276// NSSet *pirateVictimRoles; // Roles listed in pirateVictimRoles.plist.
277 NSDictionary *roleCategories; // Categories for roles from role-categories.plist, extending the old pirate-victim-roles.plist
278 NSDictionary *autoAIMap; // Default AIs for roles from autoAImap.plist.
279 NSDictionary *screenBackgrounds; // holds filenames for various screens backgrounds, loaded at initialisation
280 NSDictionary *explosionSettings; // explosion settings from explosions.plist
281
282 NSDictionary *cargoPods; // template cargo pods
283
287
288 NSString *system_names[256]; // hold pregenerated universe info
289 BOOL system_found[256]; // holds matches for input strings
290
292
294
296 OOPlanetEntity *cachedPlanet;
298 NSMutableArray *allPlanets;
299 NSMutableSet *allStations;
300
302
303 NSMutableDictionary *populatorSettings;
307
308 NSArray *closeSystems;
309
310 NSString *useAddOns;
311
313
314#ifndef NDEBUG
316#endif
317
319
320 NSMutableArray *activeWormholes;
321
322 NSMutableArray *characterPool;
323
325
326 // check and maintain linked lists occasionally
328
331
332#if OOLITE_SPEECH_SYNTH
333#if OOLITE_MAC_OS_X
334 NSSpeechSynthesizer *speechSynthesizer;
335#elif OOLITE_ESPEAK
336 const espeak_VOICE **espeak_voices;
337 unsigned int espeak_voice_count;
338#endif
339 NSArray *speechArray;
340#endif
341
342#if NEW_PLANETS
343 NSMutableArray *_preloadingPlanetMaterials;
344#endif
346
347 GLfloat frustum[6][4];
348
349 NSMutableDictionary *conditionScripts;
350
359
369 OOShaderProgram *textureProgram;
370 OOShaderProgram *blurProgram;
371 OOShaderProgram *finalProgram;
374 GLuint pingpongFBO[2];
376 BOOL _bloom;
379}
380
381- (BOOL) bloom;
382- (void) setBloom: (BOOL)newBloom;
383
384- (int) currentPostFX;
385- (void) setCurrentPostFX: (int) newCurrentPostFX;
386- (void) terminatePostFX:(int) postFX;
387
388- (id)initWithGameView:(MyOpenGLView *)gameView;
389
390// SessionID: a value that's incremented when the game is reset.
391- (NSUInteger) sessionID;
392
393- (BOOL) doProcedurallyTexturedPlanets;
394- (void) setDoProcedurallyTexturedPlanets:(BOOL) value;
395
396- (NSString *) useAddOns;
397- (BOOL) setUseAddOns:(NSString *)newUse fromSaveGame: (BOOL)saveGame;
398- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame forceReinit:(BOOL)force;
399
400- (void) setUpSettings;
401
402- (BOOL) reinitAndShowDemo:(BOOL)showDemo;
403
404- (BOOL) doingStartUp; // True during initial game startup (not reset).
405
406- (NSUInteger) entityCount;
407#ifndef NDEBUG
408- (void) debugDumpEntities;
409- (NSArray *) entityList;
410#endif
411
412- (void) pauseGame;
413
414- (void) carryPlayerOn:(StationEntity*)carrier inWormhole:(WormholeEntity*)wormhole;
415- (void) setUpUniverseFromStation;
416- (void) setUpUniverseFromWitchspace;
417- (void) setUpUniverseFromMisjump;
418- (void) setUpWitchspace;
419- (void) setUpWitchspaceBetweenSystem:(OOSystemID)s1 andSystem:(OOSystemID)s2;
420- (void) setUpSpace;
421- (void) populateNormalSpace;
422- (void) clearSystemPopulator;
423- (BOOL) deterministicPopulation;
424- (void) populateSystemFromDictionariesWithSun:(OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet;
425- (NSDictionary *) getPopulatorSettings;
426- (void) setPopulatorSetting:(NSString *)key to:(NSDictionary *)setting;
427- (HPVector) locationByCode:(NSString *)code withSun:(OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet;
428- (void) setAmbientLightLevel:(float)newValue;
429- (float) ambientLightLevel;
430- (void) setLighting;
431- (void) forceLightSwitch;
432- (void) setMainLightPosition: (Vector) sunPos;
433- (OOPlanetEntity *) setUpPlanet;
434
435- (void) makeSunSkimmer:(ShipEntity *) ship andSetAI:(BOOL)setAI;
436- (void) addShipWithRole:(NSString *) desc nearRouteOneAt:(double) route_fraction;
437- (HPVector) coordinatesForPosition:(HPVector) pos withCoordinateSystem:(NSString *) system returningScalar:(GLfloat*) my_scalar;
438- (NSString *) expressPosition:(HPVector) pos inCoordinateSystem:(NSString *) system;
439- (HPVector) legacyPositionFrom:(HPVector) pos asCoordinateSystem:(NSString *) system;
440- (HPVector) coordinatesFromCoordinateSystemString:(NSString *) system_x_y_z;
441- (BOOL) addShipWithRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system;
442- (BOOL) addShips:(int) howMany withRole:(NSString *) desc atPosition:(HPVector) pos withCoordinateSystem:(NSString *) system;
443- (BOOL) addShips:(int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system;
444- (BOOL) addShips:(int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system withinRadius:(GLfloat) radius;
445- (BOOL) addShips:(int) howMany withRole:(NSString *) desc intoBoundingBox:(BoundingBox) bbox;
446- (BOOL) spawnShip:(NSString *) shipdesc;
447- (void) witchspaceShipWithPrimaryRole:(NSString *)role;
448- (ShipEntity *) spawnShipWithRole:(NSString *) desc near:(Entity *) entity;
449
450- (OOVisualEffectEntity *) addVisualEffectAt:(HPVector)pos withKey:(NSString *)key;
451- (ShipEntity *) addShipAt:(HPVector)pos withRole:(NSString *)role withinRadius:(GLfloat)radius;
452- (NSArray *) addShipsAt:(HPVector)pos withRole:(NSString *)role quantity:(unsigned)count withinRadius:(GLfloat)radius asGroup:(BOOL)isGroup;
453- (NSArray *) addShipsToRoute:(NSString *)route withRole:(NSString *)role quantity:(unsigned)count routeFraction:(double)routeFraction asGroup:(BOOL)isGroup;
454
455- (BOOL) roleIsPirateVictim:(NSString *)role;
456- (BOOL) role:(NSString *)role isInCategory:(NSString *)category;
457
458- (void) forceWitchspaceEntries;
459- (void) addWitchspaceJumpEffectForShip:(ShipEntity *)ship;
460- (GLfloat) safeWitchspaceExitDistance;
461
462- (void) setUpBreakPattern:(HPVector)pos orientation:(Quaternion)q forDocking:(BOOL)forDocking;
463- (BOOL) witchspaceBreakPattern;
464- (void) setWitchspaceBreakPattern:(BOOL)newValue;
465
466- (BOOL) dockingClearanceProtocolActive;
467- (void) setDockingClearanceProtocolActive:(BOOL)newValue;
468
469- (void) handleGameOver;
470
471- (void) setupIntroFirstGo:(BOOL)justCobra;
472- (void) selectIntro2Previous;
473- (void) selectIntro2Next;
474- (void) selectIntro2PreviousCategory;
475- (void) selectIntro2NextCategory;
476
477- (StationEntity *) station;
478- (OOPlanetEntity *) planet;
479- (OOSunEntity *) sun;
480- (NSArray *) planets; // Note: does not include sun.
481- (NSArray *) stations; // includes main station
482- (NSArray *) wormholes;
483- (StationEntity *) stationWithRole:(NSString *)role andPosition:(HPVector)position;
484
485// Turn main station into just another station, for blowUpStation.
486- (void) unMagicMainStation;
487// find a valid station in interstellar space
488- (StationEntity *) stationFriendlyTo:(ShipEntity *) ship;
489
490- (void) resetBeacons;
491- (Entity <OOBeaconEntity> *) firstBeacon;
492- (Entity <OOBeaconEntity> *) lastBeacon;
493- (void) setNextBeacon:(Entity <OOBeaconEntity> *) beaconShip;
494- (void) clearBeacon:(Entity <OOBeaconEntity> *) beaconShip;
495
496- (NSDictionary *) currentWaypoints;
497- (void) defineWaypoint:(NSDictionary *)definition forKey:(NSString *)key;
498
499- (GLfloat *) skyClearColor;
500// Note: the alpha value is also air resistance!
501- (void) setSkyColorRed:(GLfloat)red green:(GLfloat)green blue:(GLfloat)blue alpha:(GLfloat)alpha;
502
503- (BOOL) breakPatternOver;
504- (BOOL) breakPatternHide;
505
506- (NSString *) randomShipKeyForRoleRespectingConditions:(NSString *)role;
507- (ShipEntity *) newShipWithRole:(NSString *)role OO_RETURNS_RETAINED; // Selects ship using role weights, applies auto_ai, respects conditions
508- (ShipEntity *) newShipWithName:(NSString *)shipKey OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
509- (ShipEntity *) newSubentityWithName:(NSString *)shipKey andScaleFactor:(float)scale OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
510- (OOVisualEffectEntity *) newVisualEffectWithName:(NSString *)effectKey OO_RETURNS_RETAINED;
511- (DockEntity *) newDockWithName:(NSString *)shipKey andScaleFactor:(float)scale OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
512- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy OO_RETURNS_RETAINED; // If usePlayerProxy, non-carriers are instantiated as ProxyPlayerEntity.
513- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity OO_RETURNS_RETAINED;
514- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity andScaleFactor:(float)scale OO_RETURNS_RETAINED;
515
516- (Class) shipClassForShipDictionary:(NSDictionary *)dict;
517
518- (NSString *)defaultAIForRole:(NSString *)role; // autoAImap.plist lookup
519
520- (OOCargoQuantity) maxCargoForShip:(NSString *) desc;
521
522- (OOCreditsQuantity) getEquipmentPriceForKey:(NSString *) eq_key;
523
524- (OOCommodities *) commodities;
525
526- (ShipEntity *) reifyCargoPod:(ShipEntity *)cargoObj;
527- (ShipEntity *) cargoPodFromTemplate:(ShipEntity *)cargoObj;
528- (NSArray *) getContainersOfGoods:(OOCargoQuantity)how_many scarce:(BOOL)scarce legal:(BOOL)legal;
529- (NSArray *) getContainersOfCommodity:(OOCommodityType) commodity_name :(OOCargoQuantity) how_many;
530- (void) fillCargopodWithRandomCargo:(ShipEntity *)cargopod;
531
532- (NSString *) getRandomCommodity;
533- (OOCargoQuantity) getRandomAmountOfCommodity:(OOCommodityType) co_type;
534
535- (NSDictionary *) commodityDataForType:(OOCommodityType)type;
536- (NSString *) displayNameForCommodity:(OOCommodityType)co_type;
537- (NSString *) describeCommodity:(OOCommodityType)co_type amount:(OOCargoQuantity) co_amount;
538
539- (void) setGameView:(MyOpenGLView *)view;
540- (MyOpenGLView *) gameView;
541- (GameController *) gameController;
542- (NSDictionary *) gameSettings;
543
544- (void) useGUILightSource:(BOOL)GUILight;
545
546- (void) drawUniverse;
547
548- (void) defineFrustum;
549- (BOOL) viewFrustumIntersectsSphereAt:(Vector)position withRadius:(GLfloat)radius;
550
551- (void) drawMessage;
552
553- (void) drawWatermarkString:(NSString *)watermarkString;
554
555// Used to draw subentities. Should be getting this from camera.
556- (OOMatrix) viewMatrix;
557
558- (id) entityForUniversalID:(OOUniversalID)u_id;
559
560- (BOOL) addEntity:(Entity *) entity;
561- (BOOL) removeEntity:(Entity *) entity;
562- (void) ensureEntityReallyRemoved:(Entity *)entity;
563- (void) removeAllEntitiesExceptPlayer;
564- (void) removeDemoShips;
565
566- (ShipEntity *) makeDemoShipWithRole:(NSString *)role spinning:(BOOL)spinning;
567
568- (BOOL) isVectorClearFromEntity:(Entity *) e1 toDistance:(double)dist fromPoint:(HPVector) p2;
569- (Entity*) hazardOnRouteFromEntity:(Entity *) e1 toDistance:(double)dist fromPoint:(HPVector) p2;
570- (HPVector) getSafeVectorFromEntity:(Entity *) e1 toDistance:(double)dist fromPoint:(HPVector) p2;
571
572- (ShipEntity *) addWreckageFrom:(ShipEntity *)ship withRole:(NSString *)wreckRole at:(HPVector)rpos scale:(GLfloat)scale lifetime:(GLfloat)lifetime;
573- (void) addLaserHitEffectsAt:(HPVector)pos against:(ShipEntity *)target damage:(float)damage color:(OOColor *)color;
574- (ShipEntity *) firstShipHitByLaserFromShip:(ShipEntity *)srcEntity inDirection:(OOWeaponFacing)direction offset:(Vector)offset gettingRangeFound:(GLfloat*)range_ptr;
575- (Entity *) firstEntityTargetedByPlayer;
576- (Entity *) firstEntityTargetedByPlayerPrecisely;
577
578- (NSArray *) entitiesWithinRange:(double)range ofEntity:(Entity *)entity;
579- (unsigned) countShipsWithRole:(NSString *)role inRange:(double)range ofEntity:(Entity *)entity;
580- (unsigned) countShipsWithRole:(NSString *)role;
581- (unsigned) countShipsWithPrimaryRole:(NSString *)role inRange:(double)range ofEntity:(Entity *)entity;
582- (unsigned) countShipsWithPrimaryRole:(NSString *)role;
583- (unsigned) countShipsWithScanClass:(OOScanClass)scanClass inRange:(double)range ofEntity:(Entity *)entity;
584
585
586// General count/search methods. Pass range of -1 and entity of nil to search all of system.
587- (unsigned) countEntitiesMatchingPredicate:(EntityFilterPredicate)predicate
588 parameter:(void *)parameter
589 inRange:(double)range
590 ofEntity:(Entity *)entity;
591- (unsigned) countShipsMatchingPredicate:(EntityFilterPredicate)predicate
592 parameter:(void *)parameter
593 inRange:(double)range
594 ofEntity:(Entity *)entity;
595- (NSMutableArray *) findEntitiesMatchingPredicate:(EntityFilterPredicate)predicate
596 parameter:(void *)parameter
597 inRange:(double)range
598 ofEntity:(Entity *)entity;
599- (id) findOneEntityMatchingPredicate:(EntityFilterPredicate)predicate
600 parameter:(void *)parameter;
601- (NSMutableArray *) findShipsMatchingPredicate:(EntityFilterPredicate)predicate
602 parameter:(void *)parameter
603 inRange:(double)range
604 ofEntity:(Entity *)entity;
605- (NSMutableArray *) findVisualEffectsMatchingPredicate:(EntityFilterPredicate)predicate
606 parameter:(void *)parameter
607 inRange:(double)range
608 ofEntity:(Entity *)entity;
609- (id) nearestEntityMatchingPredicate:(EntityFilterPredicate)predicate
610 parameter:(void *)parameter
611 relativeToEntity:(Entity *)entity;
612- (id) nearestShipMatchingPredicate:(EntityFilterPredicate)predicate
613 parameter:(void *)parameter
614 relativeToEntity:(Entity *)entity;
615
616
617- (OOTimeAbsolute) getTime;
618- (OOTimeDelta) getTimeDelta;
619
620- (void) findCollisionsAndShadows;
621- (NSString*) collisionDescription;
622- (void) dumpCollisions;
623
624- (OOViewID) viewDirection;
625- (void) setViewDirection:(OOViewID)vd;
626- (void) enterGUIViewModeWithMouseInteraction:(BOOL)mouseInteraction; // Use instead of setViewDirection:VIEW_GUI_DISPLAY
627
628- (NSString *) soundNameForCustomSoundKey:(NSString *)key;
629- (NSDictionary *) screenTextureDescriptorForKey:(NSString *)key;
630- (void) setScreenTextureDescriptorForKey:(NSString *) key descriptor:(NSDictionary *)desc;
631
632- (void) clearPreviousMessage;
633- (void) setMessageGuiBackgroundColor:(OOColor *) some_color;
634- (void) displayMessage:(NSString *) text forCount:(OOTimeDelta) count;
635- (void) displayCountdownMessage:(NSString *) text forCount:(OOTimeDelta) count;
636- (void) addDelayedMessage:(NSString *) text forCount:(OOTimeDelta) count afterDelay:(OOTimeDelta) delay;
637- (void) addDelayedMessage:(NSDictionary *) textdict;
638- (void) addMessage:(NSString *) text forCount:(OOTimeDelta) count;
639- (void) addMessage:(NSString *) text forCount:(OOTimeDelta) count forceDisplay:(BOOL) forceDisplay;
640- (void) addCommsMessage:(NSString *) text forCount:(OOTimeDelta) count;
641- (void) addCommsMessage:(NSString *) text forCount:(OOTimeDelta) count andShowComms:(BOOL)showComms logOnly:(BOOL)logOnly;
642- (void) showCommsLog:(OOTimeDelta) how_long;
643- (void) showGUIMessage:(NSString *)text withScroll:(BOOL)scroll andColor:(OOColor *)selectedColor overDuration:(OOTimeDelta)how_long;
644
645- (void) update:(OOTimeDelta)delta_t;
646
647// Time Acelleration Factor. In deployment builds, this is always 1.0 and -setTimeAccelerationFactor: does nothing.
648- (double) timeAccelerationFactor;
649- (void) setTimeAccelerationFactor:(double)newTimeAccelerationFactor;
650
651- (BOOL) ECMVisualFXEnabled;
652- (void) setECMVisualFXEnabled:(BOOL)isEnabled;
653
654- (void) filterSortedLists;
655
657
658- (void) setGalaxyTo:(OOGalaxyID) g;
659- (void) setGalaxyTo:(OOGalaxyID) g andReinit:(BOOL) forced;
660
661- (void) setSystemTo:(OOSystemID) s;
662
663- (OOSystemID) currentSystemID;
664
665- (NSDictionary *) descriptions;
666- (NSDictionary *) characters;
667- (NSDictionary *) missiontext;
668- (NSArray *) scenarios;
669- (NSDictionary *) explosionSetting:(NSString *)explosion;
670
671- (OOSystemDescriptionManager *) systemManager;
672
673- (NSString *)descriptionForKey:(NSString *)key; // String, or random item from array
674- (NSString *)descriptionForArrayKey:(NSString *)key index:(unsigned)index; // Indexed item from array
675- (BOOL) descriptionBooleanForKey:(NSString *)key; // Boolean from descriptions.plist, for configuration.
676
677- (NSString *) keyForPlanetOverridesForSystem:(OOSystemID) s inGalaxy:(OOGalaxyID) g;
678- (NSString *) keyForInterstellarOverridesForSystems:(OOSystemID) s1 :(OOSystemID) s2 inGalaxy:(OOGalaxyID) g;
679- (NSDictionary *) generateSystemData:(OOSystemID) s;
680- (NSDictionary *) generateSystemData:(OOSystemID) s useCache:(BOOL) useCache;
681- (NSDictionary *) currentSystemData; // Same as generateSystemData:systemSeed unless in interstellar space.
682
683- (BOOL) inInterstellarSpace;
684
685- (void) setSystemDataKey:(NSString*) key value:(NSObject*) object fromManifest:(NSString *)manifest;
686- (void) setSystemDataForGalaxy:(OOGalaxyID) gnum planet:(OOSystemID) pnum key:(NSString *)key value:(id)object fromManifest:(NSString *)manifest forLayer:(OOSystemLayer)layer;
687- (id) systemDataForGalaxy:(OOGalaxyID) gnum planet:(OOSystemID) pnum key:(NSString *)key;
688- (NSArray *) systemDataKeysForGalaxy:(OOGalaxyID)gnum planet:(OOSystemID)pnum;
689- (NSString *) getSystemName:(OOSystemID) sys;
690- (NSString *) getSystemName:(OOSystemID) sys forGalaxy:(OOGalaxyID) gnum;
691- (OOGovernmentID) getSystemGovernment:(OOSystemID) sys;
692- (NSString *) getSystemInhabitants:(OOSystemID) sys;
693- (NSString *) getSystemInhabitants:(OOSystemID) sys plural:(BOOL)plural;
694
695- (NSPoint) coordinatesForSystem:(OOSystemID)s;
696- (OOSystemID) findSystemFromName:(NSString *) sysName;
697
701- (NSMutableArray *) nearbyDestinationsWithinRange:(double) range;
702
703- (OOSystemID) findNeighbouringSystemToCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal;
704- (OOSystemID) findConnectedSystemAtCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal;
705// old alias for findSystemNumberAtCoords
706- (OOSystemID) findSystemAtCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal;
707- (OOSystemID) findSystemNumberAtCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal includingHidden:(BOOL)hidden;
708- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix;
709- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix exactMatch:(BOOL) exactMatch;
710- (BOOL*) systemsFound;
711- (NSString*) systemNameIndex:(OOSystemID) index;
712- (NSDictionary *) routeFromSystem:(OOSystemID) start toSystem:(OOSystemID) goal optimizedBy:(OORouteType) optimizeBy;
713- (NSArray *) neighboursToSystem:(OOSystemID) system_number;
714
715- (void) preloadPlanetTexturesForSystem:(OOSystemID)system;
716- (void) preloadSounds;
717
718- (NSDictionary *) globalSettings;
719
720- (NSArray *) equipmentData;
721- (NSArray *) equipmentDataOutfitting;
722- (OOCommodityMarket *) commodityMarket;
723- (Random_Seed) marketSeed;
724
725- (NSString *) timeDescription:(OOTimeDelta) interval;
726- (NSString *) shortTimeDescription:(OOTimeDelta) interval;
727
728- (void) loadStationMarkets:(NSArray *)marketData;
729- (NSArray *) getStationMarkets;
730
731- (NSArray *) shipsForSaleForSystem:(OOSystemID) s withTL:(OOTechLevelID) specialTL atTime:(OOTimeAbsolute) current_time;
732
733/* Calculate base cost, before depreciation */
734- (OOCreditsQuantity) tradeInValueForCommanderDictionary:(NSDictionary*) cmdr_dict;
735
736- (NSString*) brochureDescriptionWithDictionary:(NSDictionary*) dict standardEquipment:(NSArray*) extras optionalEquipment:(NSArray*) options;
737
738- (HPVector) getWitchspaceExitPosition;
739- (Quaternion) getWitchspaceExitRotation;
740
741- (HPVector) getSunSkimStartPositionForShip:(ShipEntity*) ship;
742- (HPVector) getSunSkimEndPositionForShip:(ShipEntity*) ship;
743
744- (NSArray*) listBeaconsWithCode:(NSString*) code;
745
746- (void) allShipsDoScriptEvent:(jsid)event andReactToAIMessage:(NSString *)message;
747
749
750- (void) clearGUIs;
751
752- (GuiDisplayGen *) gui;
753- (GuiDisplayGen *) commLogGUI;
754- (GuiDisplayGen *) messageGUI;
755
756- (void) resetCommsLogColor;
757
758- (void) setDisplayText:(BOOL) value;
759- (BOOL) displayGUI;
760
761- (void) setDisplayFPS:(BOOL) value;
762- (BOOL) displayFPS;
763
764- (void) setAutoSave:(BOOL) value;
765- (BOOL) autoSave;
766
767- (void) setWireframeGraphics:(BOOL) value;
768- (BOOL) wireframeGraphics;
769
770- (BOOL) reducedDetail;
771- (void) setDetailLevel:(OOGraphicsDetail)value;
772- (OOGraphicsDetail) detailLevel;
773- (BOOL) useShaders;
774
775- (void) handleOoliteException:(NSException *)ooliteException;
776
777- (GLfloat)airResistanceFactor;
778- (void) setAirResistanceFactor:(GLfloat)newFactor;
779
780// speech routines
781//
782- (void) startSpeakingString:(NSString *) text;
783//
784- (void) stopSpeaking;
785//
786- (BOOL) isSpeaking;
787//
788#if OOLITE_ESPEAK
789- (NSString *) voiceName:(unsigned int) index;
790- (unsigned int) voiceNumber:(NSString *) name;
791- (unsigned int) nextVoice:(unsigned int) index;
792- (unsigned int) prevVoice:(unsigned int) index;
793- (unsigned int) setVoice:(unsigned int) index withGenderM:(BOOL) isMale;
794#endif
795- (int) nextColorblindMode:(int) index;
796- (int) prevColorblindMode:(int) index;
797- (int) colorblindMode;
798//
800
801//autosave
802- (void) setAutoSaveNow:(BOOL) value;
803- (BOOL) autoSaveNow;
804
805- (int) framesDoneThisUpdate;
806- (void) resetFramesDoneThisUpdate;
807
808// True if textual pause message (as opposed to overlay) is being shown.
809- (BOOL) pauseMessageVisible;
810- (void) setPauseMessageVisible:(BOOL)value;
811
812- (BOOL) permanentCommLog;
813- (void) setPermanentCommLog:(BOOL)value;
814- (void) setAutoCommLog:(BOOL)value;
815- (BOOL) permanentMessageLog;
816- (void) setPermanentMessageLog:(BOOL)value;
817- (BOOL) autoMessageLogBg;
818- (void) setAutoMessageLogBg:(BOOL)value;
819
820- (BOOL) blockJSPlayerShipProps;
821- (void) setBlockJSPlayerShipProps:(BOOL)value;
822
823- (void) loadConditionScripts;
824- (void) addConditionScripts:(NSEnumerator *)scripts;
825- (OOJSScript *) getConditionScript:(NSString *)scriptname;
826
827@end
828
829
830/* Use UNIVERSE to refer to the global universe object.
831 The purpose of this is that it makes UNIVERSE essentially a read-only
832 global with zero overhead.
833*/
836{
838 return gSharedUniverse;
839}
840#define UNIVERSE OOGetUniverse()
841
842
843// Only for use with string literals, and only for looking up strings.
844// DESC() is deprecated in favour of OOExpandKey() except in known performance-
845// critical contexts.
846#define DESC(key) (OOLookUpDescriptionPRIV(key ""))
847#define DESC_PLURAL(key,count) (OOLookUpPluralDescriptionPRIV(key "", count))
848
849// Not for direct use.
850NSComparisonResult populatorPrioritySort(id a, id b, void *context);
851NSComparisonResult equipmentSort(id a, id b, void *context);
852NSComparisonResult equipmentSortOutfitting(id a, id b, void *context);
853NSString *OOLookUpDescriptionPRIV(NSString *key);
854NSString *OOLookUpPluralDescriptionPRIV(NSString *key, NSInteger count);
855
856@interface OOSound (OOCustomSounds)
857
858+ (id) soundWithCustomSoundKey:(NSString *)key;
859- (id) initWithCustomSoundKey:(NSString *)key;
860
861@end
862
863
864@interface OOSoundSource (OOCustomSounds)
865
866+ (id) sourceWithCustomSoundKey:(NSString *)key;
867- (id) initWithCustomSoundKey:(NSString *)key;
868
869- (void) playCustomSoundWithKey:(NSString *)key;
870
871@end
872
873
OOScanClass
Definition Entity.h:71
NSString * OODisplayStringFromEconomyID(OOEconomyID economy)
NSString * OODisplayStringFromGovernmentID(OOGovernmentID government)
#define INLINE_CONST_FUNC
#define OOINLINE
unsigned count
NSString * OOCommodityType
Definition OOTypes.h:106
OORouteType
Definition OOTypes.h:33
OOGraphicsDetail
Definition OOTypes.h:243
OOViewID
Definition OOTypes.h:43
uint64_t OOCreditsQuantity
Definition OOTypes.h:182
uint16_t OOUniversalID
Definition OOTypes.h:189
NSUInteger OOTechLevelID
Definition OOTypes.h:204
int16_t OOSystemID
Definition OOTypes.h:211
uint8_t OOGalaxyID
Definition OOTypes.h:210
uint32_t OOCargoQuantity
Definition OOTypes.h:176
double OOTimeDelta
Definition OOTypes.h:224
uint8_t OOGovernmentID
Definition OOTypes.h:206
double OOTimeAbsolute
Definition OOTypes.h:223
OOWeaponFacing
Definition OOTypes.h:228
uint8_t OOEconomyID
Definition OOTypes.h:207
OOINLINE Universe * OOGetUniverse(void) INLINE_CONST_FUNC
Definition Universe.h:835
@ EQUIPMENT_SHORT_DESC_INDEX
Definition Universe.h:81
@ EQUIPMENT_LONG_DESC_INDEX
Definition Universe.h:83
@ EQUIPMENT_TECH_LEVEL_INDEX
Definition Universe.h:79
@ EQUIPMENT_KEY_INDEX
Definition Universe.h:82
@ EQUIPMENT_PRICE_INDEX
Definition Universe.h:80
@ EQUIPMENT_EXTRA_INFO_INDEX
Definition Universe.h:84
NSString * OOLookUpDescriptionPRIV(NSString *key)
Definition Universe.m:11168
@ OO_POSTFX_COLORBLINDNESS_PROTAN
Definition Universe.h:91
@ OO_POSTFX_ENDOFLIST
Definition Universe.h:99
@ OO_POSTFX_COLORBLINDNESS_TRITAN
Definition Universe.h:93
@ OO_POSTFX_CRT
Definition Universe.h:97
@ OO_POSTFX_COLORBLINDNESS_DEUTER
Definition Universe.h:92
@ OO_POSTFX_GRAYSCALE
Definition Universe.h:95
@ OO_POSTFX_OLDMOVIE
Definition Universe.h:96
@ OO_POSTFX_NONE
Definition Universe.h:90
@ OO_POSTFX_CRTBADSIGNAL
Definition Universe.h:98
@ OO_POSTFX_CLOAK
Definition Universe.h:94
NSString * OOLookUpPluralDescriptionPRIV(NSString *key, NSInteger count)
Definition Universe.m:11177
NSComparisonResult populatorPrioritySort(id a, id b, void *context)
Definition Universe.m:11104
NSComparisonResult equipmentSortOutfitting(id a, id b, void *context)
Definition Universe.m:11142
NSComparisonResult equipmentSort(id a, id b, void *context)
Definition Universe.m:11116
@ MARKET_QUANTITY
Definition Universe.h:65
@ MARKET_ECO_ADJUST_QUANTITY
Definition Universe.h:69
@ MARKET_MASK_PRICE
Definition Universe.h:71
@ MARKET_ECO_ADJUST_PRICE
Definition Universe.h:68
@ MARKET_NAME
Definition Universe.h:64
@ MARKET_UNITS
Definition Universe.h:73
@ MARKET_BASE_PRICE
Definition Universe.h:67
@ MARKET_BASE_QUANTITY
Definition Universe.h:70
@ MARKET_PRICE
Definition Universe.h:66
@ MARKET_MASK_QUANTITY
Definition Universe.h:72
BOOL(* EntityFilterPredicate)(Entity *entity, void *parameter)
Definition Universe.h:52
Universe * gSharedUniverse
Definition Universe.m:141
GLuint targetDepthBufferID
Definition Universe.h:366
NSArray * speechArray
Definition Universe.h:339
NSSpeechSynthesizer * speechSynthesizer
Definition Universe.h:334
OOGraphicsDetail detailLevel
Definition Universe.h:241
GLuint pingpongColorbuffers[2]
Definition Universe.h:375
unsigned n_entities
Definition Universe.h:192
GLuint msaaDepthBufferID
Definition Universe.h:365
OOShaderProgram * finalProgram
Definition Universe.h:371
OOWeakReference * _firstBeacon
Definition Universe.h:221
NSMutableDictionary * conditionScripts
Definition Universe.h:349
OOGalaxyID galaxyID
Definition Universe.h:284
NSArray * demo_ships
Definition Universe.h:257
BOOL _autoMessageLogBg
Definition Universe.h:354
OOSystemID systemID
Definition Universe.h:285
BOOL autoSaveNow
Definition Universe.h:238
BOOL _doingStartUp
Definition Universe.h:358
GLuint msaaTextureID
Definition Universe.h:360
NSString * system_repopulator
Definition Universe.h:305
OOTimeAbsolute demo_start_time
Definition Universe.h:252
OOSystemID targetSystemID
Definition Universe.h:286
GLuint quadTextureVAO
Definition Universe.h:372
BOOL ECMVisualFXEnabled
Definition Universe.h:318
NSString * system_names[256]
Definition Universe.h:288
NSString * useAddOns
Definition Universe.h:310
GLfloat sun_diffuse[4]
Definition Universe.h:205
NSUInteger demo_ship_index
Definition Universe.h:255
Entity * y_list_start
Definition Universe.h:197
NSDictionary * customSounds
Definition Universe.h:268
BOOL doProcedurallyTexturedPlanets
Definition Universe.h:345
OOCommodities * commodities
Definition Universe.h:263
OOShaderProgram * blurProgram
Definition Universe.h:370
NSMutableSet * allStations
Definition Universe.h:299
NSDictionary * roleCategories
Definition Universe.h:277
GuiDisplayGen * comm_log_gui
Definition Universe.h:233
GLfloat sun_specular[4]
Definition Universe.h:206
NSUInteger demo_ship_subindex
Definition Universe.h:256
GLuint targetFramebufferID
Definition Universe.h:367
NSDictionary * _descriptions
Definition Universe.h:267
NSDictionary * cargoPods
Definition Universe.h:282
NSArray * equipmentData
Definition Universe.h:274
int cursor_row
Definition Universe.h:194
int demo_stage
Definition Universe.h:254
BOOL doLinkedListMaintenanceThisUpdate
Definition Universe.h:327
NSDictionary * characters
Definition Universe.h:269
NSMutableDictionary * waypoints
Definition Universe.h:223
OOShaderProgram * textureProgram
Definition Universe.h:369
int next_universal_id
Definition Universe.h:216
BOOL wasDisplayGUI
Definition Universe.h:236
OOTimeAbsolute demo_stage_time
Definition Universe.h:251
BOOL _pauseMessage
Definition Universe.h:351
BOOL no_update
Definition Universe.h:312
OOViewID viewDirection
Definition Universe.h:208
BOOL deterministic_population
Definition Universe.h:306
BOOL _autoCommLog
Definition Universe.h:352
OOMatrix viewMatrix
Definition Universe.h:210
NSMutableDictionary * populatorSettings
Definition Universe.h:303
NSDictionary * screenBackgrounds
Definition Universe.h:279
GLuint pingpongFBO[2]
Definition Universe.h:374
NSDictionary * globalSettings
Definition Universe.h:271
GuiDisplayGen * message_gui
Definition Universe.h:232
OOSunEntity * cachedSun
Definition Universe.h:297
NSUInteger _sessionID
Definition Universe.h:202
BOOL system_found[256]
Definition Universe.h:289
NSString * currentMessage
Definition Universe.h:227
CollisionRegion * universeRegion
Definition Universe.h:324
NSDictionary * explosionSettings
Definition Universe.h:280
OOPlanetEntity * cachedPlanet
Definition Universe.h:296
NSSize targetFramebufferSize
Definition Universe.h:363
NSMutableArray * activeWormholes
Definition Universe.h:320
ShipEntity * demo_ship
Definition Universe.h:293
NSMutableArray * entities
Definition Universe.h:219
GLfloat skyClearColor[4]
Definition Universe.h:225
OOCommodityMarket * commodityMarket
Definition Universe.h:264
OOSystemDescriptionManager * systemManager
Definition Universe.h:272
BOOL _permanentMessageLog
Definition Universe.h:355
GLuint passthroughTextureID[2]
Definition Universe.h:362
BOOL _witchspaceBreakPattern
Definition Universe.h:356
NSArray * closeSystems
Definition Universe.h:308
GLuint passthroughFramebufferID
Definition Universe.h:368
NSArray * _scenarios
Definition Universe.h:270
OOTimeDelta next_repopulation
Definition Universe.h:304
GLuint msaaFramebufferID
Definition Universe.h:364
BOOL _bloom
Definition Universe.h:376
double timeAccelerationFactor
Definition Universe.h:315
OOTimeDelta time_delta
Definition Universe.h:249
BOOL dumpCollisionInfo
Definition Universe.h:261
Entity * sortedEntities[UNIVERSE_MAX_ENTITIES+1]
Definition Universe.h:191
GLfloat main_light_position[4]
Definition Universe.h:259
BOOL _dockingClearanceProtocolActive
Definition Universe.h:357
BOOL displayFPS
Definition Universe.h:246
BOOL autoSave
Definition Universe.h:239
int breakPatternCounter
Definition Universe.h:291
OOTimeAbsolute countdown_messageRepeatTime
Definition Universe.h:229
BOOL _permanentCommLog
Definition Universe.h:353
NSMutableSet * entitiesDeadThisUpdate
Definition Universe.h:329
GLfloat stars_ambient[4]
Definition Universe.h:199
NSMutableArray * characterPool
Definition Universe.h:322
MyOpenGLView * gameView
Definition Universe.h:214
GLfloat airResistanceFactor
Definition Universe.h:212
NSDictionary * autoAIMap
Definition Universe.h:278
GLuint quadTextureVBO
Definition Universe.h:372
OOTimeAbsolute messageRepeatTime
Definition Universe.h:228
NSMutableArray * allPlanets
Definition Universe.h:298
GLfloat demo_start_z
Definition Universe.h:253
GLuint targetTextureID
Definition Universe.h:361
GLint defaultDrawFBO
Definition Universe.h:373
Entity * z_list_start
Definition Universe.h:197
BOOL displayGUI
Definition Universe.h:235
GLfloat frustum[6][4]
Definition Universe.h:347
int framesDoneThisUpdate
Definition Universe.h:330
Entity * entity_for_uid[MAX_ENTITY_UID]
Definition Universe.h:217
BOOL wireframeGraphics
Definition Universe.h:240
OOTimeAbsolute universal_time
Definition Universe.h:248
StationEntity * cachedStation
Definition Universe.h:295
GLuint quadTextureEBO
Definition Universe.h:372
OOWeakReference * _lastBeacon
Definition Universe.h:222
Entity * x_list_start
Definition Universe.h:197
int _currentPostFX
Definition Universe.h:377
NSDictionary * missiontext
Definition Universe.h:273
float ambientLightLevel
Definition Universe.h:301
int _colorblindMode
Definition Universe.h:378
NSArray * equipmentDataOutfitting
Definition Universe.h:275
GuiDisplayGen * gui
Definition Universe.h:231
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque