TRIGTYPE.H 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/TRIGTYPE.H 1 3/03/97 10:26a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : TRIGTYPE.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 06/05/96 *
  26. * *
  27. * Last Update : June 5, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef TRIGTYPE_H
  33. #define TRIGTYPE_H
  34. #include "tevent.h"
  35. #include "taction.h"
  36. class TriggerClass;
  37. /*
  38. ** There can be multiple trigger events and trigger actions. This enumeration is used to
  39. ** indicate if there are multiple events/actions and what their relationship is.
  40. */
  41. typedef enum MultiStyleType : unsigned char {
  42. MULTI_ONLY, // "Only" main trigger action/event?
  43. MULTI_AND, // "And" secondary trigger action/event?
  44. MULTI_OR, // "Or" secondary event?
  45. MULTI_LINKED // Cause and effect pairs are linked?
  46. } MultiStyleType;
  47. class TriggerTypeClass : public AbstractTypeClass
  48. {
  49. public:
  50. unsigned IsActive:1;
  51. typedef enum PersistantType : unsigned char {
  52. VOLATILE = 0,
  53. SEMIPERSISTANT = 1,
  54. PERSISTANT = 2
  55. } PersistantType;
  56. /*
  57. ** This flag controls whether the trigger destroys itself after it goes
  58. ** off.
  59. ** 0 = trigger destroys itself immediately after going off, and removes
  60. ** itself from all objects it's attached to
  61. ** 1 = trigger is "Semi-Persistent"; it maintains a count of all objects
  62. ** it's attached to, and only actually "springs" after its been
  63. ** triggered from all the objects; then, it removes itself.
  64. ** 2 = trigger is Fully Persistent; it just won't go away.
  65. */
  66. PersistantType IsPersistant;
  67. /*
  68. ** For house-specific events, this is the house for that event.
  69. */
  70. HousesType House;
  71. /*
  72. ** Each trigger must have an event which activates it. This is the event that is
  73. ** used to activate this trigger.
  74. */
  75. TEventClass Event1;
  76. TEventClass Event2;
  77. MultiStyleType EventControl;
  78. /*
  79. ** This is the action to perform when the trigger event occurs.
  80. */
  81. TActionClass Action1;
  82. TActionClass Action2;
  83. MultiStyleType ActionControl;
  84. TriggerTypeClass(void);
  85. TriggerTypeClass(NoInitClass const & x) : AbstractTypeClass(x), Event1(x), Event2(x), Action1(x), Action2(x) {};
  86. virtual ~TriggerTypeClass(void);
  87. static void * operator new(size_t );
  88. static void * operator new(size_t, void * ptr) {return(ptr);};
  89. static void operator delete(void *ptr);
  90. /*
  91. ** Initialization: clears all trigger types in preparation for new scenario
  92. */
  93. static void Init(void);
  94. /*
  95. ** File I/O routines
  96. */
  97. static void Read_INI(CCINIClass & ini);
  98. static void Write_INI(CCINIClass & ini);
  99. void Fill_In(char * name, char * entry);
  100. void Build_INI_Entry(char * buf) const;
  101. static char * INI_Name(void) {return "Trigs";};
  102. bool Load(Straw & file);
  103. bool Save(Pipe & file) const;
  104. void Code_Pointers(void);
  105. void Decode_Pointers(void);
  106. /*
  107. ** Processing routines
  108. */
  109. TriggerClass * Create_One_Of(void) const;
  110. void Destroy_All_Of(void) const;
  111. /*
  112. ** Utility routines
  113. */
  114. void Detach(TARGET target, bool all=true);
  115. AttachType Attaches_To(void) const;
  116. TARGET As_Target(void) const;
  117. static TriggerTypeClass * From_Name(char const * name);
  118. bool Edit(void);
  119. #if defined(CHEAT_KEYS) || defined(SCENARIO_EDITOR)
  120. char const * Description(void) const;
  121. operator const char * (void) const {return(Description());};
  122. #endif
  123. void Draw_It(int index, int x, int y, int width, int height, bool selected, TextPrintType flags) const;
  124. };
  125. #endif