weaponbag.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/weaponbag.h $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 12/10/01 11:52a $*
  29. * *
  30. * $Revision:: 33 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef WEAPONBAG_H
  36. #define WEAPONBAG_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef VECTOR_H
  41. #include "vector.h"
  42. #endif
  43. /*
  44. **
  45. */
  46. class WeaponClass;
  47. class ChunkSaveClass;
  48. class ChunkLoadClass;
  49. class ArmedGameObj;
  50. class WeaponDefinitionClass;
  51. class AmmoDefinitionClass;
  52. class BitStreamClass;
  53. class InventoryClass;
  54. /*
  55. ** WeaponBags manage collections of weapons
  56. */
  57. class WeaponBagClass {
  58. public:
  59. WeaponBagClass( ArmedGameObj * owner );
  60. ~WeaponBagClass( void );
  61. bool Save( ChunkSaveClass & csave );
  62. bool Load( ChunkLoadClass & cload );
  63. bool Is_Weapon_Owned( int weapon_id );
  64. bool Is_Ammo_Full( int weapon_id );
  65. WeaponClass * Add_Weapon( const WeaponDefinitionClass * def, int rounds = 0, bool give_weapon = true );
  66. WeaponClass * Add_Weapon( int id, int rounds = 0, bool give_weapon = true );
  67. WeaponClass * Add_Weapon( const char *weapon_name, int rounds = 0, bool give_weapon = true );
  68. void Remove_Weapon( int index );
  69. void Clear_Weapons( void );
  70. int Get_Count( void ) { return WeaponList.Count(); }
  71. WeaponClass * Peek_Weapon( int index ) { return WeaponList[ index ]; }
  72. WeaponClass * Get_Weapon( void ) { return WeaponList[ WeaponIndex ]; }
  73. WeaponClass * Get_Next_Weapon( void );
  74. void Import_Weapon_List(BitStreamClass & packet);
  75. void Export_Weapon_List(BitStreamClass & packet);
  76. int Get_Index( void ) { return WeaponIndex; }
  77. void Select_Index( int index );
  78. void Select_Next( void );
  79. void Select_Prev( void );
  80. void Select_Key_Number( int key_number );
  81. void Select_Weapon( WeaponClass * weapon );
  82. void Select_Weapon_ID( int weapon_id );
  83. void Select_Weapon_Name( const char * name );
  84. void Deselect( void );
  85. bool Is_Changed( void ) { return IsChanged; }
  86. void Force_Changed( void ) { IsChanged = true; }
  87. void Reset_Changed( void ) { IsChanged = false; }
  88. bool HUD_Is_Changed( void ) { return HUDIsChanged; }
  89. void HUD_Reset_Changed( void ) { HUDIsChanged = false; }
  90. // returns if anything was moved
  91. bool Move_Contents( WeaponBagClass * source );
  92. void Store_Inventory( InventoryClass * );
  93. void Restore_Inventory( InventoryClass * );
  94. private:
  95. ArmedGameObj * Owner;
  96. DynamicVectorClass<WeaponClass*> WeaponList;
  97. int WeaponIndex;
  98. bool IsChanged;
  99. bool HUDIsChanged;
  100. WeaponClass * Find_Weapon( const WeaponDefinitionClass * def );
  101. void Mark_Owner_Dirty( void );
  102. };
  103. #endif // WEAPONBAG_H