CTown.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "../building/TownFortifications.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. const CBuilding * building; // base building. If null - this structure will be always present on screen
  25. const 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 campaignBonus;
  30. ImagePath areaName;
  31. std::string identifier;
  32. bool hiddenUpgrade; // used only if "building" is upgrade, if true - structure on town screen will behave exactly like parent (mouse clicks, hover texts, etc)
  33. };
  34. class DLL_LINKAGE CTown : boost::noncopyable
  35. {
  36. friend class CTownHandler;
  37. size_t namesCount = 0;
  38. public:
  39. CTown();
  40. ~CTown();
  41. std::string getBuildingScope() const;
  42. std::set<si32> getAllBuildings() const;
  43. const CBuilding * getSpecialBuilding(BuildingSubID::EBuildingSubID subID) const;
  44. BuildingID getBuildingType(BuildingSubID::EBuildingSubID subID) const;
  45. std::string getRandomNameTextID(size_t index) const;
  46. size_t getRandomNamesCount() const;
  47. CFaction * faction;
  48. /// level -> list of creatures on this tier
  49. std::vector<std::vector<CreatureID> > creatures;
  50. std::map<BuildingID, std::unique_ptr<const 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. /// Base state of fortifications for empty town.
  59. /// Used to define shooter units and moat spell ID
  60. TownFortifications fortifications;
  61. // default chance for hero of specific class to appear in tavern, if field "tavern" was not set
  62. // resulting chance = sqrt(town.chance * heroClass.chance)
  63. ui32 defaultTavernChance;
  64. // Client-only data. Should be moved away from lib
  65. struct ClientInfo
  66. {
  67. //icons [fort is present?][build limit reached?] -> index of icon in def files
  68. int icons[2][2];
  69. std::string iconSmall[2][2]; /// icon names used during loading
  70. std::string iconLarge[2][2];
  71. VideoPath tavernVideo;
  72. std::vector<AudioPath> musicTheme;
  73. ImagePath townBackground;
  74. std::vector<ImagePath> guildBackground;
  75. std::vector<ImagePath> guildWindow;
  76. Point guildWindowPosition;
  77. std::vector<std::vector<Point>> guildSpellPositions;
  78. AnimationPath buildingsIcons;
  79. ImagePath hallBackground;
  80. /// vector[row][column] = list of buildings in this slot
  81. std::vector< std::vector< std::vector<BuildingID> > > hallSlots;
  82. /// list of town screen structures.
  83. /// NOTE: index in vector is meaningless. Vector used instead of list for a bit faster access
  84. std::vector<std::unique_ptr<const CStructure>> structures;
  85. std::string siegePrefix;
  86. std::vector<Point> siegePositions;
  87. std::string towerIconSmall;
  88. std::string towerIconLarge;
  89. } clientInfo;
  90. };
  91. VCMI_LIB_NAMESPACE_END