TunnelTracker.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: TunnelTracker.h ///////////////////////////////////////////////////////////
  24. // The part of a Player's brain that holds the communal Passenger list of all tunnels.
  25. // This has a similar interface to a ContainModule, naturally, but players can't have modules.
  26. // Author: Graham Smallwood, March, 2002
  27. #pragma once
  28. #ifndef TUNNEL_TRACKER_H
  29. #define TUNNEL_TRACKER_H
  30. #include "Common/GameType.h"
  31. #include "Common/GameMemory.h"
  32. #include "Common/Snapshot.h"
  33. #include "GameLogic/Module/ContainModule.h"
  34. class TunnelTracker : public MemoryPoolObject,
  35. public Snapshot
  36. {
  37. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( TunnelTracker, "TunnelTracker" );
  38. public:
  39. TunnelTracker();
  40. // contain list access
  41. void iterateContained( ContainIterateFunc func, void *userData, Bool reverse );
  42. UnsignedInt getContainCount() const { return m_containListSize; }
  43. Int getContainMax() const;
  44. const ContainedItemsList* getContainedItemsList() const { return &m_containList; }
  45. Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
  46. void addToContainList( Object *obj ); ///< add 'obj' to contain list
  47. void removeFromContain( Object *obj, Bool exposeStealthUnits = FALSE ); ///< remove 'obj' from contain list
  48. Bool isInContainer( Object *obj ); ///< Is this thing inside?
  49. void onTunnelCreated( const Object *newTunnel ); ///< A tunnel was made
  50. void onTunnelDestroyed( const Object *deadTunnel ); ///< A tunnel was destroyed
  51. static void destroyObject( Object *obj, void *userData ); ///< Callback for Iterate Contained system
  52. static void healObject( Object *obj, void *frames ); ///< Callback for Iterate Contained system
  53. void healObjects(Real frames); ///< heal all objects within the tunnel
  54. UnsignedInt friend_getTunnelCount() const {return m_tunnelCount;}///< TunnelContains are allowed to ask if they are the last one ahead of deletion time
  55. const std::list< ObjectID > *getContainerList() const {return &m_tunnelIDs;}
  56. Object *getCurNemesis(void);
  57. void updateNemesis(const Object *target);
  58. protected:
  59. virtual void crc( Xfer *xfer );
  60. virtual void xfer( Xfer *xfer );
  61. virtual void loadPostProcess( void );
  62. private:
  63. std::list< ObjectID > m_tunnelIDs; ///< I have to try to keep track of these because Caves need to iterate on them.
  64. ContainedItemsList m_containList; ///< the contained object pointers list
  65. std::list< ObjectID > m_xferContainList;///< for loading of m_containList during post processing
  66. Int m_containListSize; ///< size of the contain list
  67. UnsignedInt m_tunnelCount; ///< How many tunnels have registered so we know when we should kill our contain list
  68. ObjectID m_curNemesisID; ///< If we have team(s) guarding a tunnel network system, this is one of the current targets.
  69. UnsignedInt m_nemesisTimestamp; ///< We only keep nemesis for a couple of seconds.
  70. };
  71. #endif