Line data Source code
1 0 : /* 2 : 3 : OOSystemDescriptionManager.h 4 : 5 : Class responsible for planet description data. 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 "OOTypes.h" 29 : #import "legacy_random.h" 30 : 31 0 : typedef enum 32 : { 33 : OO_LAYER_CORE = 0, 34 : OO_LAYER_OXP_STATIC = 1, 35 : OO_LAYER_OXP_DYNAMIC = 2, 36 : OO_LAYER_OXP_PRIORITY = 3 37 : } OOSystemLayer; 38 : 39 : 40 0 : typedef enum 41 : { 42 : OO_SYSTEMCONCEALMENT_NONE = 0, 43 : OO_SYSTEMCONCEALMENT_NODATA = 100, 44 : OO_SYSTEMCONCEALMENT_NONAME = 200, 45 : OO_SYSTEMCONCEALMENT_NOTHING = 300 46 : } OOSystemConcealment; 47 : 48 : 49 0 : #define OO_SYSTEM_LAYERS 4 50 0 : #define OO_SYSTEMS_PER_GALAXY (kOOMaximumSystemID+1) 51 0 : #define OO_GALAXIES_AVAILABLE (kOOMaximumGalaxyID+1) 52 0 : #define OO_SYSTEMS_AVAILABLE OO_SYSTEMS_PER_GALAXY * OO_GALAXIES_AVAILABLE 53 : // don't bother caching interstellar properties 54 0 : #define OO_SYSTEM_CACHE_LENGTH OO_SYSTEMS_AVAILABLE 55 : 56 0 : @interface OOSystemDescriptionEntry : NSObject 57 : { 58 : @private 59 0 : NSMutableDictionary *layers[OO_SYSTEM_LAYERS]; 60 : } 61 : 62 0 : - (void) setProperty:(NSString *)property forLayer:(OOSystemLayer)layer toValue:(id)value; 63 0 : - (id) getProperty:(NSString *)property forLayer:(OOSystemLayer)layer; 64 : 65 : @end 66 : 67 : /** 68 : * Note: forSystem: inGalaxy: returns from the (fast) propertyCache 69 : * 70 : * forSystemKey calculates the values - but is necessary for 71 : * interstellar space 72 : */ 73 1 : @interface OOSystemDescriptionManager : NSObject 74 : { 75 : @private 76 0 : NSMutableDictionary *universalProperties; 77 0 : OOSystemDescriptionEntry *interstellarSpace; 78 0 : NSMutableDictionary *systemDescriptions; 79 0 : NSMutableDictionary *propertyCache[OO_SYSTEM_CACHE_LENGTH]; 80 0 : NSMutableSet *propertiesInUse; 81 0 : NSPoint coordinatesCache[OO_SYSTEM_CACHE_LENGTH]; 82 0 : NSMutableArray *neighbourCache[OO_SYSTEM_CACHE_LENGTH]; 83 0 : NSMutableDictionary *scriptedChanges; 84 : } 85 : 86 : // this needs to be re-called every time system coordinates change 87 : // changing system coordinates after plist loading is probably 88 : // too much of a can of worms *anyway*, so currently it's only 89 : // called just after the manager data is loaded. 90 0 : - (void) buildRouteCache; 91 : 92 0 : - (void) setUniversalProperties:(NSDictionary *)properties; 93 0 : - (void) setInterstellarProperties:(NSDictionary *)properties; 94 : 95 : // this is used by planetinfo.plist and has default layer 1 96 0 : - (void) setProperties:(NSDictionary *)properties forSystemKey:(NSString *)key; 97 : 98 : // this is used by Javascript property setting 99 0 : - (void) setProperty:(NSString *)property forSystemKey:(NSString *)key andLayer:(OOSystemLayer)layer toValue:(id)value fromManifest:(NSString *)manifest; 100 : 101 0 : - (void) importScriptedChanges:(NSDictionary *)scripted; 102 0 : - (void) importLegacyScriptedChanges:(NSDictionary *)scripted; 103 0 : - (NSDictionary *) exportScriptedChanges; 104 : 105 0 : - (NSDictionary *) getPropertiesForSystemKey:(NSString *)key; 106 0 : - (NSDictionary *) getPropertiesForSystem:(OOSystemID)s inGalaxy:(OOGalaxyID)g; 107 0 : - (NSDictionary *) getPropertiesForCurrentSystem; 108 0 : - (id) getProperty:(NSString *)property forSystemKey:(NSString *)key; 109 0 : - (id) getProperty:(NSString *)property forSystem:(OOSystemID)s inGalaxy:(OOGalaxyID)g; 110 : 111 0 : - (NSPoint) getCoordinatesForSystem:(OOSystemID)s inGalaxy:(OOGalaxyID)g; 112 0 : - (NSArray *) getNeighbourIDsForSystem:(OOSystemID)s inGalaxy:(OOGalaxyID)g; 113 : 114 0 : - (Random_Seed) getRandomSeedForCurrentSystem; 115 0 : - (Random_Seed) getRandomSeedForSystem:(OOSystemID)s inGalaxy:(OOGalaxyID)g; 116 : 117 : @end 118 : 119 :