drones.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #ifndef DRONES_H
  2. #define DRONES_H
  3. // There are only a handfull of things that the rest of the game
  4. // needs to know about. Everything else should be completely
  5. // contained in the drones directory.
  6. const int MAX_DRONES = 100; // this is the maximum number of drones for the entire game
  7. // the number was arbitrary, but the idea is that we don't want too
  8. // many drones taking away from player cycles
  9. class Drone; // class declaration, but not definition. See drone.h
  10. /*-------------------------------------------------------------------------
  11. * Class: Drones
  12. *-------------------------------------------------------------------------
  13. * Purpose:
  14. * This is the drones wrapper class. This class should make knowledge of
  15. * of the actual Drone class completely unnecessary outside of the drones
  16. * directory.
  17. */
  18. class Drones {
  19. public:
  20. Drones(); // Constructor
  21. ~Drones() // Destructor
  22. {
  23. Purge();
  24. };
  25. //Leave this around so the drones can set the default command
  26. //(NYI this really should be done via the database (server) or messages (client))
  27. void SetCore(ImissionIGC* pmission);
  28. /*
  29. ImissionIGC * GetCore() // Want to access the trekcore, too
  30. {
  31. return m_pTrekCore;
  32. };
  33. */
  34. Drone* Create( ImissionIGC* pMission, // Create a new drone (and it's accompanying ship)
  35. DroneType dtType, // what type of drone
  36. const char* name, // name, or NULL = default name
  37. HullID hullID, // Which hull to use
  38. IsideIGC* side, // what side is it on
  39. Mount nParts, // Part data
  40. const PartData* parts,
  41. float shootSkill = 1.0f, // Unless specified, give the drones all their skills
  42. float moveSkill = 1.0f,
  43. float bravery = 1.0f);
  44. // Message to Drones: these functions are wrappers of each other.
  45. // It should be passed as much info as possible
  46. /*
  47. void MessageToDrone(Time now, // Just support old calling method, really we want to have the sender field
  48. const char* msg,
  49. ImodelIGC* pmodelObject)
  50. {
  51. MessageToDrone(now, NULL, msg, pmodelObject);
  52. };
  53. */
  54. void MessageToDrone(Time now, // When we know the sender, but not the recipient or command
  55. IshipIGC* pSender,
  56. const char* msg,
  57. ImodelIGC* pmodelObject,
  58. bool fCheckPilot = false);
  59. void MessageToDrone(Time now, // We know the sender and recipient, bot not which command
  60. IshipIGC* pSender,
  61. Drone * pdRecip,
  62. const char* msg,
  63. ImodelIGC* pmodelObject);
  64. void MessageToDrone(Time now, // We know the sender, recipient, and command.... Just pass it on to the drone
  65. IshipIGC* pSender,
  66. Drone * pdRecip,
  67. CommandID cm,
  68. ImodelIGC* pmodelObject);
  69. void DockEvent(IshipIGC * pship); // Let the drone know that it has docked
  70. CommandMask GetDroneCommands(DroneType); // GetDroneCommands returns mask of CommandIDs that are supported by each
  71. // drone. If no drone matches pDroneShip, I return -1.
  72. void Update(Time lastUpdate, // This is in the main game loop. Update all of the drone controls.
  73. Time now);
  74. // we also want to have a special drone for the auto pilot. This will only get used on the client.
  75. void CreatePilot(IshipIGC* ship); // Create an autoPilot drone using the existing ship
  76. void MessageToPilot(CommandID cm, ImodelIGC* pmodelObject); // Send the message right to the pilot
  77. void UpdatePilot(Time lastUpdate, Time now, float dt); // This is not in the main drone update, because it will normally be the
  78. // only one running on the client, and it won't happen on the server
  79. void ResetPilot(void); // Clear the pilots goals
  80. IshipIGC* GetPilotShip(void); // Get the pilot's ships
  81. void SetPilotShip(IshipIGC* ship); // Set the pilot to use a different ship
  82. // end pilot stuff
  83. // begin Pig pilot stuff
  84. Drone* CreatePigPilot(IshipIGC* ship); // Create a pig autoPilot drone using the existing ship
  85. // end Pig pilot stuff
  86. bool DeleteShip(IshipIGC* ship); // Clean up the drone using this ship
  87. void Purge(ImissionIGC* pMission = NULL); // Clean up all of the drones (for the specified mission)
  88. // Here are a couple of specialized functions, necessary to keep drone.h hidden.
  89. bool DisappearingDrone(IshipIGC * pship); // When a special drone (bounty hunter, pirate) wants to go into in aleph,
  90. // and never come out the other side
  91. int GetIndex() {return m_index;} // so drones can keep track of their own index and help out on deletion
  92. void InitializeConstructor(Drone* pdrone,
  93. IstationTypeIGC* pstationtype);
  94. private:
  95. Drone* m_pDroneList[MAX_DRONES]; // This is the actual list of drone pointers
  96. //ImissionIGC* m_pTrekCore; // Pointer to the core
  97. Drone* m_pPilot; // keep the autoPilot seperately
  98. int m_index; // next slot to try
  99. friend class Pirate; // Pirate needs to find other pirates, and miners without searching all ships
  100. };
  101. /*-------------------------------------------------------------------------
  102. * Global: g_drones
  103. *-------------------------------------------------------------------------
  104. * Purpose:
  105. * This is the ONLY instance of the Drones class, but it needs to be
  106. * accessable by EVERYONE
  107. */
  108. extern Drones g_drones;
  109. /*-------------------------------------------------------------------------
  110. * Include: drone.h
  111. *-------------------------------------------------------------------------
  112. * Purpose:
  113. * If all goes well, and the server really becomes independent of the Drone class,
  114. * then we won't need this include. Until it does, though, we need to include the
  115. * Information about the Drone class.
  116. */
  117. #include "..\drones\drone.h"
  118. #endif
  119. #endif