Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOEquipmentType Class Reference

#include <OOEquipmentType.h>

+ Inheritance diagram for OOEquipmentType:
+ Collaboration diagram for OOEquipmentType:

Instance Methods

(NSString *) - identifier
 
(NSString *) - damagedIdentifier
 
(NSString *) - name
 
(NSString *) - descriptiveText
 
(OOTechLevelID- techLevel
 
(OOCreditsQuantity- price
 
(BOOL) - isAvailableToAll
 
(BOOL) - requiresEmptyPylon
 
(BOOL) - requiresMountedPylon
 
(BOOL) - requiresCleanLegalRecord
 
(BOOL) - requiresNonCleanLegalRecord
 
(BOOL) - requiresFreePassengerBerth
 
(BOOL) - requiresFullFuel
 
(BOOL) - requiresNonFullFuel
 
(BOOL) - isPrimaryWeapon
 
(BOOL) - isMissileOrMine
 
(BOOL) - isPortableBetweenShips
 
(BOOL) - canCarryMultiple
 
(GLfloat) - damageProbability
 
(BOOL) - canBeDamaged
 
(BOOL) - isVisible
 
(BOOL) - hideValues
 
(OOColor *) - displayColor
 
(void) - setDisplayColor:
 
(BOOL) - isAvailableToPlayer
 
(BOOL) - isAvailableToNPCs
 
(OOCargoQuantity- requiredCargoSpace
 
(NSSet *) - requiresEquipment
 
(NSSet *) - requiresAnyEquipment
 
(NSSet *) - incompatibleEquipment
 
(NSArray *) - conditions
 
(NSString *) - conditionScript
 
(NSDictionary *) - scriptInfo
 
(NSString *) - scriptName
 
(BOOL) - fastAffinityDefensive
 
(BOOL) - fastAffinityOffensive
 
(NSArray *) - defaultActivateKey
 
(NSArray *) - defaultModeKey
 
(NSUInteger) - installTime
 
(NSUInteger) - repairTime
 
(NSArray *) - providesForScripting
 
(BOOL) - provides:
 
(BOOL) - isTurretLaser
 
(BOOL) - isMiningLaser
 
(NSDictionary *) - weaponInfo
 
(GLfloat) - weaponRange
 
(GLfloat) - weaponEnergyUse
 
(GLfloat) - weaponDamage
 
(GLfloat) - weaponRechargeRate
 
(GLfloat) - weaponShotTemperature
 
(GLfloat) - weaponThreatAssessment
 
(OOColor *) - weaponColor
 
(NSString *) - fxShotMissName
 
(NSString *) - fxShotHitName
 
(NSString *) - fxShieldHitName
 
(NSString *) - fxUnshieldedHitName
 
(NSString *) - fxWeaponLaunchedName
 
(id) - initWithInfo: [implementation]
 
(void) - dealloc [implementation]
 
(id) - copyWithZone: [implementation]
 
(NSString *) - descriptionComponents [implementation]
 
(BOOL) - suppressClangStuff [implementation]
 
(OOTechLevelID- effectiveTechLevel
 
(jsval) - oo_jsValueInContext: [implementation]
 
(NSString *) - oo_jsClassName [implementation]
 
(void) - oo_clearJSSelf: [implementation]
 

Class Methods

(void) + loadEquipment
 
(void) + addEquipmentWithInfo:
 
(NSString *) + getMissileRegistryRoleForShip:
 
(void) + setMissileRegistryRole:forShip:
 
(NSArray *) + allEquipmentTypes
 
(NSEnumerator *) + equipmentEnumerator
 
(NSEnumerator *) + reverseEquipmentEnumerator
 
(NSEnumerator *) + equipmentEnumeratorOutfitting
 
(OOEquipmentType *) + equipmentTypeWithIdentifier:
 

Private Attributes

OOTechLevelID _techLevel
 
OOCreditsQuantity _price
 
NSString * _name
 
NSString * _identifier
 
NSString * _description
 
unsigned _isAvailableToAll: 1
 
unsigned _requiresEmptyPylon: 1
 
unsigned _requiresMountedPylon: 1
 
unsigned _requiresClean: 1
 
unsigned _requiresNotClean: 1
 
unsigned _portableBetweenShips: 1
 
unsigned _requiresFreePassengerBerth: 1
 
unsigned _requiresFullFuel: 1
 
unsigned _requiresNonFullFuel: 1
 
unsigned _isMissileOrMine: 1
 
unsigned _isVisible: 1
 
unsigned _isAvailableToPlayer: 1
 
unsigned _isAvailableToNPCs: 1
 
unsigned _fastAffinityA: 1
 
unsigned _fastAffinityB: 1
 
unsigned _canCarryMultiple: 1
 
unsigned _hideValues: 1
 
OOColor_displayColor
 
NSUInteger _installTime
 
NSUInteger _repairTime
 
GLfloat _damageProbability
 
OOCargoQuantity _requiredCargoSpace
 
NSSet * _requiresEquipment
 
NSSet * _requiresAnyEquipment
 
NSSet * _incompatibleEquipment
 
NSArray * _conditions
 
NSArray * _provides
 
NSArray * _defaultActivateKey
 
NSArray * _defaultModeKey
 
NSDictionary * _scriptInfo
 
NSDictionary * _weaponInfo
 
NSString * _script
 
NSString * _condition_script
 
struct JSObject * _jsSelf
 

Detailed Description

Definition at line 37 of file OOEquipmentType.h.

Method Documentation

◆ addEquipmentWithInfo:

+ (void) addEquipmentWithInfo: (NSArray *) itemInfo

Definition at line 40 of file OOEquipmentType.m.

115 :(NSArray *)itemInfo
116{
117 NSMutableArray *equipmentTypes = [NSMutableArray arrayWithArray:sEquipmentTypes];
118 NSMutableArray *equipmentTypesOutfitting = [NSMutableArray arrayWithArray:sEquipmentTypesOutfitting];
119 NSMutableDictionary *equipmentTypesByIdentifier = [[NSMutableDictionary alloc] initWithDictionary:sEquipmentTypesByIdentifier];
120 OOEquipmentType *item = [[[OOEquipmentType alloc] initWithInfo:itemInfo] autorelease];
121 if (item != nil)
122 {
123 [equipmentTypes addObject:item];
124 [equipmentTypesOutfitting addObject:item];
125 [equipmentTypesByIdentifier setObject:item forKey:[item identifier]];
126
127 [sEquipmentTypes release];
129 [sEquipmentTypesOutfitting release];
132 sEquipmentTypes = [equipmentTypes copy];
133 sEquipmentTypesOutfitting = [equipmentTypesOutfitting copy];
134 sEquipmentTypesByIdentifier = [[NSDictionary alloc] initWithDictionary:equipmentTypesByIdentifier];
135 }
136 DESTROY(equipmentTypesByIdentifier);
137}
#define DESTROY(x)
Definition OOCocoa.h:77
static NSDictionary * sEquipmentTypesByIdentifier
static NSArray * sEquipmentTypes
static NSArray * sEquipmentTypesOutfitting
return nil
NSString * identifier()

◆ allEquipmentTypes

+ (NSArray *) allEquipmentTypes

Definition at line 40 of file OOEquipmentType.m.

160{
161 return sEquipmentTypes;
162}

◆ canBeDamaged

- (BOOL) canBeDamaged

Definition at line 40 of file OOEquipmentType.m.

568{
569 if ([self isMissileOrMine]) return NO;
570
571 if ([self damageProbability] > 0.0)
572 {
573 return YES;
574 }
575
576 return NO;
577}
GLfloat damageProbability()

◆ canCarryMultiple

- (BOOL) canCarryMultiple

Definition at line 40 of file OOEquipmentType.m.

543{
544 if ([self isMissileOrMine]) return YES;
545 // technically multiple can be fitted, but not to the same mount.
546 if ([self isPrimaryWeapon]) return NO;
547
548 // hard-coded as special items
549 if ([_identifier isEqualToString:@"EQ_PASSENGER_BERTH"] ||
550 [_identifier isEqualToString:@"EQ_TRUMBLE"])
551 {
552 return YES;
553 }
554
555 return _canCarryMultiple;
556}
NSString * _identifier
unsigned _canCarryMultiple

Referenced by ShipAwardEquipment().

+ Here is the caller graph for this function:

◆ conditions

- (NSArray *) conditions

Definition at line 40 of file OOEquipmentType.m.

642{
643 return _conditions;
644}
NSArray * _conditions

◆ conditionScript

- (NSString *) conditionScript

Definition at line 40 of file OOEquipmentType.m.

648{
649 return _condition_script;
650}
NSString * _condition_script

◆ copyWithZone:

- (id) copyWithZone: (NSZone *) zone
implementation

Definition at line 40 of file OOEquipmentType.m.

427 :(NSZone *)zone
428{
429 // OOEquipmentTypes are immutable.
430 return [self retain];
431}

◆ damagedIdentifier

- (NSString *) damagedIdentifier

Definition at line 40 of file OOEquipmentType.m.

447{
448 return [_identifier stringByAppendingString:@"_DAMAGED"];
449}

◆ damageProbability

- (GLfloat) damageProbability

Definition at line 40 of file OOEquipmentType.m.

560{
561 if ([self isMissileOrMine]) return 0.0;
562
563 return _damageProbability;
564}
GLfloat _damageProbability

◆ dealloc

- (void) dealloc
implementation

Definition at line 40 of file OOEquipmentType.m.

406{
407 DESTROY(_name);
422
423 [super dealloc];
424}
NSArray * _defaultActivateKey
NSArray * _defaultModeKey
NSString * _description
NSDictionary * _scriptInfo
NSSet * _requiresEquipment
NSSet * _requiresAnyEquipment
NSSet * _incompatibleEquipment
OOColor * _displayColor
NSDictionary * _weaponInfo

◆ defaultActivateKey

- (NSArray *) defaultActivateKey

Definition at line 40 of file OOEquipmentType.m.

678{
679 return _defaultActivateKey;
680}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ defaultModeKey

- (NSArray *) defaultModeKey

Definition at line 40 of file OOEquipmentType.m.

684{
685 return _defaultModeKey;
686}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Definition at line 40 of file OOEquipmentType.m.

435{
436 return [NSString stringWithFormat:@"%@ \"%@\"", _identifier, _name];
437}

◆ descriptiveText

- (NSString *) descriptiveText

Definition at line 40 of file OOEquipmentType.m.

459{
460 return _description;
461}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ displayColor

- (OOColor *) displayColor

Definition at line 40 of file OOEquipmentType.m.

629{
630 return _displayColor;
631}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ effectiveTechLevel

- (OOTechLevelID) effectiveTechLevel

Provided by category OOEquipmentType(Conveniences).

Definition at line 40 of file OOEquipmentType.m.

829{
830 OOTechLevelID tl;
831 id missionVar = nil;
832
833 tl = [self techLevel];
834 if (tl == kOOVariableTechLevel)
835 {
836 OOStandardsDeprecated([NSString stringWithFormat:@"TL99 is deprecated for %@",[self identifier]]);
837 if (!OOEnforceStandards())
838 {
839 missionVar = [PLAYER missionVariableForKey:[@"mission_TL_FOR_" stringByAppendingString:[self identifier]]];
840 tl = OOUIntegerFromObject(missionVar, tl);
841 }
842 }
843
844 return tl;
845}
OOINLINE NSInteger OOUIntegerFromObject(id object, NSUInteger defaultValue)
void OOStandardsDeprecated(NSString *message)
BOOL OOEnforceStandards(void)
@ kOOVariableTechLevel
Definition OOTypes.h:202
NSUInteger OOTechLevelID
Definition OOTypes.h:204

◆ equipmentEnumerator

+ (NSEnumerator *) equipmentEnumerator

Definition at line 40 of file OOEquipmentType.m.

166{
167 return [sEquipmentTypes objectEnumerator];
168}

◆ equipmentEnumeratorOutfitting

+ (NSEnumerator *) equipmentEnumeratorOutfitting

Definition at line 40 of file OOEquipmentType.m.

178{
179 return [sEquipmentTypesOutfitting objectEnumerator];
180}

◆ equipmentTypeWithIdentifier:

+ (OOEquipmentType *) equipmentTypeWithIdentifier: (NSString *) identifier

Definition at line 40 of file OOEquipmentType.m.

183 :(NSString *)identifier
184{
185 return [sEquipmentTypesByIdentifier objectForKey:identifier];
186}

Referenced by JSValueToEquipmentType(), OOWeaponTypeFromEquipmentIdentifierSloppy(), and PlayerShipAwardEquipmentToCurrentPylon().

+ Here is the caller graph for this function:

◆ fastAffinityDefensive

- (BOOL) fastAffinityDefensive

Definition at line 40 of file OOEquipmentType.m.

666{
667 return _fastAffinityA;
668}
unsigned _fastAffinityA

◆ fastAffinityOffensive

- (BOOL) fastAffinityOffensive

Definition at line 40 of file OOEquipmentType.m.

672{
673 return _fastAffinityB;
674}
unsigned _fastAffinityB

◆ fxShieldHitName

- (NSString *) fxShieldHitName

Definition at line 40 of file OOEquipmentType.m.

794{
795 return [_weaponInfo oo_stringForKey:@"fx_hitplayer_shielded_name" defaultValue:@"[player-hit-by-weapon]"];
796}

◆ fxShotHitName

- (NSString *) fxShotHitName

Definition at line 40 of file OOEquipmentType.m.

788{
789 return [_weaponInfo oo_stringForKey:@"fx_shot_hit_name" defaultValue:@"[player-laser-hit]"];
790}

◆ fxShotMissName

- (NSString *) fxShotMissName

Definition at line 40 of file OOEquipmentType.m.

782{
783 return [_weaponInfo oo_stringForKey:@"fx_shot_miss_name" defaultValue:@"[player-laser-miss]"];
784}

◆ fxUnshieldedHitName

- (NSString *) fxUnshieldedHitName

Definition at line 40 of file OOEquipmentType.m.

800{
801 return [_weaponInfo oo_stringForKey:@"fx_hitplayer_unshielded_name" defaultValue:@"[player-direct-hit]"];
802}

◆ fxWeaponLaunchedName

- (NSString *) fxWeaponLaunchedName

Definition at line 40 of file OOEquipmentType.m.

806{
807 return [_weaponInfo oo_stringForKey:@"fx_weapon_launch_name" defaultValue:([[self identifier] hasSuffix:@"_MINE"] ? @"[mine-launched]" : @"[missile-launched]")];
808}

◆ getMissileRegistryRoleForShip:

+ (NSString *) getMissileRegistryRoleForShip: (NSString *) shipKey

Definition at line 40 of file OOEquipmentType.m.

140 :(NSString *)shipKey
141{
142 return [sMissilesRegistry oo_stringForKey:shipKey];
143}

◆ hideValues

- (BOOL) hideValues

Definition at line 40 of file OOEquipmentType.m.

587{
588 return _hideValues;
589}

◆ identifier

- (NSString *) identifier

Definition at line 40 of file OOEquipmentType.m.

441{
442 return _identifier;
443}

Referenced by ShipEntity::absoluteTractorPosition, EquipmentInfoGetProperty(), EquipmentInfoSetProperty(), OOEquipmentIdentifierFromWeaponType(), OOStringFromWeaponType(), ShipAwardEquipment(), ShipSelectNewMissile(), and ShipSetEquipmentStatus().

+ Here is the caller graph for this function:

◆ incompatibleEquipment

- (NSSet *) incompatibleEquipment

Definition at line 40 of file OOEquipmentType.m.

623{
625}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ initWithInfo:

- (id) initWithInfo: (NSArray *) info
implementation

Provided by category OOEquipmentType(Private).

Definition at line 40 of file OOEquipmentType.m.

189 :(NSArray *)info
190{
191 BOOL OK = YES;
192 NSDictionary *extra = nil;
193 NSArray *conditions = nil;
194 NSString *condition_script = nil;
195 NSArray *keydef = nil;
196
197 self = [super init];
198 if (self == nil) OK = NO;
199
200 if (OK && [info count] <= EQUIPMENT_LONG_DESC_INDEX) OK = NO;
201
202 if (OK)
203 {
204 // Read required attributes
205 _techLevel = [info oo_unsignedIntAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
206 _price = [info oo_unsignedIntAtIndex:EQUIPMENT_PRICE_INDEX];
207 _name = [[info oo_stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX] retain];
208 _identifier = [[info oo_stringAtIndex:EQUIPMENT_KEY_INDEX] retain];
209 _description = [[info oo_stringAtIndex:EQUIPMENT_LONG_DESC_INDEX] retain];
210
211 if (_name == nil || _identifier == nil || _description == nil)
212 {
213 OOLog(@"equipment.load", @"***** ERROR: Invalid equipment.plist entry - missing name, identifier or description (\"%@\", %@, \"%@\")", _name, _identifier, _description);
214 OK = NO;
215 }
216 }
217
218 if (OK)
219 {
220 // Implied attributes for backwards-compatibility
221 if ([_identifier hasSuffix:@"_MISSILE"] || [_identifier hasSuffix:@"_MINE"])
222 {
223 _isMissileOrMine = YES;
225 }
226 else if ([_identifier isEqualToString:@"EQ_PASSENGER_BERTH_REMOVAL"])
227 {
229 }
230 else if ([_identifier isEqualToString:@"EQ_FUEL"])
231 {
233 }
234 _isVisible = YES;
236 _isAvailableToNPCs = YES;
237 _damageProbability = 1.0;
238 _hideValues = NO;
239 }
240
241 if (OK && [info count] > EQUIPMENT_EXTRA_INFO_INDEX)
242 {
243 // Read extra info dictionary
244 extra = [info oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX];
245 if (extra != nil)
246 {
247
248 _isAvailableToAll = [extra oo_boolForKey:@"available_to_all" defaultValue:_isAvailableToAll];
249 _isAvailableToPlayer = [extra oo_boolForKey:@"available_to_player" defaultValue:_isAvailableToPlayer];
250 _isAvailableToNPCs = [extra oo_boolForKey:@"available_to_NPCs" defaultValue:_isAvailableToNPCs];
251
252 _isMissileOrMine = [extra oo_boolForKey:@"is_external_store" defaultValue:_isMissileOrMine];
253 _requiresEmptyPylon = [extra oo_boolForKey:@"requires_empty_pylon" defaultValue:_requiresEmptyPylon];
254 _requiresMountedPylon = [extra oo_boolForKey:@"requires_mounted_pylon" defaultValue:_requiresMountedPylon];
255 _requiresClean = [extra oo_boolForKey:@"requires_clean" defaultValue:_requiresClean];
256 _requiresNotClean = [extra oo_boolForKey:@"requires_not_clean" defaultValue:_requiresNotClean];
257 _portableBetweenShips = [extra oo_boolForKey:@"portable_between_ships" defaultValue:_portableBetweenShips];
258 _requiresFreePassengerBerth = [extra oo_boolForKey:@"requires_free_passenger_berth" defaultValue:_requiresFreePassengerBerth];
259 _requiresFullFuel = [extra oo_boolForKey:@"requires_full_fuel" defaultValue:_requiresFullFuel];
260 _requiresNonFullFuel = [extra oo_boolForKey:@"requires_non_full_fuel" defaultValue:_requiresNonFullFuel];
261 _isVisible = [extra oo_boolForKey:@"visible" defaultValue:_isVisible];
262 _canCarryMultiple = [extra oo_boolForKey:@"can_carry_multiple" defaultValue:NO];
263 _hideValues = [extra oo_boolForKey:@"hide_values" defaultValue:NO];
264
265 _requiredCargoSpace = [extra oo_unsignedIntForKey:@"requires_cargo_space" defaultValue:_requiredCargoSpace];
266
267 _installTime = [extra oo_unsignedIntForKey:@"installation_time" defaultValue:0];
268 _repairTime = [extra oo_unsignedIntForKey:@"repair_time" defaultValue:0];
269 _provides = [[extra oo_arrayForKey:@"provides" defaultValue:[NSArray array]] retain];
270
271 id dispColor = [extra oo_objectForKey:@"display_color" defaultValue:nil];
272 _displayColor = [[OOColor colorWithDescription:dispColor] retain];
273
274 _weaponInfo = [[extra oo_dictionaryForKey:@"weapon_info" defaultValue:[NSDictionary dictionary]] retain];
275
276 _damageProbability = [extra oo_floatForKey:@"damage_probability" defaultValue:(_isMissileOrMine?0.0:1.0)];
277
278 id object = [extra objectForKey:@"requires_equipment"];
279 if ([object isKindOfClass:[NSString class]]) _requiresEquipment = [[NSSet setWithObject:object] retain];
280 else if ([object isKindOfClass:[NSArray class]]) _requiresEquipment = [[NSSet setWithArray:object] retain];
281 else if (object != nil)
282 {
283 OOLog(@"equipment.load", @"***** ERROR: %@ for equipment item %@ is not a string or an array.", @"requires_equipment", _identifier);
284 }
285
286 object = [extra objectForKey:@"requires_any_equipment"];
287 if ([object isKindOfClass:[NSString class]]) _requiresAnyEquipment = [[NSSet setWithObject:object] retain];
288 else if ([object isKindOfClass:[NSArray class]]) _requiresAnyEquipment = [[NSSet setWithArray:object] retain];
289 else if (object != nil)
290 {
291 OOLog(@"equipment.load", @"***** ERROR: %@ for equipment item %@ is not a string or an array.", @"requires_any_equipment", _identifier);
292 }
293
294 object = [extra objectForKey:@"incompatible_with_equipment"];
295 if ([object isKindOfClass:[NSString class]]) _incompatibleEquipment = [[NSSet setWithObject:object] retain];
296 else if ([object isKindOfClass:[NSArray class]]) _incompatibleEquipment = [[NSSet setWithArray:object] retain];
297 else if (object != nil)
298 {
299 OOLog(@"equipment.load", @"***** ERROR: %@ for equipment item %@ is not a string or an array.", @"incompatible_with_equipment", _identifier);
300 }
301
302 object = [extra objectForKey:@"conditions"];
303 if ([object isKindOfClass:[NSString class]]) conditions = [NSArray arrayWithObject:object];
304 else if ([object isKindOfClass:[NSArray class]]) conditions = object;
305 else if (object != nil)
306 {
307 OOLog(@"equipment.load", @"***** ERROR: %@ for equipment item %@ is not a string or an array.", @"conditions", _identifier);
308 }
309 if (conditions != nil)
310 {
311 OOStandardsDeprecated([NSString stringWithFormat:@"The conditions key is deprecated for equipment %@",_name]);
312 if (!OOEnforceStandards())
313 {
314 _conditions = OOSanitizeLegacyScriptConditions(conditions, [NSString stringWithFormat:@"<equipment type \"%@\">", _name]);
315 [_conditions retain];
316 }
317 }
318
319 object = [extra objectForKey:@"condition_script"];
320 if ([object isKindOfClass:[NSString class]])
321 {
322 condition_script = object;
323 }
324 else if (object != nil)
325 {
326 OOLog(@"equipment.load", @"***** ERROR: %@ for equipment item %@ is not a string.", @"condition_script", _identifier);
327 }
328 if (condition_script != nil)
329 {
330 _condition_script = [condition_script retain];
331 }
332 /* Condition scripts are shared: all equipment/ships using the
333 * same condition script use one shared instance. Equipment
334 * scripts and ship scripts are not shared and get one instance
335 * per item. */
336
337 _scriptInfo = [extra oo_dictionaryForKey:@"script_info"];
338 [_scriptInfo retain];
339
340 _script = [extra oo_stringForKey:@"script"];
341 if (_script != nil && ![OOScript jsScriptFromFileNamed:_script properties:nil]) _script = nil;
342 [_script retain];
343 if (_script != nil)
344 {
345 _fastAffinityA = !![extra oo_boolForKey:@"fast_affinity_defensive"];
346 _fastAffinityB = !![extra oo_boolForKey:@"fast_affinity_offensive"];
347
348 // look for default activate and mode key settings
349 // note: the customEquipmentActivation array is only populated when starting a game
350 // so the application of any default key settings on equipment will only happen then
351 NSString *checking;
352
353 object = [extra objectForKey:@"default_activate_key"];
354 if ([object isKindOfClass:[NSArray class]]) keydef = object;
355 else if (object != nil)
356 {
357 OOLog(@"equipment.load", @"***** ERROR: %@ for equipment item %@ is not an array.", @"default_activate_key", _identifier);
358 object = nil;
359 }
360
361 if (object != nil)
362 {
363 // do processing for key
364 _defaultActivateKey = [PLAYER processKeyCode:keydef];
365 checking = [PLAYER validateKey:[NSString stringWithFormat:@"activate_%@", _identifier] checkKeys:_defaultActivateKey];
366
367 if (checking != nil) {
368 OOLog(@"equipment.load", @"***** Error: %@ for equipment item %@ is already in use for %@. Default not applied", @"default_activate_key", _identifier, checking);
370 }
371 }
372
373 object = [extra objectForKey:@"default_mode_key"];
374 if ([object isKindOfClass:[NSArray class]]) keydef = object;
375 else if (object != nil)
376 {
377 OOLog(@"equipment.load", @"***** ERROR: %@ for equipment item %@ is not an array.", @"default_mode_key", _identifier);
378 object = nil;
379 }
380
381 if (object != nil)
382 {
383 // do processing for key
384 _defaultModeKey = [PLAYER processKeyCode:keydef];
385 checking = [PLAYER validateKey:[NSString stringWithFormat:@"mode_%@", _identifier] checkKeys:_defaultModeKey];
386
387 if (checking != nil) {
388 OOLog(@"equipment.load", @"***** Error: %@ for equipment item %@ is already in use for %@. Default not applied.", @"default_mode_key", _identifier, checking);
390 }
391 }
392 }
393 }
394 }
395
396 if (!OK)
397 {
398 [self release];
399 self = nil;
400 }
401 return self;
402}
NSArray * OOSanitizeLegacyScriptConditions(NSArray *conditions, NSString *context)
#define OOLog(class, format,...)
Definition OOLogging.h:88
unsigned count
@ EQUIPMENT_LONG_DESC_INDEX
Definition Universe.h:83
@ EQUIPMENT_EXTRA_INFO_INDEX
Definition Universe.h:84
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127
OOCargoQuantity _requiredCargoSpace
unsigned _isMissileOrMine
unsigned _requiresFullFuel
NSUInteger _repairTime
NSUInteger _installTime
unsigned _portableBetweenShips
unsigned _requiresMountedPylon
unsigned _isAvailableToAll
unsigned _isAvailableToNPCs
OOTechLevelID _techLevel
unsigned _requiresNotClean
unsigned _requiresClean
OOCreditsQuantity _price
unsigned _requiresFreePassengerBerth
unsigned _requiresNonFullFuel
unsigned _isAvailableToPlayer
unsigned _requiresEmptyPylon

◆ installTime

- (NSUInteger) installTime

Definition at line 40 of file OOEquipmentType.m.

690{
691 return _installTime;
692}

◆ isAvailableToAll

- (BOOL) isAvailableToAll

Definition at line 40 of file OOEquipmentType.m.

477{
478 return _isAvailableToAll;
479}

◆ isAvailableToNPCs

- (BOOL) isAvailableToNPCs

Definition at line 40 of file OOEquipmentType.m.

599{
600 return _isAvailableToNPCs;
601}

◆ isAvailableToPlayer

- (BOOL) isAvailableToPlayer

Definition at line 40 of file OOEquipmentType.m.

593{
595}

◆ isMiningLaser

- (BOOL) isMiningLaser

Definition at line 40 of file OOEquipmentType.m.

728{
729 return [_weaponInfo oo_boolForKey:@"is_mining_laser" defaultValue:NO];
730}

◆ isMissileOrMine

- (BOOL) isMissileOrMine

Definition at line 40 of file OOEquipmentType.m.

531{
532 return _isMissileOrMine;
533}

◆ isPortableBetweenShips

- (BOOL) isPortableBetweenShips

Definition at line 40 of file OOEquipmentType.m.

537{
539}

◆ isPrimaryWeapon

- (BOOL) isPrimaryWeapon

Definition at line 40 of file OOEquipmentType.m.

525{
526 return [[self identifier] hasPrefix:@"EQ_WEAPON"];
527}

◆ isTurretLaser

- (BOOL) isTurretLaser

Definition at line 40 of file OOEquipmentType.m.

722{
723 return [_weaponInfo oo_boolForKey:@"is_turret_laser" defaultValue:NO];
724}

◆ isVisible

- (BOOL) isVisible

Definition at line 40 of file OOEquipmentType.m.

581{
582 return _isVisible;
583}

◆ loadEquipment

+ (void) loadEquipment

Definition at line 40 of file OOEquipmentType.m.

53{
54 NSArray *equipmentData = nil;
55 NSMutableArray *equipmentTypes = nil;
56 NSMutableDictionary *equipmentTypesByIdentifier = nil;
57 NSArray *itemInfo = nil;
58 OOEquipmentType *item = nil;
59 NSEnumerator *itemEnum = nil;
60 NSMutableArray *conditionScripts = nil;
61
62 equipmentData = [UNIVERSE equipmentData];
63
64 [sEquipmentTypes release];
66 equipmentTypes = [NSMutableArray arrayWithCapacity:[equipmentData count]];
67 conditionScripts = [NSMutableArray arrayWithCapacity:[equipmentData count]];
69 equipmentTypesByIdentifier = [NSMutableDictionary dictionaryWithCapacity:[equipmentData count]];
70
71 for (itemEnum = [equipmentData objectEnumerator]; (itemInfo = [itemEnum nextObject]); )
72 {
73 item = [[[OOEquipmentType alloc] initWithInfo:itemInfo] autorelease];
74 if (item != nil)
75 {
76 [equipmentTypes addObject:item];
77 [equipmentTypesByIdentifier setObject:item forKey:[item identifier]];
78 }
79 NSString* condition_script = [item conditionScript];
80 if (condition_script != nil)
81 {
82 if (![conditionScripts containsObject:condition_script])
83 {
84 [conditionScripts addObject:condition_script];
85 }
86 }
87 }
88
89 [[OOCacheManager sharedCache] setObject:conditionScripts forKey:@"equipment conditions" inCache:@"condition scripts"];
90
91 sEquipmentTypes = [equipmentTypes copy];
92 sEquipmentTypesByIdentifier = [[NSDictionary alloc] initWithDictionary:equipmentTypesByIdentifier];
93
94 // same for the outfitting dataset
95 equipmentData = [UNIVERSE equipmentDataOutfitting];
96
97 [sEquipmentTypesOutfitting release];
99
100 equipmentTypes = [NSMutableArray arrayWithCapacity:[equipmentData count]];
101 for (itemEnum = [equipmentData objectEnumerator]; (itemInfo = [itemEnum nextObject]); )
102 {
103 item = [[[OOEquipmentType alloc] initWithInfo:itemInfo] autorelease];
104 if (item != nil)
105 {
106 [equipmentTypes addObject:item];
107 [equipmentTypesByIdentifier setObject:item forKey:[item identifier]];
108 }
109 }
110 sEquipmentTypesOutfitting = [equipmentTypes copy];
111
112}
void setObject:forKey:inCache:(id inElement,[forKey] NSString *inKey,[inCache] NSString *inCacheKey)
OOCacheManager * sharedCache()
NSString * conditionScript()

◆ name

- (NSString *) name

Definition at line 40 of file OOEquipmentType.m.

453{
454 return _name;
455}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ oo_clearJSSelf:

- (void) oo_clearJSSelf: (JSObject *) selfVal
implementation

Provided by category OOEquipmentType(OOJavaScriptExtensions).

Definition at line 530 of file OOJSEquipmentInfo.m.

519 :(JSObject *)selfVal
520{
521 if (_jsSelf == selfVal) _jsSelf = NULL;
522}

◆ oo_jsClassName

- (NSString *) oo_jsClassName
implementation

Provided by category OOEquipmentType(OOJavaScriptExtensions).

Definition at line 530 of file OOJSEquipmentInfo.m.

514{
515 return @"EquipmentInfo";
516}

◆ oo_jsValueInContext:

- (jsval) oo_jsValueInContext: (JSContext *) context
implementation

Provided by category OOEquipmentType(OOJavaScriptExtensions).

Definition at line 530 of file OOJSEquipmentInfo.m.

498 :(JSContext *)context
499{
500 if (_jsSelf == NULL)
501 {
502 _jsSelf = JS_NewObject(context, &sEquipmentInfoClass, sEquipmentInfoPrototype, NULL);
503 if (_jsSelf != NULL)
504 {
505 if (!JS_SetPrivate(context, _jsSelf, [self retain])) _jsSelf = NULL;
506 }
507 }
508
509 return OBJECT_TO_JSVAL(_jsSelf);
510}
static JSObject * sEquipmentInfoPrototype
static JSClass sEquipmentInfoClass

◆ price

- (OOCreditsQuantity) price

Definition at line 40 of file OOEquipmentType.m.

471{
472 return _price;
473}

◆ provides:

- (BOOL) provides: (NSString *) key

Definition at line 40 of file OOEquipmentType.m.

714 :(NSString *)key
715{
716 return [_provides containsObject:key];
717}

◆ providesForScripting

- (NSArray *) providesForScripting

Definition at line 40 of file OOEquipmentType.m.

709{
710 return [[_provides copy] autorelease];
711}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ repairTime

- (NSUInteger) repairTime

Definition at line 40 of file OOEquipmentType.m.

696{
697 if (_repairTime > 0)
698 {
699 return _repairTime;
700 }
701 else
702 {
703 return _installTime / 2;
704 }
705}

◆ requiredCargoSpace

- (OOCargoQuantity) requiredCargoSpace

Definition at line 40 of file OOEquipmentType.m.

605{
606 return _requiredCargoSpace;
607}

Referenced by ShipAwardEquipment().

+ Here is the caller graph for this function:

◆ requiresAnyEquipment

- (NSSet *) requiresAnyEquipment

Definition at line 40 of file OOEquipmentType.m.

617{
619}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ requiresCleanLegalRecord

- (BOOL) requiresCleanLegalRecord

Definition at line 40 of file OOEquipmentType.m.

495{
496 return _requiresClean;
497}

◆ requiresEmptyPylon

- (BOOL) requiresEmptyPylon

Definition at line 40 of file OOEquipmentType.m.

483{
484 return _requiresEmptyPylon;
485}

◆ requiresEquipment

- (NSSet *) requiresEquipment

Definition at line 40 of file OOEquipmentType.m.

611{
612 return _requiresEquipment;
613}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ requiresFreePassengerBerth

- (BOOL) requiresFreePassengerBerth

Definition at line 40 of file OOEquipmentType.m.

507{
509}

◆ requiresFullFuel

- (BOOL) requiresFullFuel

Definition at line 40 of file OOEquipmentType.m.

513{
514 return _requiresFullFuel;
515}

◆ requiresMountedPylon

- (BOOL) requiresMountedPylon

Definition at line 40 of file OOEquipmentType.m.

489{
491}

◆ requiresNonCleanLegalRecord

- (BOOL) requiresNonCleanLegalRecord

Definition at line 40 of file OOEquipmentType.m.

501{
502 return _requiresNotClean;
503}

◆ requiresNonFullFuel

- (BOOL) requiresNonFullFuel

Definition at line 40 of file OOEquipmentType.m.

519{
521}

◆ reverseEquipmentEnumerator

+ (NSEnumerator *) reverseEquipmentEnumerator

Definition at line 40 of file OOEquipmentType.m.

172{
173 return [sEquipmentTypes reverseObjectEnumerator];
174}

◆ scriptInfo

- (NSDictionary *) scriptInfo

Definition at line 40 of file OOEquipmentType.m.

654{
655 return _scriptInfo;
656}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ scriptName

- (NSString *) scriptName

Definition at line 40 of file OOEquipmentType.m.

660{
661 return _script;
662}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ setDisplayColor:

- (void) setDisplayColor: (OOColor *) newColor

Definition at line 40 of file OOEquipmentType.m.

634 :(OOColor *)color
635{
636 [_displayColor release];
637 _displayColor = [color retain];
638}

Referenced by EquipmentInfoSetProperty().

+ Here is the caller graph for this function:

◆ setMissileRegistryRole:forShip:

+ (void) setMissileRegistryRole: (NSString *) roles
forShip: (NSString *) shipKey 

Definition at line 40 of file OOEquipmentType.m.

146 :(NSString *)role forShip:(NSString *)shipKey
147{
148 NSMutableDictionary *missilesRegistry = [[NSMutableDictionary alloc] initWithDictionary:sMissilesRegistry];
149 if (role != nil && shipKey != nil && ![shipKey isEqualToString:@""])
150 {
151 [missilesRegistry setValue:role forKey:shipKey];
153 sMissilesRegistry = [[NSDictionary alloc] initWithDictionary:missilesRegistry];
154 }
155 DESTROY(missilesRegistry);
156}
static NSDictionary * sMissilesRegistry

◆ suppressClangStuff

- (BOOL) suppressClangStuff
implementation

Definition at line 40 of file OOEquipmentType.m.

817{
818 return !_jsSelf;
819}
struct JSObject * _jsSelf

◆ techLevel

- (OOTechLevelID) techLevel

Definition at line 40 of file OOEquipmentType.m.

465{
466 return _techLevel;
467}

◆ weaponColor

- (OOColor *) weaponColor

Definition at line 40 of file OOEquipmentType.m.

776{
777 return [OOColor brightColorWithDescription:[_weaponInfo objectForKey:@"color"]];
778}
OOColor * brightColorWithDescription:(id description)
Definition OOColor.m:205

◆ weaponDamage

- (GLfloat) weaponDamage

Definition at line 40 of file OOEquipmentType.m.

752{
753 return [_weaponInfo oo_floatForKey:@"damage" defaultValue:15.0];
754}

◆ weaponEnergyUse

- (GLfloat) weaponEnergyUse

Definition at line 40 of file OOEquipmentType.m.

746{
747 return [_weaponInfo oo_floatForKey:@"energy" defaultValue:0.8];
748}

◆ weaponInfo

- (NSDictionary *) weaponInfo

Definition at line 40 of file OOEquipmentType.m.

734{
735 return _weaponInfo;
736}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ weaponRange

- (GLfloat) weaponRange

Definition at line 40 of file OOEquipmentType.m.

740{
741 return [_weaponInfo oo_floatForKey:@"range" defaultValue:12500.0];
742}

Referenced by getWeaponRangeFromType().

+ Here is the caller graph for this function:

◆ weaponRechargeRate

- (GLfloat) weaponRechargeRate

Definition at line 40 of file OOEquipmentType.m.

758{
759 return [_weaponInfo oo_floatForKey:@"recharge_rate" defaultValue:0.5];
760}

◆ weaponShotTemperature

- (GLfloat) weaponShotTemperature

Definition at line 40 of file OOEquipmentType.m.

764{
765 return [_weaponInfo oo_floatForKey:@"shot_temperature" defaultValue:7.0];
766}

◆ weaponThreatAssessment

- (GLfloat) weaponThreatAssessment

Definition at line 40 of file OOEquipmentType.m.

770{
771 return [_weaponInfo oo_floatForKey:@"threat_assessment" defaultValue:1.0];
772}

Referenced by ShipThreatAssessmentWeapon().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _canCarryMultiple

- (unsigned) _canCarryMultiple
private

Definition at line 61 of file OOEquipmentType.h.

◆ _condition_script

- (NSString*) _condition_script
private

Definition at line 78 of file OOEquipmentType.h.

◆ _conditions

- (NSArray*) _conditions
private

Definition at line 71 of file OOEquipmentType.h.

◆ _damageProbability

- (GLfloat) _damageProbability
private

Definition at line 66 of file OOEquipmentType.h.

◆ _defaultActivateKey

- (NSArray*) _defaultActivateKey
private

Definition at line 73 of file OOEquipmentType.h.

◆ _defaultModeKey

- (NSArray*) _defaultModeKey
private

Definition at line 74 of file OOEquipmentType.h.

◆ _description

- (NSString*) _description
private

Definition at line 45 of file OOEquipmentType.h.

◆ _displayColor

- (OOColor*) _displayColor
private

Definition at line 63 of file OOEquipmentType.h.

◆ _fastAffinityA

- (unsigned) _fastAffinityA
private

Definition at line 59 of file OOEquipmentType.h.

◆ _fastAffinityB

- (unsigned) _fastAffinityB
private

Definition at line 60 of file OOEquipmentType.h.

◆ _hideValues

- (unsigned) _hideValues
private

Definition at line 62 of file OOEquipmentType.h.

◆ _identifier

- (NSString*) _identifier
private

Definition at line 44 of file OOEquipmentType.h.

◆ _incompatibleEquipment

- (NSSet*) _incompatibleEquipment
private

Definition at line 70 of file OOEquipmentType.h.

◆ _installTime

- (NSUInteger) _installTime
private

Definition at line 64 of file OOEquipmentType.h.

◆ _isAvailableToAll

- (unsigned) _isAvailableToAll
private

Definition at line 46 of file OOEquipmentType.h.

◆ _isAvailableToNPCs

- (unsigned) _isAvailableToNPCs
private

Definition at line 58 of file OOEquipmentType.h.

◆ _isAvailableToPlayer

- (unsigned) _isAvailableToPlayer
private

Definition at line 57 of file OOEquipmentType.h.

◆ _isMissileOrMine

- (unsigned) _isMissileOrMine
private

Definition at line 55 of file OOEquipmentType.h.

◆ _isVisible

- (unsigned) _isVisible
private

Definition at line 56 of file OOEquipmentType.h.

◆ _jsSelf

- (struct JSObject*) _jsSelf
private

Definition at line 80 of file OOEquipmentType.h.

◆ _name

- (NSString*) _name
private

Definition at line 43 of file OOEquipmentType.h.

◆ _portableBetweenShips

- (unsigned) _portableBetweenShips
private

Definition at line 51 of file OOEquipmentType.h.

◆ _price

- (OOCreditsQuantity) _price
private

Definition at line 42 of file OOEquipmentType.h.

◆ _provides

- (NSArray*) _provides
private

Definition at line 72 of file OOEquipmentType.h.

◆ _repairTime

- (NSUInteger) _repairTime
private

Definition at line 65 of file OOEquipmentType.h.

◆ _requiredCargoSpace

- (OOCargoQuantity) _requiredCargoSpace
private

Definition at line 67 of file OOEquipmentType.h.

◆ _requiresAnyEquipment

- (NSSet*) _requiresAnyEquipment
private

Definition at line 69 of file OOEquipmentType.h.

◆ _requiresClean

- (unsigned) _requiresClean
private

Definition at line 49 of file OOEquipmentType.h.

◆ _requiresEmptyPylon

- (unsigned) _requiresEmptyPylon
private

Definition at line 47 of file OOEquipmentType.h.

◆ _requiresEquipment

- (NSSet*) _requiresEquipment
private

Definition at line 68 of file OOEquipmentType.h.

◆ _requiresFreePassengerBerth

- (unsigned) _requiresFreePassengerBerth
private

Definition at line 52 of file OOEquipmentType.h.

◆ _requiresFullFuel

- (unsigned) _requiresFullFuel
private

Definition at line 53 of file OOEquipmentType.h.

◆ _requiresMountedPylon

- (unsigned) _requiresMountedPylon
private

Definition at line 48 of file OOEquipmentType.h.

◆ _requiresNonFullFuel

- (unsigned) _requiresNonFullFuel
private

Definition at line 54 of file OOEquipmentType.h.

◆ _requiresNotClean

- (unsigned) _requiresNotClean
private

Definition at line 50 of file OOEquipmentType.h.

◆ _script

- (NSString*) _script
private

Definition at line 77 of file OOEquipmentType.h.

◆ _scriptInfo

- (NSDictionary*) _scriptInfo
private

Definition at line 75 of file OOEquipmentType.h.

◆ _techLevel

- (OOTechLevelID) _techLevel
private

Definition at line 41 of file OOEquipmentType.h.

◆ _weaponInfo

- (NSDictionary*) _weaponInfo
private

Definition at line 76 of file OOEquipmentType.h.


The documentation for this class was generated from the following files: