Sheet animation system
One of the objects sensitive to state changes is the sprite sheet animation system. Knowing an entity's state is of paramount importance, if we desire to apply animations that describe its current action:
S_SheetAnimation::S_SheetAnimation(SystemManager* l_systemMgr) : S_Base(System::SheetAnimation,l_systemMgr) { Bitmask req; req.TurnOnBit((unsigned int)Component::SpriteSheet); req.TurnOnBit((unsigned int)Component::State); m_requiredComponents.push_back(req); m_systemManager->GetMessageHandler()-> Subscribe(EntityMessage::State_Changed,this); }
As you can see, all we need are two component types and a subscription to a message type of State_Changed
. So far, so good!
Updating the sprite sheets can get a little involved, so let us delve right into it:
void S_SheetAnimation::Update(float l_dT){ EntityManager* entities = m_systemManager->GetEntityManager(); for(auto &entity : m_entities){ auto sheet = entities-> ...