CTown.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * CTown.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../../ConstTransitivePtr.h"
  12. #include "../../Point.h"
  13. #include "../../constants/EntityIdentifiers.h"
  14. #include "../../constants/Enumerations.h"
  15. #include "../../filesystem/ResourcePath.h"
  16. #include "../../int3.h"
  17. VCMI_LIB_NAMESPACE_BEGIN
  18. class CBuilding;
  19. /// This is structure used only by client
  20. /// Consists of all gui-related data about town structures
  21. /// Should be moved from lib to client
  22. struct DLL_LINKAGE CStructure
  23. {
  24. CBuilding * building; // base building. If null - this structure will be always present on screen
  25. CBuilding * buildable; // building that will be used to determine built building and visible cost. Usually same as "building"
  26. int3 pos;
  27. AnimationPath defName;
  28. ImagePath borderName;
  29. ImagePath areaName;
  30. std::string identifier;
  31. bool hiddenUpgrade; // used only if "building" is upgrade, if true - structure on town screen will behave exactly like parent (mouse clicks, hover texts, etc)
  32. };
  33. class DLL_LINKAGE CTown
  34. {
  35. friend class CTownHandler;
  36. size_t namesCount = 0;
  37. public:
  38. CTown();
  39. ~CTown();
  40. std::string getBuildingScope() const;
  41. std::set<si32> getAllBuildings() const;
  42. const CBuilding * getSpecialBuilding(BuildingSubID::EBuildingSubID subID) const;
  43. BuildingID getBuildingType(BuildingSubID::EBuildingSubID subID) const;
  44. std::string getRandomNameTextID(size_t index) const;
  45. size_t getRandomNamesCount() const;
  46. CFaction * faction;
  47. /// level -> list of creatures on this tier
  48. // TODO: replace with pointers to CCreature
  49. std::vector<std::vector<CreatureID> > creatures;
  50. std::map<BuildingID, ConstTransitivePtr<CBuilding> > buildings;
  51. std::vector<std::string> dwellings; //defs for adventure map dwellings for new towns, [0] means tier 1 creatures etc.
  52. std::vector<std::string> dwellingNames;
  53. // should be removed at least from configs in favor of auto-detection
  54. std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
  55. ui32 mageLevel; //max available mage guild level
  56. GameResID primaryRes;
  57. CreatureID warMachineDeprecated;
  58. SpellID moatAbility;
  59. // default chance for hero of specific class to appear in tavern, if field "tavern" was not set
  60. // resulting chance = sqrt(town.chance * heroClass.chance)
  61. ui32 defaultTavernChance;
  62. // Client-only data. Should be moved away from lib
  63. struct ClientInfo
  64. {
  65. //icons [fort is present?][build limit reached?] -> index of icon in def files
  66. int icons[2][2];
  67. std::string iconSmall[2][2]; /// icon names used during loading
  68. std::string iconLarge[2][2];
  69. VideoPath tavernVideo;
  70. std::vector<AudioPath> musicTheme;
  71. ImagePath townBackground;
  72. ImagePath guildBackground;
  73. ImagePath guildWindow;
  74. AnimationPath buildingsIcons;
  75. ImagePath hallBackground;
  76. /// vector[row][column] = list of buildings in this slot
  77. std::vector< std::vector< std::vector<BuildingID> > > hallSlots;
  78. /// list of town screen structures.
  79. /// NOTE: index in vector is meaningless. Vector used instead of list for a bit faster access
  80. std::vector<ConstTransitivePtr<CStructure> > structures;
  81. std::string siegePrefix;
  82. std::vector<Point> siegePositions;
  83. CreatureID siegeShooter; // shooter creature ID
  84. std::string towerIconSmall;
  85. std::string towerIconLarge;
  86. } clientInfo;
  87. };
  88. VCMI_LIB_NAMESPACE_END