Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
StationEntity(OOPrivate) Category Reference

Instance Methods

(void) - pullInShipIfPermitted:
 
(void) - addShipToStationCount:
 
(void) - addShipToLaunchQueue:withPriority:
 
(unsigned) - countOfShipsInLaunchQueueWithPrimaryRole:
 
(NSDictionary *) - holdPositionInstructionForShip:
 

Detailed Description

Definition at line 53 of file StationEntity.m.

Method Documentation

◆ addShipToLaunchQueue:withPriority:

- (void) addShipToLaunchQueue: (ShipEntity *) ship
withPriority: (BOOL) priority 

Extends class StationEntity.

Definition at line 448 of file StationEntity.m.

1095 :(ShipEntity *)ship withPriority:(BOOL)priority
1096{
1097 NSEnumerator *subEnum = nil;
1098 DockEntity *sub = nil;
1099 unsigned threshold = 0;
1100
1101 // quickest launch if we assign ships to those bays with no incoming ships
1102 // and spread the ships evenly around those bays
1103 // much easier if the station has at least one launch-only dock
1104 while (threshold < 16)
1105 {
1106 for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
1107 {
1108 if (sub != player_reserved_dock)
1109 {
1110 if ([sub countOfShipsInDockingQueue] == 0)
1111 {
1112 if ([sub allowsLaunching] && [sub countOfShipsInLaunchQueue] <= threshold)
1113 {
1114 if ([sub allowsLaunchingOf:ship])
1115 {
1116 [sub addShipToLaunchQueue:ship withPriority:priority];
1117 return;
1118 }
1119 }
1120 }
1121 }
1122 }
1123 threshold++;
1124 }
1125 // if we get this far, all docks have at least some incoming traffic.
1126 // usually most efficient (since launching is far faster than docking)
1127 // to assign all ships to the *same* dock with the smallest incoming queue
1128 // rather than to try spreading them out across several queues
1129 // also stops escorts being launched before their mothership
1130 threshold = 0;
1131 while (threshold < 16)
1132 {
1133 for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
1134 {
1135 /* so this time as long as it allows launching only check
1136 * the docking queue size so long as enumerator order is
1137 * deterministic, this will assign every launch this
1138 * update to the same dock (edge case where new docking
1139 * ship appears in the middle, probably not a problem) */
1140 if ([sub allowsLaunching] && [sub countOfShipsInDockingQueue] <= threshold)
1141 {
1142 if ([sub allowsLaunchingOf:ship])
1143 {
1144 [sub addShipToLaunchQueue:ship withPriority:priority];
1145 return;
1146 }
1147 }
1148
1149 }
1150 threshold++;
1151 }
1152
1153 OOLog(@"station.launchShip.failed", @"Cancelled launch for a %@ with role %@, as the %@ has too many ships in its launch queue(s) or no suitable launch docks.",
1154 [ship displayName], [ship primaryRole], [self displayName]);
1155}
#define OOLog(class, format,...)
Definition OOLogging.h:88
return nil
void addShipToLaunchQueue:withPriority:(ShipEntity *ship,[withPriority] BOOL priority)
Definition DockEntity.m:865

◆ addShipToStationCount:

- (void) addShipToStationCount: (ShipEntity *) ship

Extends class StationEntity.

Definition at line 448 of file StationEntity.m.

1248 :(ShipEntity *) ship
1249{
1250 if ([ship isShuttle]) docked_shuttles++;
1251 else if ([ship isTrader] && ![ship isPlayer]) docked_traders++;
1252 else if (([ship isPolice] && ![ship isEscort]) || [ship hasPrimaryRole:@"defense_ship"])
1253 {
1254 if (0 < defenders_launched) defenders_launched--;
1255 }
1256 else if ([ship hasPrimaryRole:@"scavenger"] || [ship hasPrimaryRole:@"miner"]) // treat miners and scavengers alike!
1257 {
1258 if (0 < scavengers_launched) scavengers_launched--;
1259 }
1260}

◆ countOfShipsInLaunchQueueWithPrimaryRole:

- (unsigned) countOfShipsInLaunchQueueWithPrimaryRole: (NSString *) role

Extends class StationEntity.

Definition at line 448 of file StationEntity.m.

1158 :(NSString *)role
1159{
1160 unsigned result = 0;
1161 NSEnumerator *subEnum = nil;
1162 DockEntity* sub = nil;
1163 for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); )
1164 {
1165 result += [sub countOfShipsInLaunchQueueWithPrimaryRole:role];
1166 }
1167 return result;
1168}

◆ holdPositionInstructionForShip:

- (NSDictionary *) holdPositionInstructionForShip: (ShipEntity *) ship

Extends class StationEntity.

Definition at line 448 of file StationEntity.m.

591 :(ShipEntity *)ship
592{
593 if (![_shipsOnHold containsObject:ship])
594 {
595 [self sendExpandedMessage:@"[station-acknowledges-hold-position]" toShip:ship];
596 [_shipsOnHold addObject:ship];
597 }
598
599 return OOMakeDockingInstructions(self, [ship position], 0, 100, @"HOLD_POSITION", nil, NO, -1);
600}
NSDictionary * OOMakeDockingInstructions(StationEntity *station, HPVector coords, float speed, float range, NSString *ai_message, NSString *comms_message, BOOL match_rotation, int docking_stage)

◆ pullInShipIfPermitted:

- (void) pullInShipIfPermitted: (ShipEntity *) ship

Extends class StationEntity.

Definition at line 448 of file StationEntity.m.

831 :(ShipEntity *)ship
832{
833 [ship enterDock:self]; // dock performs permitted checks
834}
void enterDock:(StationEntity *station)

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