Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOShipLibraryDescriptions.m
Go to the documentation of this file.
1/*
2
3OOShipLibraryDescriptions.m
4
5Oolite
6Copyright (C) 2004-2013 Giles C Williams and contributors
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21MA 02110-1301, USA.
22
23*/
24
26#import "OOStringExpander.h"
27#import "Universe.h"
28
29NSString *OOShipLibraryCategorySingular(NSString *category)
30{
31 return OOExpandKey(OOExpand(@"oolite-ship-library-category-[category]", category));
32}
33
34
35NSString *OOShipLibraryCategoryPlural(NSString *category)
36{
37 return OOExpandKey(OOExpand(@"oolite-ship-library-category-plural-[category]", category));
38}
39
40
41NSString *OOShipLibrarySpeed (ShipEntity *demo_ship)
42{
43 GLfloat param = [demo_ship maxFlightSpeed];
44 NSString *result = nil;
45 if (param <= 1)
46 {
47 result = DESC(@"oolite-ship-library-speed-stationary");
48 }
49 else if (param <= 150)
50 {
51 result = DESC(@"oolite-ship-library-speed-veryslow");
52 }
53 else if (param <= 250)
54 {
55 result = DESC(@"oolite-ship-library-speed-slow");
56 }
57 else if (param <= 325)
58 {
59 result = DESC(@"oolite-ship-library-speed-average");
60 }
61 else if (param <= 425)
62 {
63 result = DESC(@"oolite-ship-library-speed-fast");
64 }
65 else
66 {
67 result = DESC(@"oolite-ship-library-speed-veryfast");
68 }
69 return result;
70}
71
72
73NSString *OOShipLibraryTurnRate (ShipEntity *demo_ship)
74{
75 GLfloat param = [demo_ship maxFlightRoll] + (2*[demo_ship maxFlightPitch]);
76 NSString *result = nil;
77 if (param <= 2)
78 {
79 result = DESC(@"oolite-ship-library-turn-veryslow");
80 }
81 else if (param <= 2.75)
82 {
83 result = DESC(@"oolite-ship-library-turn-slow");
84 }
85 else if (param <= 4.5)
86 {
87 result = DESC(@"oolite-ship-library-turn-average");
88 }
89 else if (param <= 6)
90 {
91 result = DESC(@"oolite-ship-library-turn-fast");
92 }
93 else
94 {
95 result = DESC(@"oolite-ship-library-turn-veryfast");
96 }
97 return result;
98}
99
100
101NSString *OOShipLibraryCargo (ShipEntity *demo_ship)
102{
103 OOCargoQuantity param = [demo_ship maxAvailableCargoSpace];
104 NSString *result = nil;
105 if (param == 0)
106 {
107 result = DESC(@"oolite-ship-library-cargo-none");
108 }
109 else
110 {
111 result = [NSString stringWithFormat:DESC(@"oolite-ship-library-cargo-carried-u"),param];
112 }
113 return result;
114}
115
116
117NSString *OOShipLibraryGenerator (ShipEntity *demo_ship)
118{
119 float rate = [demo_ship energyRechargeRate];
120 NSString *result = nil;
121 if (rate < 2.5)
122 {
123 result = DESC(@"oolite-ship-library-generator-weak");
124 }
125 else if (rate < 3.75)
126 {
127 result = DESC(@"oolite-ship-library-generator-average");
128 }
129 else
130 {
131 result = DESC(@"oolite-ship-library-generator-strong");
132 }
133 return result;
134}
135
136
137NSString *OOShipLibraryShields (ShipEntity *demo_ship)
138{
139 // when NPCs have actual shields, add those on as well
140 float shields = [demo_ship maxEnergy];
141 NSString *result = nil;
142 if (shields < 128)
143 {
144 result = DESC(@"oolite-ship-library-shields-veryweak");
145 }
146 else if (shields < 192)
147 {
148 result = DESC(@"oolite-ship-library-shields-weak");
149 }
150 else if (shields < 256)
151 {
152 result = DESC(@"oolite-ship-library-shields-average");
153 }
154 else if (shields < 320)
155 {
156 result = DESC(@"oolite-ship-library-shields-strong");
157 }
158 else
159 {
160 result = DESC(@"oolite-ship-library-shields-verystrong");
161 }
162 return result;
163}
164
165
167{
168 if ([demo_ship hasHyperspaceMotor])
169 {
170 return DESC(@"oolite-ship-library-witchspace-yes");
171 }
172 else
173 {
174 return DESC(@"oolite-ship-library-witchspace-no");
175 }
176}
177
178
179NSString *OOShipLibraryWeapons (ShipEntity *demo_ship)
180{
181 OOWeaponFacingSet facings = [demo_ship weaponFacings];
182 NSUInteger fixed = (facings&1)+(facings&2)/2+(facings&4)/4+(facings&8)/8;
183 NSUInteger pylons = [demo_ship missileCapacity];
184 if (fixed == 0 && pylons == 0)
185 {
186 return DESC(@"oolite-ship-library-weapons-none");
187 }
188 return [NSString stringWithFormat:DESC(@"oolite-ship-library-weapons-u-u"),fixed,pylons];
189}
190
191
192NSString *OOShipLibraryTurrets (ShipEntity *demo_ship)
193{
194 NSUInteger turretCount = [demo_ship turretCount];
195 if (turretCount > 0)
196 {
197 return [NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-u"), turretCount];
198 }
199 else
200 {
201 return @"";
202 }
203}
204
205
206NSString *OOShipLibrarySize (ShipEntity *demo_ship)
207{
208 BoundingBox bb = [demo_ship totalBoundingBox];
209 return [NSString stringWithFormat:DESC(@"oolite-ship-library-size-u-u-u"),(unsigned)(bb.max.x-bb.min.x),(unsigned)(bb.max.y-bb.min.y),(unsigned)(bb.max.z-bb.min.z)];
210}
return nil
NSString * OOShipLibraryCategorySingular(NSString *category)
NSString * OOShipLibraryWitchspace(ShipEntity *demo_ship)
NSString * OOShipLibraryTurrets(ShipEntity *demo_ship)
NSString * OOShipLibraryShields(ShipEntity *demo_ship)
NSString * OOShipLibraryCargo(ShipEntity *demo_ship)
NSString * OOShipLibraryCategoryPlural(NSString *category)
NSString * OOShipLibraryGenerator(ShipEntity *demo_ship)
NSString * OOShipLibrarySize(ShipEntity *demo_ship)
NSString * OOShipLibrarySpeed(ShipEntity *demo_ship)
NSString * OOShipLibraryWeapons(ShipEntity *demo_ship)
NSString * OOShipLibraryTurnRate(ShipEntity *demo_ship)
#define OOExpandKey(key,...)
#define OOExpand(string,...)
uint8_t OOWeaponFacingSet
Definition OOTypes.h:237
uint32_t OOCargoQuantity
Definition OOTypes.h:176
#define DESC(key)
Definition Universe.h:846
GLfloat maxEnergy
Definition Entity.h:143
NSUInteger turretCount()
GLfloat maxFlightRoll()
BoundingBox totalBoundingBox
Definition ShipEntity.h:213
NSUInteger missileCapacity()
float energyRechargeRate()
OOWeaponFacingSet weaponFacings()
OOCargoQuantity maxAvailableCargoSpace()
GLfloat maxFlightSpeed
Definition ShipEntity.h:239
GLfloat maxFlightPitch()