1 // Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details 2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt 3 4 #ifndef _SPACESTATIONTYPE_H 5 #define _SPACESTATIONTYPE_H 6 7 #include "libs.h" 8 9 //Space station definition, loaded from data/stations 10 11 class Ship; 12 namespace SceneGraph { 13 class Model; 14 } 15 16 class SpaceStationType { 17 public: 18 typedef std::map<Uint32, matrix4x4f> TMapBayIDMat; 19 struct PortPath { 20 TMapBayIDMat m_docking; 21 TMapBayIDMat m_leaving; 22 }; 23 typedef std::map<Uint32, PortPath> PortPathMap; 24 25 struct SPort { 26 static const int BAD_PORT_ID = -1; SPortSPort27 SPort() : 28 portId(BAD_PORT_ID), 29 minShipSize(5000), 30 maxShipSize(-1), 31 inUse(false) {} 32 int portId; 33 int minShipSize, maxShipSize; 34 bool inUse; 35 std::vector<std::pair<int, std::string>> bayIDs; 36 std::string name; 37 TMapBayIDMat m_approach; 38 }; 39 typedef std::vector<SPort> TPorts; 40 41 struct positionOrient_t { 42 vector3d pos; 43 vector3d xaxis; 44 vector3d yaxis; 45 vector3d zaxis; 46 }; 47 48 private: 49 std::string id; 50 SceneGraph::Model *model; 51 std::string modelName; 52 float angVel; 53 enum DOCKMETHOD { SURFACE, 54 ORBITAL } dockMethod; 55 unsigned int numDockingPorts; 56 int numDockingStages; 57 int numUndockStages; 58 int shipLaunchStage; 59 float parkingDistance; 60 float parkingGapSize; 61 PortPathMap m_portPaths; 62 TPorts m_ports; 63 float padOffset; 64 65 static std::vector<SpaceStationType> surfaceTypes; 66 static std::vector<SpaceStationType> orbitalTypes; 67 68 public: 69 SpaceStationType(const std::string &id, const std::string &path); 70 71 void OnSetupComplete(); 72 const SPort *FindPortByBay(const int zeroBaseBayID) const; 73 SPort *GetPortByBay(const int zeroBaseBayID); 74 75 double GetDockAnimStageDuration(const int stage) const; 76 double GetUndockAnimStageDuration(const int stage) const; 77 78 // Call functions in the station .lua 79 bool GetShipApproachWaypoints(const unsigned int port, const int stage, positionOrient_t &outPosOrient) const; 80 /** when ship is on rails it returns true and fills outPosOrient. 81 * when ship has been released (or docked) it returns false. 82 * Note station animations may continue for any number of stages after 83 * ship has been released and is under player control again */ 84 bool GetDockAnimPositionOrient(const unsigned int port, int stage, double t, const vector3d &from, positionOrient_t &outPosOrient, const Ship *ship) const; 85 ModelName()86 const std::string &ModelName() const { return modelName; } AngVel()87 float AngVel() const { return angVel; } IsSurfaceStation()88 bool IsSurfaceStation() const { return (SURFACE == dockMethod); } IsOrbitalStation()89 bool IsOrbitalStation() const { return (ORBITAL == dockMethod); } NumDockingPorts()90 unsigned int NumDockingPorts() const { return numDockingPorts; } NumDockingStages()91 int NumDockingStages() const { return numDockingStages; } NumUndockStages()92 int NumUndockStages() const { return numUndockStages; } ShipLaunchStage()93 int ShipLaunchStage() const { return shipLaunchStage; } ParkingDistance()94 float ParkingDistance() const { return parkingDistance; } ParkingGapSize()95 float ParkingGapSize() const { return parkingGapSize; } Ports()96 const TPorts &Ports() const { return m_ports; } 97 98 static void Init(); 99 100 static const SpaceStationType *RandomStationType(Random &random, const bool bIsGround); 101 static const SpaceStationType *FindByName(const std::string &name); 102 }; 103 104 #endif 105