CTown.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 "../../ConstTransitivePtr.h"
  13. #include "../../Point.h"
  14. #include "../../constants/EntityIdentifiers.h"
  15. #include "../../constants/Enumerations.h"
  16. #include "../../filesystem/ResourcePath.h"
  17. #include "../../int3.h"
  18. VCMI_LIB_NAMESPACE_BEGIN
  19. class CBuilding;
  20. /// This is structure used only by client
  21. /// Consists of all gui-related data about town structures
  22. /// Should be moved from lib to client
  23. struct DLL_LINKAGE CStructure
  24. {
  25. CBuilding * building; // base building. If null - this structure will be always present on screen
  26. CBuilding * buildable; // building that will be used to determine built building and visible cost. Usually same as "building"
  27. int3 pos;
  28. AnimationPath defName;
  29. ImagePath borderName;
  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
  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. // TODO: replace with pointers to CCreature
  50. std::vector<std::vector<CreatureID> > creatures;
  51. std::map<BuildingID, ConstTransitivePtr<CBuilding> > buildings;
  52. std::vector<std::string> dwellings; //defs for adventure map dwellings for new towns, [0] means tier 1 creatures etc.
  53. std::vector<std::string> dwellingNames;
  54. // should be removed at least from configs in favor of auto-detection
  55. std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
  56. ui32 mageLevel; //max available mage guild level
  57. GameResID primaryRes;
  58. CreatureID warMachineDeprecated;
  59. /// Base state of fortifications for empty town.
  60. /// Used to define shooter units and moat spell ID
  61. TownFortifications fortifications;
  62. // default chance for hero of specific class to appear in tavern, if field "tavern" was not set
  63. // resulting chance = sqrt(town.chance * heroClass.chance)
  64. ui32 defaultTavernChance;
  65. // Client-only data. Should be moved away from lib
  66. struct ClientInfo
  67. {
  68. //icons [fort is present?][build limit reached?] -> index of icon in def files
  69. int icons[2][2];
  70. std::string iconSmall[2][2]; /// icon names used during loading
  71. std::string iconLarge[2][2];
  72. VideoPath tavernVideo;
  73. std::vector<AudioPath> musicTheme;
  74. ImagePath townBackground;
  75. ImagePath guildBackground;
  76. ImagePath guildWindow;
  77. AnimationPath buildingsIcons;
  78. ImagePath hallBackground;
  79. /// vector[row][column] = list of buildings in this slot
  80. std::vector< std::vector< std::vector<BuildingID> > > hallSlots;
  81. /// list of town screen structures.
  82. /// NOTE: index in vector is meaningless. Vector used instead of list for a bit faster access
  83. std::vector<ConstTransitivePtr<CStructure> > structures;
  84. std::string siegePrefix;
  85. std::vector<Point> siegePositions;
  86. std::string towerIconSmall;
  87. std::string towerIconLarge;
  88. } clientInfo;
  89. };
  90. VCMI_LIB_NAMESPACE_END