The number of turrets on a ship, if they exist, is now shown on the Ship Library screen.

master
AnotherCommander 2020-07-16 13:07:40 +02:00
parent 4b32de3a9f
commit 94d89fdd55
7 changed files with 51 additions and 14 deletions

View File

@ -1142,6 +1142,9 @@
"oolite-ship-library-weapons-custom" = "Weapons: %@";
"oolite-ship-library-weapons-none" = "Weapons: None";
"oolite-ship-library-weapons-u-u" = "Weapons: %u fixed, %u pylons";
"oolite-ship-library-turrets-custom" = "Turrets: %@";
"oolite-ship-library-turrets-u" = "Turrets: %u";
"oolite-ship-library-size-custom" = "Size: %@";
"oolite-ship-library-size-u-u-u" = "Size: %um x %um x %um";

View File

@ -769,6 +769,8 @@ typedef enum
- (uint8_t) maxEscortCount;
- (void) setMaxEscortCount:(uint8_t)newCount;
- (NSUInteger) turretCount;
- (NSString *) name;
- (NSString *) shipUniqueName;
- (NSString *) shipClassName;

View File

@ -7024,6 +7024,22 @@ static GLfloat scripted_color[4] = { 0.0, 0.0, 0.0, 0.0}; // to be defined by s
}
- (NSUInteger) turretCount
{
NSUInteger count = 0;
NSEnumerator *subEnum = [self shipSubEntityEnumerator];
ShipEntity *se = nil;
while ((se = [subEnum nextObject]))
{
if ([se isTurret])
{
count ++;
}
}
return count;
}
- (Entity*) proximityAlert
{
Entity* prox = [_proximityAlert weakRefUnderlyingObject];

View File

@ -39,6 +39,7 @@ static NSString * const kOODemoShipGenerator = @"generator";
static NSString * const kOODemoShipShields = @"shields";
static NSString * const kOODemoShipWitchspace = @"witchspace";
static NSString * const kOODemoShipWeapons = @"weapons";
static NSString * const kOODemoShipTurrets = @"turrets";
static NSString * const kOODemoShipSize = @"size";
static NSString * const kOODemoShipConditions = @"condition_script";
@ -52,4 +53,5 @@ NSString *OOShipLibraryGenerator (ShipEntity *demo_ship);
NSString *OOShipLibraryShields (ShipEntity *demo_ship);
NSString *OOShipLibraryWitchspace (ShipEntity *demo_ship);
NSString *OOShipLibraryWeapons (ShipEntity *demo_ship);
NSString *OOShipLibraryTurrets (ShipEntity *demo_ship);
NSString *OOShipLibrarySize (ShipEntity *demo_ship);

View File

@ -189,6 +189,13 @@ NSString *OOShipLibraryWeapons (ShipEntity *demo_ship)
}
NSString *OOShipLibraryTurrets (ShipEntity *demo_ship)
{
NSUInteger turretCount = [demo_ship turretCount];
return turretCount > 0 ? [NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-u"), turretCount] : @"";
}
NSString *OOShipLibrarySize (ShipEntity *demo_ship)
{
BoundingBox bb = [demo_ship totalBoundingBox];

View File

@ -4153,18 +4153,10 @@ static JSBool ShipThreatAssessment(JSContext *context, uintN argc, jsval *vp)
}
/* Turret count is public knowledge */
NSEnumerator *subEnum = [thisEnt shipSubEntityEnumerator];
ShipEntity *se = nil;
while ((se = [subEnum nextObject]))
{
if ([se isTurret])
{
/* TODO: consider making ship combat behaviour try to
* stay at long range from enemies with turrets. Then
* we could perhaps reduce this bonus a bit. */
assessment += 1;
}
}
/* TODO: consider making ship combat behaviour try to
* stay at long range from enemies with turrets. Then
* we could perhaps reduce this bonus a bit. */
assessment += [thisEnt turretCount];
if (fullCheck)
{

View File

@ -3019,7 +3019,7 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
[gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:4];
/* Row 4: weapons, size */
/* Row 4: weapons, turrets, size */
override = [librarySettings oo_stringForKey:kOODemoShipWeapons defaultValue:nil];
if (override != nil)
{
@ -3037,7 +3037,22 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
field1 = OOShipLibraryWeapons(demo_ship);
}
field2 = @"";
override = [librarySettings oo_stringForKey:kOODemoShipTurrets defaultValue:nil];
if (override != nil)
{
if ([override length] == 0)
{
field2 = @"";
}
else
{
field2 = [NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-custom"),OOExpand(override)];
}
}
else
{
field2 = OOShipLibraryTurrets(demo_ship);
}
override = [librarySettings oo_stringForKey:kOODemoShipSize defaultValue:nil];
if (override != nil)