Oolite
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 30 of file ShipEntityScriptMethods.h.

Method Documentation

◆ ejectShipOfRole:

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

Extends class ShipEntity.

Definition at line 47 of file ShipEntityScriptMethods.m.

47 :(NSString*)role
48{
49 ShipEntity* item = nil;
50
51 if (role != nil) {
52 item = [[UNIVERSE newShipWithRole:role] autorelease];
53 if (item != nil)
54 [self dumpItem:item];
55 }
56
57 return item;
58}
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 34 of file ShipEntityScriptMethods.m.

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

References ShipEntity::dumpItem:, and nil.

Here is the call graph for this function:

◆ spawnShipsWithRole:count:

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

Extends class ShipEntity.

Definition at line 60 of file ShipEntityScriptMethods.m.

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

References ShipEntity::addTarget:, count, kOOLogNoteAddShips, nil, OOLog, Entity::owner, ShipEntity::primaryTarget, ShipEntity::randomEjectaTemperature, Entity::rootShipEntity, ShipEntity::setIsMissileFlag:, ShipEntity::setOwner:, and ShipEntity::setTemperature:.

Here is the call graph for this function:

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