Forráskód Böngészése

vcmi: add obstacle animation helper functions

Konstantin 2 éve
szülő
commit
179cee3e88
2 módosított fájl, 39 hozzáadás és 0 törlés
  1. 30 0
      lib/battle/CObstacleInstance.cpp
  2. 9 0
      lib/battle/CObstacleInstance.h

+ 30 - 0
lib/battle/CObstacleInstance.cpp

@@ -60,6 +60,21 @@ bool CObstacleInstance::visibleForSide(ui8 side, bool hasNativeStack) const
 	return true;
 }
 
+const std::string & CObstacleInstance::getAnimation() const
+{
+	return getInfo().animation;
+}
+
+const std::string & CObstacleInstance::getAppearAnimation() const
+{
+	return getInfo().appearAnimation;
+}
+
+const std::string & CObstacleInstance::getAppearSound() const
+{
+	return getInfo().appearSound;
+}
+
 int CObstacleInstance::getAnimationYOffset(int imageHeight) const
 {
 	int offset = imageHeight % 42;
@@ -219,6 +234,21 @@ void SpellCreatedObstacle::battleTurnPassed()
 		turnsRemaining--;
 }
 
+const std::string & SpellCreatedObstacle::getAnimation() const
+{
+	return animation;
+}
+
+const std::string & SpellCreatedObstacle::getAppearAnimation() const
+{
+	return appearAnimation;
+}
+
+const std::string & SpellCreatedObstacle::getAppearSound() const
+{
+	return appearSound;
+}
+
 int SpellCreatedObstacle::getAnimationYOffset(int imageHeight) const
 {
 	int offset = imageHeight % 42;

+ 9 - 0
lib/battle/CObstacleInstance.h

@@ -48,6 +48,11 @@ struct DLL_LINKAGE CObstacleInstance
 
 	virtual void battleTurnPassed(){};
 
+	//Client helper functions, make it easier to render animations
+	virtual const std::string & getAnimation() const;
+	virtual const std::string & getAppearAnimation() const;
+	virtual const std::string & getAppearSound() const;
+
 	virtual int getAnimationYOffset(int imageHeight) const;
 
 	void toInfo(ObstacleChanges & info, BattleChanges::EOperation operation = BattleChanges::EOperation::ADD);
@@ -99,6 +104,10 @@ struct DLL_LINKAGE SpellCreatedObstacle : CObstacleInstance
 
 	void battleTurnPassed() override;
 
+	//Client helper functions, make it easier to render animations
+	const std::string & getAnimation() const override;
+	const std::string & getAppearAnimation() const override;
+	const std::string & getAppearSound() const override;
 	int getAnimationYOffset(int imageHeight) const override;
 
 	void fromInfo(const ObstacleChanges & info);