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