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