1 #ifndef __FOLLOWABLE_COMPONENT__ 2 #define __FOLLOWABLE_COMPONENT__ 3 4 #include "../ActorComponent.h" 5 6 //===================================================================================================================== 7 // FollowableComponent 8 //===================================================================================================================== 9 10 typedef std::map<std::string, Actor*> FollowingActorsMap; 11 12 class PositionComponent; 13 class ActorRenderComponent; 14 class FollowableComponent : public ActorComponent 15 { 16 public: 17 FollowableComponent(); 18 virtual ~FollowableComponent(); 19 20 static const char* g_Name; VGetName()21 virtual const char* VGetName() const override { return g_Name; } 22 23 virtual bool VInit(TiXmlElement* data) override; 24 virtual void VPostInit() override; 25 virtual TiXmlElement* VGenerateXml() override; 26 27 virtual void VUpdate(uint32 msDiff) override; 28 IsActive()29 bool IsActive() { return m_CurrentMsDuration > 0; } 30 void Activate(int msDuration); 31 void Deactivate(); 32 33 private: 34 // XML Data members 35 Point m_Offset; 36 std::string m_ImageSet; 37 std::string m_AnimationPath; 38 39 // Internal members 40 PositionComponent* m_pPositionComponent; 41 42 PositionComponent* m_pTargetPositionComponent; 43 ActorRenderComponent* m_pTargetRenderComponent; 44 Actor* m_pFollowingActor; 45 46 int m_MsDuration; 47 int m_CurrentMsDuration; 48 }; 49 50 #endif