activeconversation.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/activeconversation.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 12/05/01 1:46p $*
  29. * *
  30. * $Revision:: 14 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __ACTIVE_CONVERSATION_H
  39. #define __ACTIVE_CONVERSATION_H
  40. #include "refcount.h"
  41. #include "conversation.h"
  42. #include "vector.h"
  43. #include "vector3.h"
  44. #include "gameobjref.h"
  45. ////////////////////////////////////////////////////////////////
  46. // Forward declarations
  47. ////////////////////////////////////////////////////////////////
  48. class ChunkSaveClass;
  49. class ChunkLoadClass;
  50. class PhysicalGameObj;
  51. class OratorClass;
  52. ////////////////////////////////////////////////////////////////
  53. //
  54. // ActiveConversationClass
  55. //
  56. ////////////////////////////////////////////////////////////////
  57. class ActiveConversationClass : public RefCountClass
  58. {
  59. public:
  60. ////////////////////////////////////////////////////////////////
  61. // Public constructors/destructors
  62. ////////////////////////////////////////////////////////////////
  63. ActiveConversationClass (void);
  64. virtual ~ActiveConversationClass (void);
  65. ////////////////////////////////////////////////////////////////
  66. // Public methods
  67. ////////////////////////////////////////////////////////////////
  68. //
  69. // Save/load methods
  70. //
  71. bool Save (ChunkSaveClass &csave);
  72. bool Load (ChunkLoadClass &cload);
  73. //
  74. // Identification
  75. //
  76. int Get_ID (void) const { return ID; }
  77. void Set_ID (int id) { ID = id; }
  78. //
  79. // Conversation methods
  80. //
  81. ConversationClass * Peek_Conversation (void) const;
  82. void Set_Conversation (ConversationClass *conversation);
  83. //
  84. // Conversation flow control
  85. //
  86. void Start_Conversation (void);
  87. void Stop_Conversation (ActionCompleteReason reason = ACTION_COMPLETE_CONVERSATION_ENDED);
  88. void Think (void);
  89. bool Is_Finished (void) { return bool(State == STATE_FINISHED); }
  90. //
  91. // State evaluation methods
  92. //
  93. bool Get_Orator_Location (PhysicalGameObj *orator, Vector3 *position);
  94. bool Get_Current_Orator_Location (Vector3 *position);
  95. PhysicalGameObj * Get_Current_Orator (void);
  96. void Get_Conversation_Center (Vector3 *position);
  97. void Set_Orator_Arrived (PhysicalGameObj *orator, bool has_arrived);
  98. void Control_Orator (SoldierGameObj *orator);
  99. //
  100. // Orator methods
  101. //
  102. OratorClass * Add_Orator (PhysicalGameObj *orator);
  103. OratorClass * Get_Orator_Information (PhysicalGameObj *orator);
  104. //
  105. // Monitor support
  106. //
  107. void Register_Monitor (ScriptableGameObj *game_obj);
  108. void Unregister_Monitor (ScriptableGameObj *game_obj);
  109. void Set_Action_ID (int id) { ActionID = id; }
  110. //
  111. // Misc accessors
  112. //
  113. int Get_Priority (void) const { return Priority; }
  114. void Set_Priority (int priority) { Priority = priority; }
  115. float Get_Max_Dist (void) const { return MaxDist; }
  116. void Set_Max_Dist (float max_dist) { MaxDist = max_dist; }
  117. bool Is_Interruptable (void) const { return IsInterruptable; }
  118. void Set_Is_Interruptable (bool onoff) { IsInterruptable = onoff; }
  119. //
  120. // Time estimation
  121. //
  122. float Get_Conversation_Time (void);
  123. protected:
  124. ////////////////////////////////////////////////////////////////
  125. // Protected methods
  126. ////////////////////////////////////////////////////////////////
  127. void Load_Variables (ChunkLoadClass &cload);
  128. void Free_Orator_List (void);
  129. bool Is_Audience_In_Place (void);
  130. void Check_For_Audience (void);
  131. void Say_Next_Remark (void);
  132. void Stop_Current_Sound (void);
  133. void Notify_Monitors_On_End (ActionCompleteReason id);
  134. void Notify_Monitors (int custom_event_id, int param);
  135. ////////////////////////////////////////////////////////////////
  136. // Protected data types
  137. ////////////////////////////////////////////////////////////////
  138. enum
  139. {
  140. STATE_INITIALIZING = 0,
  141. STATE_WAITING_FOR_AUDIENCE,
  142. STATE_TALKING,
  143. STATE_FINISHED,
  144. STATE_INTERRUPTED = STATE_FINISHED
  145. };
  146. enum
  147. {
  148. MAX_MONITORS = 10,
  149. };
  150. ////////////////////////////////////////////////////////////////
  151. // Protected member data
  152. ////////////////////////////////////////////////////////////////
  153. int ID;
  154. ConversationClass * Conversation;
  155. int CurrentRemark;
  156. float NextRemarkTimer;
  157. DynamicVectorClass<OratorClass *> OratorList;
  158. int ActionID;
  159. int OratorSpokenBitmask;
  160. Vector3 CentralPos;
  161. GameObjReference MonitorArray[MAX_MONITORS];
  162. AudibleSoundClass * CurrentSound;
  163. int State;
  164. float InitializingTimeLeft;
  165. int Priority;
  166. float MaxDist;
  167. bool IsInterruptable;
  168. };
  169. ////////////////////////////////////////////////////////////////
  170. // Peek_Conversation
  171. ////////////////////////////////////////////////////////////////
  172. inline ConversationClass *
  173. ActiveConversationClass::Peek_Conversation (void) const
  174. {
  175. return Conversation;
  176. }
  177. #endif //__ACTIVE_CONVERSATION_H