Oolite
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.

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

◆ allEquipmentTypes

+ (NSArray *) allEquipmentTypes

Definition at line 40 of file OOEquipmentType.m.

159{
160 return sEquipmentTypes;
161}

◆ canBeDamaged

- (BOOL) canBeDamaged

Definition at line 40 of file OOEquipmentType.m.

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

◆ canCarryMultiple

- (BOOL) canCarryMultiple

Definition at line 40 of file OOEquipmentType.m.

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

641{
642 return _conditions;
643}
NSArray * _conditions

◆ conditionScript

- (NSString *) conditionScript

Definition at line 40 of file OOEquipmentType.m.

647{
648 return _condition_script;
649}
NSString * _condition_script

◆ copyWithZone:

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

Definition at line 40 of file OOEquipmentType.m.

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

◆ damagedIdentifier

- (NSString *) damagedIdentifier

Definition at line 40 of file OOEquipmentType.m.

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

◆ damageProbability

- (GLfloat) damageProbability

Definition at line 40 of file OOEquipmentType.m.

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

◆ dealloc

- (void) dealloc
implementation

Definition at line 40 of file OOEquipmentType.m.

405{
406 DESTROY(_name);
421
422 [super dealloc];
423}
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.

677{
678 return _defaultActivateKey;
679}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ defaultModeKey

- (NSArray *) defaultModeKey

Definition at line 40 of file OOEquipmentType.m.

683{
684 return _defaultModeKey;
685}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Definition at line 40 of file OOEquipmentType.m.

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

◆ descriptiveText

- (NSString *) descriptiveText

Definition at line 40 of file OOEquipmentType.m.

458{
459 return _description;
460}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ displayColor

- (OOColor *) displayColor

Definition at line 40 of file OOEquipmentType.m.

628{
629 return _displayColor;
630}

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.

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

◆ equipmentEnumerator

+ (NSEnumerator *) equipmentEnumerator

Definition at line 40 of file OOEquipmentType.m.

165{
166 return [sEquipmentTypes objectEnumerator];
167}

◆ equipmentEnumeratorOutfitting

+ (NSEnumerator *) equipmentEnumeratorOutfitting

Definition at line 40 of file OOEquipmentType.m.

177{
178 return [sEquipmentTypesOutfitting objectEnumerator];
179}

◆ equipmentTypeWithIdentifier:

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

Definition at line 40 of file OOEquipmentType.m.

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

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

+ Here is the caller graph for this function:

◆ fastAffinityDefensive

- (BOOL) fastAffinityDefensive

Definition at line 40 of file OOEquipmentType.m.

665{
666 return _fastAffinityA;
667}
unsigned _fastAffinityA

◆ fastAffinityOffensive

- (BOOL) fastAffinityOffensive

Definition at line 40 of file OOEquipmentType.m.

671{
672 return _fastAffinityB;
673}
unsigned _fastAffinityB

◆ fxShieldHitName

- (NSString *) fxShieldHitName

Definition at line 40 of file OOEquipmentType.m.

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

◆ fxShotHitName

- (NSString *) fxShotHitName

Definition at line 40 of file OOEquipmentType.m.

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

◆ fxShotMissName

- (NSString *) fxShotMissName

Definition at line 40 of file OOEquipmentType.m.

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

◆ fxUnshieldedHitName

- (NSString *) fxUnshieldedHitName

Definition at line 40 of file OOEquipmentType.m.

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

◆ fxWeaponLaunchedName

- (NSString *) fxWeaponLaunchedName

Definition at line 40 of file OOEquipmentType.m.

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

◆ getMissileRegistryRoleForShip:

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

Definition at line 40 of file OOEquipmentType.m.

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

◆ hideValues

- (BOOL) hideValues

Definition at line 40 of file OOEquipmentType.m.

586{
587 return _hideValues;
588}

◆ identifier

- (NSString *) identifier

Definition at line 40 of file OOEquipmentType.m.

440{
441 return _identifier;
442}

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.

622{
624}

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.

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

689{
690 return _installTime;
691}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ isAvailableToAll

- (BOOL) isAvailableToAll

Definition at line 40 of file OOEquipmentType.m.

476{
477 return _isAvailableToAll;
478}

◆ isAvailableToNPCs

- (BOOL) isAvailableToNPCs

Definition at line 40 of file OOEquipmentType.m.

598{
599 return _isAvailableToNPCs;
600}

◆ isAvailableToPlayer

- (BOOL) isAvailableToPlayer

