2
0

mapHandler.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * mapHandler.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 "../gui/CIntObject.h"
  12. #include "../../lib/Rect.h"
  13. #include "../../lib/int3.h"
  14. #include "../../lib/spells/ViewSpellInt.h"
  15. #ifdef IN
  16. # undef IN
  17. #endif
  18. #ifdef OUT
  19. # undef OUT
  20. #endif
  21. VCMI_LIB_NAMESPACE_BEGIN
  22. class CGObjectInstance;
  23. class CGHeroInstance;
  24. class CMap;
  25. VCMI_LIB_NAMESPACE_END
  26. class IMapObjectObserver;
  27. class CMapHandler
  28. {
  29. const CMap * map;
  30. std::vector<IMapObjectObserver *> observers;
  31. public:
  32. explicit CMapHandler(const CMap * map);
  33. const CMap * getMap();
  34. /// returns true if tile is within map bounds
  35. bool isInMap(const int3 & tile);
  36. /// see MapObjectObserver interface
  37. void onObjectFadeIn(const CGObjectInstance * obj, const PlayerColor & initiator);
  38. void onObjectFadeOut(const CGObjectInstance * obj, const PlayerColor & initiator);
  39. void onObjectInstantAdd(const CGObjectInstance * obj, const PlayerColor & initiator);
  40. void onObjectInstantRemove(const CGObjectInstance * obj, const PlayerColor & initiator);
  41. void onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  42. void onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  43. void onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  44. void onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  45. void onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  46. void onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  47. void onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  48. /// Add object to receive notifications on any changes in visible map state
  49. void addMapObserver(IMapObjectObserver * observer);
  50. void removeMapObserver(IMapObjectObserver * observer);
  51. /// returns string description for terrain interaction
  52. std::string getTerrainDescr(const int3 & pos, bool rightClick) const; //TODO: possible to get info about invisible tiles from client without serverside validation
  53. /// determines if the map is ready to handle new hero movement (not available during fading animations)
  54. bool hasOngoingAnimations();
  55. /// blocking wait until all ongoing animatins are over
  56. void waitForOngoingAnimations();
  57. void endNetwork();
  58. static bool compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b);
  59. };