TapestryEngine

A 2D Platformer Game Engine
Log | Files | Refs

efbc6364f7a7098b8b79dbf2c0fa17eac4b8523a.svn-base (674B)


      1 #include "Event.h"
      2 
      3 bool EventFeed::Subscribe(EventReceiver* sub)
      4 {
      5 	for (int i = 0; i < (int)mSubs.size(); i++)
      6 	{
      7 		if (mSubs.at(i) == NULL)
      8 		{
      9 			mSubs.at(i) = sub;
     10 			return true;
     11 		}
     12 	}
     13 	mSubs.push_back(sub);
     14 	return false;
     15 }
     16 
     17 bool EventFeed::Unsubscribe(EventReceiver* sub)
     18 {
     19 	for (int i = 0; i < (int)mSubs.size(); i++)
     20 	{
     21 		if (mSubs.at(i) == sub)
     22 		{
     23 			mSubs.at(i) = NULL;
     24 			return true;
     25 		}
     26 	}
     27 	return false;
     28 }
     29 
     30 bool EventFeed::EventProcess(Event eve)
     31 {
     32 	if (*eve.GetEventType() == UNSUBSCRIBE)
     33 	{
     34 		return Unsubscribe((EventReceiver*)eve.GetEventData());
     35 	}
     36 	
     37 	for (int i = 0; i < (int)mSubs.size(); i++)
     38 	{
     39 		mSubs.at(i)->EventProcess(eve);
     40 	}
     41 	return true;
     42 }