Line data Source code
1 0 : /* 2 : 3 : OOEquipmentType.h 4 : 5 : Class representing a type of ship equipment. Exposed to JavaScript as 6 : EquipmentInfo. 7 : 8 : 9 : Copyright (C) 2008-2013 Jens Ayton and contributors 10 : 11 : Permission is hereby granted, free of charge, to any person obtaining a copy 12 : of this software and associated documentation files (the "Software"), to deal 13 : in the Software without restriction, including without limitation the rights 14 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 : copies of the Software, and to permit persons to whom the Software is 16 : furnished to do so, subject to the following conditions: 17 : 18 : The above copyright notice and this permission notice shall be included in all 19 : copies or substantial portions of the Software. 20 : 21 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 : SOFTWARE. 28 : 29 : */ 30 : 31 : #import "OOCocoa.h" 32 : #import "OOTypes.h" 33 : #import "OOScript.h" 34 : #import "Universe.h" 35 : 36 : 37 0 : @interface OOEquipmentType: NSObject <NSCopying> 38 : { 39 : @private 40 : OOTechLevelID _techLevel; 41 0 : OOCreditsQuantity _price; 42 0 : NSString *_name; 43 0 : NSString *_identifier; 44 0 : NSString *_description; 45 0 : unsigned _isAvailableToAll: 1, 46 0 : _requiresEmptyPylon: 1, 47 0 : _requiresMountedPylon: 1, 48 0 : _requiresClean: 1, 49 0 : _requiresNotClean: 1, 50 0 : _portableBetweenShips: 1, 51 0 : _requiresFreePassengerBerth: 1, 52 0 : _requiresFullFuel: 1, 53 0 : _requiresNonFullFuel: 1, 54 0 : _isMissileOrMine: 1, 55 0 : _isVisible: 1, 56 0 : _isAvailableToPlayer: 1, 57 0 : _isAvailableToNPCs: 1, 58 0 : _fastAffinityA: 1, 59 0 : _fastAffinityB: 1, 60 0 : _canCarryMultiple: 1, 61 0 : _hideValues: 1; 62 0 : OOColor *_displayColor; 63 0 : NSUInteger _installTime; 64 0 : NSUInteger _repairTime; 65 0 : GLfloat _damageProbability; 66 0 : OOCargoQuantity _requiredCargoSpace; 67 0 : NSSet *_requiresEquipment; 68 0 : NSSet *_requiresAnyEquipment; 69 0 : NSSet *_incompatibleEquipment; 70 0 : NSArray *_conditions; 71 0 : NSArray *_provides; 72 0 : NSArray *_defaultActivateKey; 73 0 : NSArray *_defaultModeKey; 74 0 : NSDictionary *_scriptInfo; 75 0 : NSDictionary *_weaponInfo; 76 0 : NSString *_script; 77 0 : NSString *_condition_script; 78 0 : 79 : struct JSObject *_jsSelf; 80 0 : } 81 : 82 : + (void) loadEquipment; // Load equipment data; called on loading and when changing to/from strict mode. 83 0 : + (void) addEquipmentWithInfo:(NSArray *)itemInfo; // Used to generate equipment from missile_role entries. 84 0 : 85 : + (NSString *) getMissileRegistryRoleForShip:(NSString *)shipKey; 86 0 : + (void) setMissileRegistryRole:(NSString *)roles forShip:(NSString *)shipKey; 87 0 : 88 : + (NSArray *) allEquipmentTypes; 89 0 : + (NSEnumerator *) equipmentEnumerator; 90 0 : + (NSEnumerator *) reverseEquipmentEnumerator; 91 0 : + (NSEnumerator *) equipmentEnumeratorOutfitting; 92 0 : 93 : + (OOEquipmentType *) equipmentTypeWithIdentifier:(NSString *)identifier; 94 0 : 95 : - (NSString *) identifier; 96 0 : - (NSString *) damagedIdentifier; 97 0 : - (NSString *) name; // localized 98 0 : - (NSString *) descriptiveText; // localized 99 0 : - (OOTechLevelID) techLevel; 100 0 : - (OOCreditsQuantity) price; // Tenths of credits 101 0 : 102 : - (BOOL) isAvailableToAll; 103 0 : - (BOOL) requiresEmptyPylon; 104 0 : - (BOOL) requiresMountedPylon; 105 0 : - (BOOL) requiresCleanLegalRecord; 106 0 : - (BOOL) requiresNonCleanLegalRecord; 107 0 : - (BOOL) requiresFreePassengerBerth; 108 0 : - (BOOL) requiresFullFuel; 109 0 : - (BOOL) requiresNonFullFuel; 110 0 : - (BOOL) isPrimaryWeapon; 111 0 : - (BOOL) isMissileOrMine; 112 0 : - (BOOL) isPortableBetweenShips; 113 0 : 114 : - (BOOL) canCarryMultiple; 115 0 : - (GLfloat) damageProbability; 116 0 : - (BOOL) canBeDamaged; 117 0 : - (BOOL) isVisible; // Visible in UI? 118 0 : - (BOOL) hideValues; 119 0 : - (OOColor *) displayColor; 120 0 : - (void) setDisplayColor:(OOColor *)newColor; 121 0 : 122 : - (BOOL) isAvailableToPlayer; 123 0 : - (BOOL) isAvailableToNPCs; 124 0 : 125 : - (OOCargoQuantity) requiredCargoSpace; 126 0 : - (NSSet *) requiresEquipment; // Set of equipment identifiers; all items required 127 0 : - (NSSet *) requiresAnyEquipment; // Set of equipment identifiers; any item required 128 0 : - (NSSet *) incompatibleEquipment; // Set of equipment identifiers; all items prohibited 129 0 : 130 : // FIXME: should have general mechanism to handle scripts or legacy conditions. 131 : - (NSArray *) conditions; 132 0 : 133 : - (NSString *) conditionScript; 134 0 : 135 : - (NSDictionary *) scriptInfo; 136 0 : - (NSString *) scriptName; 137 0 : 138 : - (BOOL) fastAffinityDefensive; 139 0 : - (BOOL) fastAffinityOffensive; 140 0 : 141 : - (NSArray *) defaultActivateKey; 142 0 : - (NSArray *) defaultModeKey; 143 0 : 144 : - (NSUInteger) installTime; 145 0 : - (NSUInteger) repairTime; 146 0 : 147 : - (NSArray *) providesForScripting; 148 0 : - (BOOL) provides:(NSString *)key; 149 0 : 150 : // weapon properties 151 : - (BOOL) isTurretLaser; 152 0 : - (BOOL) isMiningLaser; 153 0 : - (NSDictionary *) weaponInfo; 154 0 : - (GLfloat) weaponRange; 155 0 : - (GLfloat) weaponEnergyUse; 156 0 : - (GLfloat) weaponDamage; 157 0 : - (GLfloat) weaponRechargeRate; 158 0 : - (GLfloat) weaponShotTemperature; 159 0 : - (GLfloat) weaponThreatAssessment; 160 0 : - (OOColor *) weaponColor; 161 0 : - (NSString *) fxShotMissName; 162 0 : - (NSString *) fxShotHitName; 163 0 : - (NSString *) fxShieldHitName; 164 0 : - (NSString *) fxUnshieldedHitName; 165 0 : - (NSString *) fxWeaponLaunchedName; 166 0 : 167 : @end 168 : 169 : 170 : @interface OOEquipmentType (Conveniences) 171 : 172 : - (OOTechLevelID) effectiveTechLevel; 173 0 : 174 : @end