Line data Source code
1 0 : /* 2 : 3 : StationEntity.h 4 : 5 : ShipEntity subclass representing a space station or dockable ship. 6 : 7 : Oolite 8 : Copyright (C) 2004-2013 Giles C Williams and contributors 9 : 10 : This program is free software; you can redistribute it and/or 11 : modify it under the terms of the GNU General Public License 12 : as published by the Free Software Foundation; either version 2 13 : of the License, or (at your option) any later version. 14 : 15 : This program is distributed in the hope that it will be useful, 16 : but WITHOUT ANY WARRANTY; without even the implied warranty of 17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 : GNU General Public License for more details. 19 : 20 : You should have received a copy of the GNU General Public License 21 : along with this program; if not, write to the Free Software 22 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 : MA 02110-1301, USA. 24 : 25 : */ 26 : 27 : #import "ShipEntity.h" 28 : #import "OOJSInterfaceDefinition.h" 29 : #import "Universe.h" 30 : 31 : @class OOWeakSet; 32 : 33 : 34 0 : typedef enum 35 : { 36 : STATION_ALERT_LEVEL_GREEN = ALERT_CONDITION_GREEN, 37 : STATION_ALERT_LEVEL_YELLOW = ALERT_CONDITION_YELLOW, 38 : STATION_ALERT_LEVEL_RED = ALERT_CONDITION_RED 39 : } OOStationAlertLevel; 40 : 41 0 : #define STATION_MAX_POLICE 8 42 : 43 0 : #define STATION_DELAY_BETWEEN_LAUNCHES 6.0 44 : 45 0 : #define STATION_LAUNCH_RETRY_INTERVAL 2.0 46 : 47 0 : #define MAX_DOCKING_STAGES 16 48 : 49 0 : #define DOCKING_CLEARANCE_WINDOW 126.0 50 : 51 : 52 0 : @interface StationEntity: ShipEntity 53 : { 54 : @private 55 0 : OOWeakSet *_shipsOnHold; 56 0 : DockEntity *player_reserved_dock; 57 0 : double last_launch_time; 58 0 : double approach_spacing; 59 0 : OOStationAlertLevel alertLevel; 60 : 61 0 : unsigned max_police; // max no. of police ships allowed 62 0 : unsigned max_defense_ships; // max no. of defense ships allowed 63 0 : unsigned defenders_launched; 64 : 65 0 : unsigned max_scavengers; // max no. of scavenger ships allowed 66 0 : unsigned scavengers_launched; 67 : 68 0 : OOTechLevelID equivalentTechLevel; 69 0 : float equipmentPriceFactor; 70 : 71 0 : Vector port_dimensions; 72 0 : double port_radius; 73 : 74 0 : unsigned no_docking_while_launching: 1, 75 0 : hasNPCTraffic: 1; 76 0 : BOOL hasPatrolShips; 77 : 78 0 : OOUniversalID planet; 79 : 80 0 : NSString *allegiance; 81 : 82 0 : OOCommodityMarket *localMarket; 83 0 : OOCargoQuantity marketCapacity; 84 0 : NSArray *marketDefinition; 85 0 : NSString *marketScriptName; 86 : // NSMutableArray *localPassengers; 87 : // NSMutableArray *localContracts; 88 0 : NSMutableArray *localShipyard; 89 : 90 0 : NSMutableDictionary *localInterfaces; 91 : 92 0 : unsigned docked_shuttles; 93 0 : double last_shuttle_launch_time; 94 0 : double shuttle_launch_interval; 95 : 96 0 : unsigned docked_traders; 97 0 : double last_trader_launch_time; 98 0 : double trader_launch_interval; 99 : 100 0 : double last_patrol_report_time; 101 0 : double patrol_launch_interval; 102 : 103 0 : unsigned suppress_arrival_reports: 1, 104 0 : requiresDockingClearance: 1, 105 0 : interstellarUndockingAllowed: 1, 106 0 : allowsFastDocking: 1, 107 0 : allowsSaving: 1, 108 0 : allowsAutoDocking: 1, 109 0 : hasBreakPattern: 1, 110 0 : marketMonitored: 1, 111 0 : marketBroadcast: 1; 112 : } 113 : 114 : 115 0 : - (OOCargoQuantity) marketCapacity; 116 0 : - (NSArray *) marketDefinition; 117 0 : - (NSString *) marketScriptName; 118 0 : - (BOOL) marketMonitored; 119 0 : - (BOOL) marketBroadcast; 120 0 : - (OOCreditsQuantity) legalStatusOfManifest:(OOCommodityMarket *)manifest export:(BOOL)export; 121 : 122 0 : - (OOCommodityMarket *) localMarket; 123 0 : - (void) setLocalMarket:(NSArray *)market; 124 0 : - (NSDictionary *) localMarketForScripting; 125 0 : - (void) setPrice:(OOCreditsQuantity) price forCommodity:(OOCommodityType) commodity; 126 0 : - (void) setQuantity:(OOCargoQuantity) quantity forCommodity:(OOCommodityType) commodity; 127 : 128 : /*- (NSMutableArray *) localPassengers; 129 : - (void) setLocalPassengers:(NSArray *)market; 130 : - (NSMutableArray *) localContracts; 131 : - (void) setLocalContracts:(NSArray *)market; */ 132 0 : - (NSMutableArray *) localShipyard; 133 0 : - (void) setLocalShipyard:(NSArray *)market; 134 0 : - (void) generateShipyard; 135 0 : - (void) generateShipyard:(OOTechLevelID)stationTechLevel; 136 0 : - (NSMutableDictionary *) localInterfaces; 137 0 : - (void) setInterfaceDefinition:(OOJSInterfaceDefinition *)definition forKey:(NSString *)key; 138 : 139 0 : - (OOCommodityMarket *) initialiseLocalMarket; 140 : 141 0 : - (OOTechLevelID) equivalentTechLevel; 142 0 : - (void) setEquivalentTechLevel:(OOTechLevelID)value; 143 : 144 0 : - (NSEnumerator *) dockSubEntityEnumerator; 145 0 : - (Vector) virtualPortDimensions; 146 0 : - (DockEntity*) playerReservedDock; 147 : 148 0 : - (HPVector) beaconPosition; 149 : 150 0 : - (float) equipmentPriceFactor; 151 : 152 0 : - (void) setPlanet:(OOPlanetEntity *)planet; 153 : 154 0 : - (OOPlanetEntity *) planet; 155 : 156 0 : - (void) setAllegiance:(NSString *)newAllegiance; 157 0 : - (NSString *)allegiance; 158 : 159 0 : - (unsigned) countOfDockedContractors; 160 0 : - (unsigned) countOfDockedPolice; 161 0 : - (unsigned) countOfDockedDefenders; 162 : 163 0 : - (void) sanityCheckShipsOnApproach; 164 : 165 0 : - (void) autoDockShipsOnApproach; 166 : 167 0 : - (Vector) portUpVectorForShip:(ShipEntity *)ship; 168 : 169 0 : - (NSDictionary *) dockingInstructionsForShip:(ShipEntity *)ship; 170 : 171 0 : - (BOOL) shipIsInDockingCorridor:(ShipEntity *)ship; 172 : 173 0 : - (BOOL) dockingCorridorIsEmpty; 174 : 175 0 : - (void) clearDockingCorridor; 176 : 177 0 : - (void) clear; 178 : 179 : 180 0 : - (void) abortAllDockings; 181 : 182 0 : - (void) abortDockingForShip:(ShipEntity *)ship; 183 : 184 0 : - (BOOL) hasMultipleDocks; 185 0 : - (BOOL) hasClearDock; 186 0 : - (BOOL) hasLaunchDock; 187 0 : - (DockEntity *) selectDockForDocking; 188 0 : - (unsigned) currentlyInLaunchingQueues; 189 0 : - (unsigned) currentlyInDockingQueues; 190 : 191 : 192 0 : - (void) launchShip:(ShipEntity *)ship; 193 : 194 0 : - (ShipEntity *) launchIndependentShip:(NSString *)role; 195 : 196 0 : - (void) noteDockedShip:(ShipEntity *)ship; 197 : 198 0 : - (BOOL) interstellarUndockingAllowed; 199 0 : - (BOOL) hasNPCTraffic; 200 0 : - (void) setHasNPCTraffic:(BOOL)flag; 201 : 202 0 : - (OOStationAlertLevel) alertLevel; 203 0 : - (void) setAlertLevel:(OOStationAlertLevel)level signallingScript:(BOOL)signallingScript; 204 : 205 : ////////////////////////////////////////////////////////////// AI methods... 206 : 207 0 : - (void) increaseAlertLevel; 208 0 : - (void) decreaseAlertLevel; 209 : 210 0 : - (NSArray *) launchPolice; 211 0 : - (ShipEntity *) launchDefenseShip; 212 0 : - (ShipEntity *) launchScavenger; 213 0 : - (ShipEntity *) launchMiner; 214 : /**Lazygun** added the following line*/ 215 1 : - (ShipEntity *) launchPirateShip; 216 0 : - (ShipEntity *) launchShuttle; 217 0 : - (ShipEntity *) launchEscort; 218 0 : - (ShipEntity *) launchPatrol; 219 : 220 0 : - (void) launchShipWithRole:(NSString *)role; 221 : 222 0 : - (void) acceptPatrolReportFrom:(ShipEntity *)patrol_ship; 223 : 224 0 : - (NSString *) acceptDockingClearanceRequestFrom:(ShipEntity *)other; 225 0 : - (BOOL) requiresDockingClearance; 226 0 : - (void) setRequiresDockingClearance:(BOOL)newValue; 227 : 228 0 : - (BOOL) allowsFastDocking; 229 0 : - (void) setAllowsFastDocking:(BOOL)newValue; 230 : 231 0 : - (BOOL) allowsAutoDocking; 232 0 : - (void) setAllowsAutoDocking:(BOOL)newValue; 233 : 234 0 : - (BOOL) allowsSaving; 235 : // no setting this after station creation 236 : 237 0 : - (NSString *) marketOverrideName; 238 0 : - (BOOL) isRotatingStation; 239 0 : - (BOOL) hasShipyard; 240 : 241 0 : - (BOOL) suppressArrivalReports; 242 0 : - (void) setSuppressArrivalReports:(BOOL)newValue; 243 : 244 0 : - (BOOL) hasBreakPattern; 245 0 : - (void) setHasBreakPattern:(BOOL)newValue; 246 : 247 0 : - (BOOL) fitsInDock:(ShipEntity *)ship; 248 0 : - (BOOL) fitsInDock:(ShipEntity *)ship andLogNoFit:(BOOL)logNoFit; 249 : 250 : @end 251 : 252 : 253 : 254 0 : NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords, float speed, float range, NSString *ai_message, NSString *comms_message, BOOL match_rotation, int docking_stage);