Oolite
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
34NSString* OOShipLibraryCategoryPlural(NSString* category)
35{
36 return OOExpandKey(OOExpand(@"oolite-ship-library-category-plural-[category]", category));
37}
38
39NSString* OOShipLibrarySpeed(ShipEntity* demo_ship)
40{
41 GLfloat param = [demo_ship maxFlightSpeed];
42 NSString* result = nil;
43 if (param <= 1) {
44 result = DESC(@"oolite-ship-library-speed-stationary");
45 } else if (param <= 150) {
46 result = DESC(@"oolite-ship-library-speed-veryslow");
47 } else if (param <= 250) {
48 result = DESC(@"oolite-ship-library-speed-slow");
49 } else if (param <= 325) {
50 result = DESC(@"oolite-ship-library-speed-average");
51 } else if (param <= 425) {
52 result = DESC(@"oolite-ship-library-speed-fast");
53 } else {
54 result = DESC(@"oolite-ship-library-speed-veryfast");
55 }
56 return result;
57}
58
59NSString* OOShipLibraryTurnRate(ShipEntity* demo_ship)
60{
61 GLfloat param = [demo_ship maxFlightRoll] + (2 * [demo_ship maxFlightPitch]);
62 NSString* result = nil;
63 if (param <= 2) {
64 result = DESC(@"oolite-ship-library-turn-veryslow");
65 } else if (param <= 2.75) {
66 result = DESC(@"oolite-ship-library-turn-slow");
67 } else if (param <= 4.5) {
68 result = DESC(@"oolite-ship-library-turn-average");
69 } else if (param <= 6) {
70 result = DESC(@"oolite-ship-library-turn-fast");
71 } else {
72 result = DESC(@"oolite-ship-library-turn-veryfast");
73 }
74 return result;
75}
76
77NSString* OOShipLibraryCargo(ShipEntity* demo_ship)
78{
79 OOCargoQuantity param = [demo_ship maxAvailableCargoSpace];
80 NSString* result = nil;
81 if (param == 0) {
82 result = DESC(@"oolite-ship-library-cargo-none");
83 } else {
84 result = [NSString stringWithFormat:DESC(@"oolite-ship-library-cargo-carried-u"), param];
85 }
86 return result;
87}
88
90{
91 float rate = [demo_ship energyRechargeRate];
92 NSString* result = nil;
93 if (rate < 2.5) {
94 result = DESC(@"oolite-ship-library-generator-weak");
95 } else if (rate < 3.75) {
96 result = DESC(@"oolite-ship-library-generator-average");
97 } else {
98 result = DESC(@"oolite-ship-library-generator-strong");
99 }
100 return result;
101}
102
103NSString* OOShipLibraryShields(ShipEntity* demo_ship)
104{
105 // when NPCs have actual shields, add those on as well
106 float shields = [demo_ship maxEnergy];
107 NSString* result = nil;
108 if (shields < 128) {
109 result = DESC(@"oolite-ship-library-shields-veryweak");
110 } else if (shields < 192) {
111 result = DESC(@"oolite-ship-library-shields-weak");
112 } else if (shields < 256) {
113 result = DESC(@"oolite-ship-library-shields-average");
114 } else if (shields < 320) {
115 result = DESC(@"oolite-ship-library-shields-strong");
116 } else {
117 result = DESC(@"oolite-ship-library-shields-verystrong");
118 }
119 return result;
120}
121
123{
124 if ([demo_ship hasHyperspaceMotor]) {
125 return DESC(@"oolite-ship-library-witchspace-yes");
126 } else {
127 return DESC(@"oolite-ship-library-witchspace-no");
128 }
129}
130
131NSString* OOShipLibraryWeapons(ShipEntity* demo_ship)
132{
133 OOWeaponFacingSet facings = [demo_ship weaponFacings];
134 NSUInteger fixed = (facings & 1) + (facings & 2) / 2 + (facings & 4) / 4 + (facings & 8) / 8;
135 NSUInteger pylons = [demo_ship missileCapacity];
136 if (fixed == 0 && pylons == 0) {
137 return DESC(@"oolite-ship-library-weapons-none");
138 }
139 return [NSString stringWithFormat:DESC(@"oolite-ship-library-weapons-u-u"), fixed, pylons];
140}
141
142NSString* OOShipLibraryTurrets(ShipEntity* demo_ship)
143{
144 NSUInteger turretCount = [demo_ship turretCount];
145 if (turretCount > 0) {
146 return [NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-u"), turretCount];
147 } else {
148 return @"";
149 }
150}
151
152NSString* OOShipLibrarySize(ShipEntity* demo_ship)
153{
154 BoundingBox bb = [demo_ship totalBoundingBox];
155 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)];
156}
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:204
uint32_t OOCargoQuantity
Definition OOTypes.h:155
#define DESC(key)
Definition Universe.h:832
GLfloat maxEnergy
Definition Entity.m:763
NSUInteger turretCount()
GLfloat maxFlightRoll()
BoundingBox totalBoundingBox
NSUInteger missileCapacity()
float energyRechargeRate()
OOWeaponFacingSet weaponFacings()
OOCargoQuantity maxAvailableCargoSpace()
GLfloat maxFlightSpeed
GLfloat maxFlightPitch()