CDefObjInfoHandler.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "GameConstants.h"
  3. #include "../lib/ConstTransitivePtr.h"
  4. /*
  5. * CDefObjInfoHandler.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. class CDefEssential;
  14. class DLL_LINKAGE CGDefInfo
  15. {
  16. public:
  17. std::string name;
  18. ui8 visitMap[6];
  19. ui8 blockMap[6];
  20. ui8 coverageMap[6], shadowCoverage[6]; //to determine which tiles are covered by picture of this object
  21. ui8 visitDir; //directions from which object can be entered, format same as for moveDir in CGHeroInstance(but 0 - 7)
  22. Obj id;
  23. si32 subid; //of object described by this defInfo
  24. si32 terrainAllowed, //on which terrain it is possible to place object
  25. terrainMenu; //in which menus in map editor object will be showed
  26. si32 width, height; //tiles
  27. si32 type; //(0- ground, 1- towns, 2-creatures, 3- heroes, 4-artifacts, 5- resources)
  28. si32 printPriority;
  29. bool isVisitable() const;
  30. bool operator<(const CGDefInfo& por) const
  31. {
  32. if(id!=por.id)
  33. return id<por.id;
  34. else
  35. return subid<por.subid;
  36. }
  37. template <typename Handler> void serialize(Handler &h, const int version)
  38. {
  39. h & name & visitMap & blockMap & visitDir & id & subid &terrainAllowed
  40. & terrainMenu & width & height & type & printPriority & coverageMap & shadowCoverage;
  41. }
  42. CGDefInfo();
  43. void fetchInfoFromMSK();
  44. };
  45. class DLL_LINKAGE CDefObjInfoHandler
  46. {
  47. public:
  48. std::map<int, std::map<int, ConstTransitivePtr<CGDefInfo> > > gobjs;
  49. std::map<TFaction, ConstTransitivePtr<CGDefInfo> > capitols;
  50. std::map<TFaction, ConstTransitivePtr<CGDefInfo> > villages;
  51. CDefObjInfoHandler();
  52. ~CDefObjInfoHandler();
  53. template <typename Handler> void serialize(Handler &h, const int version)
  54. {
  55. h & gobjs & capitols & villages;
  56. }
  57. };