Răsfoiți Sursa

Show available creatures in owned dwellings on right-click

Ivan Savenko 2 ani în urmă
părinte
comite
1ebb151b41
2 a modificat fișierele cu 25 adăugiri și 0 ștergeri
  1. 24 0
      lib/mapObjects/CGDwelling.cpp
  2. 1 0
      lib/mapObjects/CGDwelling.h

+ 24 - 0
lib/mapObjects/CGDwelling.cpp

@@ -335,6 +335,30 @@ void CGDwelling::newTurn(CRandomGenerator & rand) const
 	updateGuards();
 }
 
+std::vector<Component> CGDwelling::getPopupComponents(PlayerColor player) const
+{
+	if (getOwner() != player)
+		return {};
+
+	std::vector<Component> result;
+
+	if (ID == Obj::CREATURE_GENERATOR1 && !creatures.empty())
+	{
+		for (auto const & creature : creatures.front().second)
+			result.emplace_back(ComponentType::CREATURE, creature, creatures.front().first);
+	}
+
+	if (ID == Obj::CREATURE_GENERATOR4)
+	{
+		for (auto const & creatureLevel : creatures)
+		{
+			if (!creatureLevel.second.empty())
+				result.emplace_back(ComponentType::CREATURE, creatureLevel.second.back(), creatureLevel.first);
+		}
+	}
+	return result;
+}
+
 void CGDwelling::updateGuards() const
 {
 	//TODO: store custom guard config and use it

+ 1 - 0
lib/mapObjects/CGDwelling.h

@@ -55,6 +55,7 @@ private:
 	void setPropertyDer(ui8 what, ui32 val) override;
 	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
 	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
+	std::vector<Component> getPopupComponents(PlayerColor player) const override;
 
 	void updateGuards() const;
 	void heroAcceptsCreatures(const CGHeroInstance *h) const;