IObjectInterface.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * IObjectInterface.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 "../networkPacks/EInfoWindowMode.h"
  12. #include "../networkPacks/ObjProperty.h"
  13. #include "../constants/EntityIdentifiers.h"
  14. #include "../GameCallbackHolder.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. struct BattleResult;
  17. struct UpgradeInfo;
  18. class BoatId;
  19. class CGObjectInstance;
  20. class CRandomGenerator;
  21. class CStackInstance;
  22. class CGHeroInstance;
  23. class IGameCallback;
  24. class ResourceSet;
  25. class int3;
  26. class MetaString;
  27. class PlayerColor;
  28. class DLL_LINKAGE IObjectInterface : public GameCallbackHolder
  29. {
  30. public:
  31. using GameCallbackHolder::GameCallbackHolder;
  32. virtual ~IObjectInterface() = default;
  33. virtual MapObjectID getObjGroupIndex() const = 0;
  34. virtual MapObjectSubID getObjTypeIndex() const = 0;
  35. virtual PlayerColor getOwner() const = 0;
  36. virtual int3 visitablePos() const = 0;
  37. virtual int3 getPosition() const = 0;
  38. virtual void onHeroVisit(const CGHeroInstance * h) const;
  39. virtual void onHeroLeave(const CGHeroInstance * h) const;
  40. virtual void newTurn(CRandomGenerator & rand) const;
  41. virtual void initObj(CRandomGenerator & rand); //synchr
  42. virtual void pickRandomObject(CRandomGenerator & rand);
  43. virtual void setProperty(ObjProperty what, ObjPropertyID identifier);//synchr
  44. //Called when queries created DURING HERO VISIT are resolved
  45. //First parameter is always hero that visited object and triggered the query
  46. virtual void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const;
  47. virtual void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const;
  48. virtual void garrisonDialogClosed(const CGHeroInstance *hero) const;
  49. virtual void heroLevelUpDone(const CGHeroInstance *hero) const;
  50. //unified helper to show info dialog for object owner
  51. virtual void showInfoDialog(const ui32 txtID, const ui16 soundID = 0, EInfoWindowMode mode = EInfoWindowMode::AUTO) const;
  52. //unified interface, AI helpers
  53. virtual bool wasVisited (PlayerColor player) const;
  54. virtual bool wasVisited (const CGHeroInstance * h) const;
  55. static void preInit(); //called before objs receive their initObj
  56. static void postInit();//called after objs receive their initObj
  57. template <typename Handler> void serialize(Handler &h, const int version)
  58. {
  59. logGlobal->error("IObjectInterface serialized, unexpected, should not happen!");
  60. }
  61. };
  62. class DLL_LINKAGE ICreatureUpgrader
  63. {
  64. public:
  65. virtual void fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &stack) const = 0;
  66. virtual ~ICreatureUpgrader() = default;
  67. };
  68. class DLL_LINKAGE IBoatGenerator
  69. {
  70. public:
  71. virtual ~IBoatGenerator() = default;
  72. virtual const IObjectInterface * getObject() const = 0;
  73. virtual BoatId getBoatType() const = 0; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
  74. virtual void getOutOffsets(std::vector<int3> & offsets) const = 0; //offsets to obj pos when we boat can be placed
  75. int3 bestLocation() const; //returns location when the boat should be placed
  76. enum EGeneratorState {GOOD, BOAT_ALREADY_BUILT, TILE_BLOCKED, NO_WATER, UNKNOWN};
  77. virtual EGeneratorState shipyardStatus() const;
  78. void getProblemText(MetaString &out, const CGHeroInstance *visitor = nullptr) const;
  79. };
  80. class DLL_LINKAGE IShipyard : public IBoatGenerator
  81. {
  82. public:
  83. virtual void getBoatCost(ResourceSet & cost) const;
  84. static const IShipyard *castFrom(const CGObjectInstance *obj);
  85. };
  86. VCMI_LIB_NAMESPACE_END