ObjectManager.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * ObjectManager.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 "Zone.h"
  12. #include "RmgObject.h"
  13. class CGObjectInstance;
  14. class ObjectTemplate;
  15. class CGCreature;
  16. class ObjectManager: public Modificator
  17. {
  18. public:
  19. MODIFICATOR(ObjectManager);
  20. void process() override;
  21. void init() override;
  22. void addRequiredObject(CGObjectInstance * obj, si32 guardStrength=0);
  23. void addCloseObject(CGObjectInstance * obj, si32 guardStrength = 0);
  24. void addNearbyObject(CGObjectInstance * obj, CGObjectInstance * nearbyTarget);
  25. bool createRequiredObjects();
  26. int3 findPlaceForObject(const rmg::Area & searchArea, rmg::Object & obj, si32 min_dist, bool optimizer) const;
  27. int3 findPlaceForObject(const rmg::Area & searchArea, rmg::Object & obj, std::function<float(const int3)> weightFunction, bool optimizer) const;
  28. rmg::Path placeAndConnectObject(const rmg::Area & searchArea, rmg::Object & obj, si32 min_dist, bool isGuarded, bool onlyStraight, bool optimizer) const;
  29. rmg::Path placeAndConnectObject(const rmg::Area & searchArea, rmg::Object & obj, std::function<float(const int3)> weightFunction, bool isGuarded, bool onlyStraight, bool optimizer) const;
  30. CGCreature * chooseGuard(si32 strength, bool zoneGuard = false);
  31. bool addGuard(rmg::Object & object, si32 strength, bool zoneGuard = false);
  32. void placeObject(rmg::Object & object, bool guarded, bool updateDistance);
  33. void updateDistances(const rmg::Object & obj);
  34. const rmg::Area & getVisitableArea() const;
  35. protected:
  36. //content info
  37. std::vector<std::pair<CGObjectInstance*, ui32>> requiredObjects;
  38. std::vector<std::pair<CGObjectInstance*, ui32>> closeObjects;
  39. std::vector<std::pair<CGObjectInstance*, int3>> instantObjects;
  40. std::vector<std::pair<CGObjectInstance*, CGObjectInstance*>> nearbyObjects;
  41. std::vector<CGObjectInstance*> objects;
  42. rmg::Area objectsVisitableArea;
  43. };