Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
ShipEntity(ScriptMethods) Category Reference

#include <ShipEntityScriptMethods.h>

Instance Methods

(ShipEntity *) - ejectShipOfType:
 
(ShipEntity *) - ejectShipOfRole:
 
(NSArray *) - spawnShipsWithRole:count:
 

Detailed Description

Definition at line 31 of file ShipEntityScriptMethods.h.

Method Documentation

◆ ejectShipOfRole:

- (ShipEntity *) ejectShipOfRole: (NSString *) role

Extends class ShipEntity.

Definition at line 31 of file ShipEntityScriptMethods.m.

50 :(NSString *)role
51{
52 ShipEntity *item = nil;
53
54 if (role != nil)
55 {
56 item = [[UNIVERSE newShipWithRole:role] autorelease];
57 if (item != nil) [self dumpItem:item];
58 }
59
60 return item;
61}
return nil

References ShipEntity::dumpItem:, and nil.

+ Here is the call graph for this function:

◆ ejectShipOfType:

- (ShipEntity *) ejectShipOfType: (NSString *) shipKey

Extends class ShipEntity.

Definition at line 31 of file ShipEntityScriptMethods.m.

36 :(NSString *)shipKey
37{
38 ShipEntity *item = nil;
39
40 if (shipKey != nil)
41 {
42 item = [[UNIVERSE newShipWithName:shipKey] autorelease];
43 if (item != nil) [self dumpItem:item];
44 }
45
46 return item;
47}

◆ spawnShipsWithRole:count:

- (NSArray *) spawnShipsWithRole: (NSString *) role
count: (NSUInteger) count 

Extends class ShipEntity.

Definition at line 31 of file ShipEntityScriptMethods.m.

64 :(NSString *)role count:(NSUInteger)count
65{
66 ShipEntity *ship = [self rootShipEntity]; // FIXME: (EMMSTRAN) implement an -absolutePosition method, use that in spawnShipWithRole:near:, and use self instead of root.
67 ShipEntity *spawned = nil;
68 NSMutableArray *result = nil;
69
70 if (count == 0) return [NSArray array];
71
72 OOLog(kOOLogNoteAddShips, @"Spawning %ld x '%@' near %@ %d", count, role, [self shortDescription], [self universalID]);
73
74 result = [NSMutableArray arrayWithCapacity:count];
75
76 do
77 {
78 spawned = [UNIVERSE spawnShipWithRole:role near:ship];
79 if (spawned != nil)
80 {
81 [spawned setTemperature:[self randomEjectaTemperature]];
82 if ([self isMissileFlagSet] && [[spawned shipInfoDictionary] oo_boolForKey:@"is_submunition"])
83 {
84 [spawned setOwner:[self owner]];
85 [spawned addTarget:[self primaryTarget]];
86 [spawned setIsMissileFlag:YES];
87 }
88 [result addObject:spawned];
89 }
90 }
91 while (--count);
92
93 return result;
94}
#define OOLog(class, format,...)
Definition OOLogging.h:88
unsigned count
static NSString *const kOOLogNoteAddShips
void addTarget:(Entity *targetEntity)
void setTemperature:(GLfloat value)
void setIsMissileFlag:(BOOL newValue)
void setOwner:(Entity *who_owns_entity)

The documentation for this category was generated from the following files: