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