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