Definition at line 40 of file OOEquipmentType.m.

592{
594}

◆ isMiningLaser

- (BOOL) isMiningLaser

Definition at line 40 of file OOEquipmentType.m.

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

◆ isMissileOrMine

- (BOOL) isMissileOrMine

Definition at line 40 of file OOEquipmentType.m.

530{
531 return _isMissileOrMine;
532}

◆ isPortableBetweenShips

- (BOOL) isPortableBetweenShips

Definition at line 40 of file OOEquipmentType.m.

536{
538}

◆ isPrimaryWeapon

- (BOOL) isPrimaryWeapon

Definition at line 40 of file OOEquipmentType.m.

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

◆ isTurretLaser

- (BOOL) isTurretLaser

Definition at line 40 of file OOEquipmentType.m.

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

◆ isVisible

- (BOOL) isVisible

Definition at line 40 of file OOEquipmentType.m.

580{
581 return _isVisible;
582}

◆ 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 NSMutableArray *conditionScripts = nil;
60
61 equipmentData = [UNIVERSE equipmentData];
62
63 [sEquipmentTypes release];
65 equipmentTypes = [NSMutableArray arrayWithCapacity:[equipmentData count]];
66 conditionScripts = [NSMutableArray arrayWithCapacity:[equipmentData count]];
68 equipmentTypesByIdentifier = [NSMutableDictionary dictionaryWithCapacity:[equipmentData count]];
69
70 foreach (itemInfo, equipmentData)
71 {
72 item = [[[OOEquipmentType alloc] initWithInfo:itemInfo] autorelease];
73 if (item != nil)
74 {
75 [equipmentTypes addObject:item];
76 [equipmentTypesByIdentifier setObject:item forKey:[item identifier]];
77 }
78 NSString* condition_script = [item conditionScript];
79 if (condition_script != nil)
80 {
81 if (![conditionScripts containsObject:condition_script])
82 {
83 [conditionScripts addObject:condition_script];
84 }
85 }
86 }
87
88 [[OOCacheManager sharedCache] setObject:conditionScripts forKey:@"equipment conditions" inCache:@"condition scripts"];
89
90 sEquipmentTypes = [equipmentTypes copy];
91 sEquipmentTypesByIdentifier = [[NSDictionary alloc] initWithDictionary:equipmentTypesByIdentifier];
92
93 // same for the outfitting dataset
94 equipmentData = [UNIVERSE equipmentDataOutfitting];
95
96 [sEquipmentTypesOutfitting release];
98
99 equipmentTypes = [NSMutableArray arrayWithCapacity:[equipmentData count]];
100 foreach (itemInfo, equipmentData)
101 {
102 item = [[[OOEquipmentType alloc] initWithInfo:itemInfo] autorelease];
103 if (item != nil)
104 {
105 [equipmentTypes addObject:item];
106 [equipmentTypesByIdentifier setObject:item forKey:[item identifier]];
107 }
108 }
109 sEquipmentTypesOutfitting = [equipmentTypes copy];
110
111}
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.

452{
453 return _name;
454}

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 548 of file OOJSEquipmentInfo.m.

537 :(JSObject *)selfVal
538{
539 if (_jsSelf == selfVal) _jsSelf = NULL;
540}

◆ oo_jsClassName

- (NSString *) oo_jsClassName
implementation

Provided by category OOEquipmentType(OOJavaScriptExtensions).

Definition at line 548 of file OOJSEquipmentInfo.m.

532{
533 return @"EquipmentInfo";
534}

◆ oo_jsValueInContext:

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

Provided by category OOEquipmentType(OOJavaScriptExtensions).

Definition at line 548 of file OOJSEquipmentInfo.m.

516 :(JSContext *)context
517{
518 if (_jsSelf == NULL)
519 {
520 _jsSelf = JS_NewObject(context, &sEquipmentInfoClass, sEquipmentInfoPrototype, NULL);
521 if (_jsSelf != NULL)
522 {
523 if (!JS_SetPrivate(context, _jsSelf, [self retain])) _jsSelf = NULL;
524 }
525 }
526
527 return OBJECT_TO_JSVAL(_jsSelf);
528}
static JSObject * sEquipmentInfoPrototype
static JSClass sEquipmentInfoClass

◆ price

- (OOCreditsQuantity) price

Definition at line 40 of file OOEquipmentType.m.

470{
471 return _price;
472}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ provides:

- (BOOL) provides: (NSString *)  key

