Team.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. //***************************************************************************
  2. //
  3. // team.h - This file contains the Team Class header
  4. //
  5. // MechCommander 2
  6. //
  7. //---------------------------------------------------------------------------//
  8. // Copyright (C) Microsoft Corporation. All rights reserved. //
  9. //===========================================================================//
  10. #ifndef TEAM_H
  11. #define TEAM_H
  12. //---------------------------------------------------------------------------
  13. #ifndef MCLIB_H
  14. #include "mclib.h"
  15. #endif
  16. #ifndef DTEAM_H
  17. #include "dteam.h"
  18. #endif
  19. #ifndef DMOVER_H
  20. #include "dmover.h"
  21. #endif
  22. #ifndef CONTACT_H
  23. #include "contact.h"
  24. #endif
  25. #ifndef OBJECTIVE_H
  26. #include "Objective.h"
  27. #endif
  28. //***************************************************************************
  29. typedef struct _SystemTracker {
  30. GameObjectPtr owner;
  31. long masterId;
  32. float effect;
  33. SystemTrackerPtr prev;
  34. SystemTrackerPtr next;
  35. } SystemTracker;
  36. //---------------------------------------------------------------------------
  37. typedef struct _TeamData
  38. {
  39. long id;
  40. long rosterSize;
  41. GameObjectWatchID roster[MAX_MOVERS_PER_TEAM];
  42. } TeamData;
  43. typedef struct _TeamStaticData
  44. {
  45. long numTeams;
  46. long homeTeamId;
  47. char relations[MAX_TEAMS][MAX_TEAMS];
  48. bool noPain[MAX_TEAMS];
  49. } TeamStaticData;
  50. class Team {
  51. public:
  52. //-------------
  53. // general info
  54. long id;
  55. long rosterSize;
  56. GameObjectWatchID roster[MAX_MOVERS_PER_TEAM]; // list of mover WIDs
  57. //-------------
  58. // mission info
  59. CObjectives objectives;
  60. long numPrimaryObjectives;
  61. //------------------
  62. // static class info
  63. static long numTeams;
  64. static TeamPtr home;
  65. static TeamPtr teams[MAX_TEAMS];
  66. static SortListPtr sortList;
  67. static char relations[MAX_TEAMS][MAX_TEAMS];
  68. static bool noPain[MAX_TEAMS];
  69. public:
  70. virtual void init (void);
  71. Team (void) {
  72. init();
  73. }
  74. virtual long init (long _id, FitIniFile *pMissionFile = 0);
  75. virtual long loadObjectives (FitIniFile *pMissionFile = 0);
  76. long getId (void) {
  77. return(id);
  78. }
  79. void buildRoster (void);
  80. void addToRoster (MoverPtr mover);
  81. long getRosterSize (void) {
  82. return(rosterSize);
  83. }
  84. MoverPtr getMover (long index);
  85. void removeFromRoster (MoverPtr mover);
  86. virtual long getRoster (GameObjectPtr* objList, bool existsOnly = false);
  87. void disableTargets (void);
  88. void destroyTargets (void);
  89. bool isTargeting (GameObjectWatchID targetWID, GameObjectWatchID exceptWID);
  90. bool isCapturing (GameObjectWatchID targetWID, GameObjectWatchID exceptWID);
  91. bool isContact (GameObjectPtr looker, MoverPtr mover, long contactCriteria);
  92. virtual long getContacts (GameObjectPtr looker, long* contactList, long contactCriteria, long sortType);
  93. bool hasSensorContact (long teamID);
  94. void addToGUI (void);
  95. Stuff::Vector3D calcEscapeVector (MoverPtr mover, float threatRange);
  96. void statusCount (long* statusTally);
  97. void eject (void);
  98. virtual long init (FitIniFile* unitFile) {
  99. return(NO_ERR);
  100. }
  101. virtual void destroy (void);
  102. ~Team (void) {
  103. destroy();
  104. }
  105. static bool lineOfSight (float startLocal, long mCellRow, long mCellCol, float endLocal, long tCellRow, long tCellCol, long teamId, float targetRadius, float startRadius = 0.0f, bool checkVisibleBits = true);
  106. static bool lineOfSight (Stuff::Vector3D myPos, Stuff::Vector3D targetPosition, long teamId, float targetRadius, float startRadius = 0.0f, bool checkVisibleBits = true);
  107. //-------------------------------------------
  108. // Can anyone on my team see this position?
  109. // Used for cursors, artillery, indirect fire.
  110. bool teamLineOfSight (Stuff::Vector3D tPos, float extRad);
  111. void markRadiusSeen (Stuff::Vector3D& location, float radius);
  112. void markRadiusSeenToTeams (Stuff::Vector3D& location, float radius = -1, bool shrinkForNight = false);
  113. void markSeen (Stuff::Vector3D& location, float specialUnitExpand);
  114. void setRelation (TeamPtr team, char relation) {
  115. relations[id][team->getId()] = relation;
  116. relations[team->getId()][id] = relation;
  117. }
  118. long getRelation (TeamPtr team) {
  119. if ( !team )
  120. return RELATION_NEUTRAL;
  121. return(relations[id][team->getId()]);
  122. }
  123. static long getRelation (long teamID1, long teamID2) {
  124. if (teamID1 == -1)
  125. return(0);
  126. if (teamID2 == -1)
  127. return(0);
  128. return(relations[teamID1][teamID2]);
  129. }
  130. static long Save (PacketFilePtr file, long packetNum);
  131. static long Load (PacketFilePtr file, long packetNum);
  132. bool isFriendly (TeamPtr team) {
  133. if ( !team )
  134. return 0;
  135. return(relations[id][team->getId()] == RELATION_FRIENDLY);
  136. }
  137. bool isEnemy (TeamPtr team) {
  138. if ( !team )
  139. return 0;
  140. return(relations[id][team->getId()] == RELATION_ENEMY);
  141. }
  142. bool isNeutral (TeamPtr team) {
  143. if ( !team )
  144. return true;
  145. return(relations[id][team->getId()] == RELATION_NEUTRAL);
  146. }
  147. };
  148. //***************************************************************************
  149. #endif