TapestryEngine

A 2D Platformer Game Engine
Log | Files | Refs

277989613d4ef02752c22c9316e4c2311da41355.svn-base (1593B)


      1 #ifndef ACTORHANDLE_H
      2 #define ACTORHANDLE_H
      3 
      4 #include "Console.h"
      5 #include "Event.h"
      6 #include "Utils.h"
      7 #include "Actor.h"
      8 
      9 struct HandleBind
     10 {
     11 	ActHandle mID;
     12 	EventReceiver* mAct;
     13 };
     14 
     15 class ActorHandleManager : public EventReceiver
     16 {
     17 public:
     18 
     19 	ActorHandleManager() : mNextNewID(0)
     20 	{
     21 		mHandleTree = BinaryTree();
     22 		//mHandleTree = &Node(mNextID);
     23 	}
     24 
     25 	int AssignHandle(Actor* act)
     26 	{
     27 		//HandleBind hb = { mNextID, act };
     28 		//mHandles.push_back(hb); //record the handle and Actor/EventReceiverPointer
     29 
     30 		//Node* Bind = new Node(mNextID, act);
     31 
     32 		mHandleTree.Insert(mNextNewID, act);
     33 
     34 		mNextNewID++;
     35 
     36 		return mNextNewID-1;
     37 		//return hb.mHandle;
     38 	}
     39 
     40 	int ReclaimHandle(int id) //I'm not sure if recycling ID's makes sense or how to do it
     41 	{
     42 		//mHandleTree.Search(id)->Delete()
     43 	}
     44 
     45 	Actor* GetActorAddress(int id)
     46 	{
     47 		Actor* Address = (Actor*)(mHandleTree.Search(id))->GetData();
     48 		if (Address == NULL)
     49 		{
     50 			return NULL;
     51 		}
     52 		else
     53 		{
     54 			return Address;
     55 		}
     56 		//return mHandles.at(mNextID).mAct;
     57 	}
     58 
     59 	bool EventProcess(Event eve)
     60 	{
     61 //		switch (*eve.GetEventType())
     62 //		{
     63 //		case ASSIGN_HANDLE:
     64 //			
     65 //			gCons->ConsPrintf("Handle Assigned to actor\n");
     66 //			return AssignHandle((Actor*)eve.GetReturnAddress());
     67 //			break;
     68 //		case GET_ACTOR_ADDRESS:
     69 //			return GetActorAddress(eve.GetEventData()->i);
     70 //			break;
     71 //		default:
     72 //			gCons->ConsPrintf("Actor Handle Manager received unrecognized event\n");
     73 //			return false;
     74 //			break;
     75 //		}
     76 		return true;
     77 	}
     78 
     79 protected:
     80 
     81 	int UpdateNextHandle() // see reclaim handle
     82 	{
     83 
     84 	}
     85 
     86 	int mNextNewID;
     87 	BinaryTree mHandleTree;
     88 
     89 };
     90 
     91 #endif