Definition at line 40 of file OOEquipmentType.m.

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

◆ providesForScripting

- (NSArray *) providesForScripting

Definition at line 40 of file OOEquipmentType.m.

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

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ repairTime

- (NSUInteger) repairTime

Definition at line 40 of file OOEquipmentType.m.

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

◆ requiredCargoSpace

- (OOCargoQuantity) requiredCargoSpace

Definition at line 40 of file OOEquipmentType.m.

604{
605 return _requiredCargoSpace;
606}

Referenced by ShipAwardEquipment().

+ Here is the caller graph for this function:

◆ requiresAnyEquipment

- (NSSet *) requiresAnyEquipment

Definition at line 40 of file OOEquipmentType.m.

616{
618}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ requiresCleanLegalRecord

- (BOOL) requiresCleanLegalRecord

Definition at line 40 of file OOEquipmentType.m.

494{
495 return _requiresClean;
496}

◆ requiresEmptyPylon

- (BOOL) requiresEmptyPylon

Definition at line 40 of file OOEquipmentType.m.

482{
483 return _requiresEmptyPylon;
484}

◆ requiresEquipment

- (NSSet *) requiresEquipment

Definition at line 40 of file OOEquipmentType.m.

610{
611 return _requiresEquipment;
612}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ requiresFreePassengerBerth

- (BOOL) requiresFreePassengerBerth

Definition at line 40 of file OOEquipmentType.m.

506{
508}

◆ requiresFullFuel

- (BOOL) requiresFullFuel

Definition at line 40 of file OOEquipmentType.m.

512{
513 return _requiresFullFuel;
514}

◆ requiresMountedPylon

- (BOOL) requiresMountedPylon

Definition at line 40 of file OOEquipmentType.m.

488{
490}

◆ requiresNonCleanLegalRecord

- (BOOL) requiresNonCleanLegalRecord

Definition at line 40 of file OOEquipmentType.m.

500{
501 return _requiresNotClean;
502}

◆ requiresNonFullFuel

- (BOOL) requiresNonFullFuel

Definition at line 40 of file OOEquipmentType.m.

518{
520}

◆ reverseEquipmentEnumerator

+ (NSEnumerator *) reverseEquipmentEnumerator

Definition at line 40 of file OOEquipmentType.m.

171{
172 return [sEquipmentTypes reverseObjectEnumerator];
173}

◆ scriptInfo

- (NSDictionary *) scriptInfo

Definition at line 40 of file OOEquipmentType.m.

653{
654 return _scriptInfo;
655}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ scriptName

- (NSString *) scriptName

Definition at line 40 of file OOEquipmentType.m.

659{
660 return _script;
661}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ setDisplayColor:

- (void) setDisplayColor: (OOColor *)  newColor

Definition at line 40 of file OOEquipmentType.m.

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

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.

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

◆ suppressClangStuff

- (BOOL) suppressClangStuff
implementation

Definition at line 40 of file OOEquipmentType.m.

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

◆ techLevel

- (OOTechLevelID) techLevel

Definition at line 40 of file OOEquipmentType.m.

464{
465 return _techLevel;
466}

Referenced by EquipmentInfoSetProperty().

+ Here is the caller graph for this function:

◆ weaponColor

- (OOColor *) weaponColor

Definition at line 40 of file OOEquipmentType.m.

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

◆ weaponDamage

- (GLfloat) weaponDamage

Definition at line 40 of file OOEquipmentType.m.

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

◆ weaponEnergyUse

- (GLfloat) weaponEnergyUse

Definition at line 40 of file OOEquipmentType.m.

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

◆ weaponInfo

- (NSDictionary *) weaponInfo

Definition at line 40 of file OOEquipmentType.m.

733{
734 return _weaponInfo;
735}

Referenced by EquipmentInfoGetProperty().

+ Here is the caller graph for this function:

◆ weaponRange

- (GLfloat) weaponRange

Definition at line 40 of file OOEquipmentType.m.

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

Referenced by getWeaponRangeFromType().

+ Here is the caller graph for this function:

◆ weaponRechargeRate

- (GLfloat) weaponRechargeRate

Definition at line 40 of file OOEquipmentType.m.

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

◆ weaponShotTemperature

- (GLfloat) weaponShotTemperature

Definition at line 40 of file OOEquipmentType.m.

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

◆ weaponThreatAssessment

- (GLfloat) weaponThreatAssessment

Definition at line 40 of file OOEquipmentType.m.

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

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: