FACTORY.H 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. ** Command & Conquer(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. /* $Header: F:\projects\c&c\vcs\code\factory.h_v 2.17 16 Oct 1995 16:45:44 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : FACTORY.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 12/26/94 *
  30. * *
  31. * Last Update : December 26, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef FACTORY_H
  37. #define FACTORY_H
  38. #include "stage.h"
  39. class FactoryClass : private StageClass
  40. {
  41. public:
  42. FactoryClass(void);
  43. ~FactoryClass(void);
  44. static void * operator new(size_t size);
  45. static void operator delete(void *ptr);
  46. static void Init(void);
  47. /*
  48. ** File I/O.
  49. */
  50. bool Load(FileClass & file);
  51. bool Save(FileClass & file);
  52. void Code_Pointers(void);
  53. void Decode_Pointers(void);
  54. bool Abandon(void);
  55. bool Completed(void);
  56. bool Has_Changed(void);
  57. bool Has_Completed(void);
  58. bool Is_Building(void) const {return(Fetch_Rate() != 0);};
  59. bool Set(TechnoTypeClass const & object, HouseClass & house);
  60. bool Set(int const & type, HouseClass & house);
  61. bool Start(void);
  62. bool Suspend(void);
  63. int Completion(void);
  64. TechnoClass * Get_Object(void) const;
  65. int Get_Special_Item(void) const;
  66. void AI(void);
  67. void Set(TechnoClass & object);
  68. HouseClass * Get_House(void) {return(House);};
  69. /*
  70. ** Dee-buggin' support.
  71. */
  72. int Validate(void) const;
  73. /*
  74. ** This flag is used to maintain the pool of factory class objects. If the object has
  75. ** been allocated, then this flag is true. Otherwise, the object is free to be
  76. ** allocated.
  77. */
  78. unsigned IsActive:1;
  79. protected:
  80. enum StepCountEnum {
  81. STEP_COUNT=108 // Number of steps to break production down into.
  82. };
  83. int Cost_Per_Tick(void);
  84. private:
  85. /*
  86. ** If production is temporarily suspended, then this flag will be true. A factory
  87. ** is suspended when it is first created, when production has completed, and when
  88. ** explicitly instructed to Suspend() production. Suspended production is not
  89. ** abandoned. It may be resumed with a call to Start().
  90. */
  91. unsigned IsSuspended:1;
  92. /*
  93. ** If the AI process detected that the production process has advanced far enough
  94. ** that a change in the building animation would occur, this flag will be true.
  95. ** Examination of this flag (through the Has_Chaged function) allows intelligent
  96. ** updating of any production graphic.
  97. */
  98. unsigned IsDifferent:1;
  99. /*
  100. ** This records the balance due on the current production item. This value will
  101. ** be reduced as production proceeds. It will reach zero the moment production has
  102. ** finished. Using this method ensures that the total production cost will be EXACT
  103. ** regardless of the number of installment payments that are made.
  104. */
  105. int Balance;
  106. int OriginalBalance;
  107. /*
  108. ** This is the object that is being produced. It is held in a state of limbo while
  109. ** undergoing production. Since the object is created at the time production is
  110. ** started, it is always available when production completes.
  111. */
  112. TechnoClass * Object;
  113. /*
  114. ** If the factory is not producing an object and is instead producing
  115. ** a special item, then special item will be set.
  116. */
  117. int SpecialItem;
  118. /*
  119. ** The factory has to be doing production for one house or another.
  120. ** The house pointer will point to whichever house it is being done
  121. ** for.
  122. */
  123. HouseClass * House;
  124. };
  125. #endif