TapestryEngine

A 2D Platformer Game Engine
Log | Files | Refs

5aacbee6025a7fc5220bfe8a0f47138865c592a4.svn-base (1555B)


      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 	}
     57 
     58 	bool EventProcess(Event eve)
     59 	{
     60 //		switch (*eve.GetEventType())
     61 //		{
     62 //		case ASSIGN_HANDLE:
     63 //			
     64 //			gCons->ConsPrintf("Handle Assigned to actor\n");
     65 //			return AssignHandle((Actor*)eve.GetReturnAddress());
     66 //			break;
     67 //		case GET_ACTOR_ADDRESS:
     68 //			return GetActorAddress(eve.GetEventData()->i);
     69 //			break;
     70 //		default:
     71 //			gCons->ConsPrintf("Actor Handle Manager received unrecognized event\n");
     72 //			return false;
     73 //			break;
     74 //		}
     75 		return true;
     76 	}
     77 
     78 protected:
     79 
     80 	int UpdateNextHandle() // see reclaim handle
     81 	{
     82 
     83 	}
     84 
     85 	int mNextNewID;
     86 	BinaryTree mHandleTree;
     87 
     88 };
     89 
     90 #endif