About Store Forum Documentation Contact



Post Reply 
Getting Obj from World Manager
Author Message
xzessmedia Offline
Member

Post: #1
Getting Obj from World Manager
Hello again,

im trying to use Game::World.objGet to check for objects in range.

Code:
Memp<GameObject*> objs;
      ..
      ..
      ..
      Game::World.objGet(objs,Ball(radius, T.pos()));

can anybody explain me how the Memp init works?
thanks in advice
02-15-2014 07:43 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Getting Obj from World Manager
http://www.esenthel.com/?id=doc#Memory_Containers

There are some tutorials using objGet, probably Bloody Massacre
02-15-2014 10:37 PM
Find all posts by this user Quote this message in a reply
xzessmedia Offline
Member

Post: #3
RE: Getting Obj from World Manager
thanks greg
I get it working but i am only able to get Game.Obj types.
i want to get my subclass from Game.Obj cause it has actor and so on..
are there more ways?

what would be the best way in performance to iterate through objects?
02-16-2014 09:09 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Getting Obj from World Manager
You can use dynamic_cast (like the CAST macro).

That's also covered in the Bloody Massacre tut:

Code:
void autoPickUp() // automatically pick up nearby items
   {
      Memt<Game.Obj*> obj;
      Vec test_pos=ctrl.center()-Vec(0, ctrl.height()/2, 0);
      Game.World.objGet(obj, Ball(2, test_pos), OBJ_ITEM);

      REPA(obj)
         if(Item *item=CAST(Item, obj[i]))
            if(item.type==ITEM_WEAPON && item.mesh && Dist(test_pos, item.mesh->box*item.matrixScaled())<=ctrl.radius()+0.1f)
      {
         AddMessage(S+"Picked up "+item.name);
         itemPickUp(*item);
      }
   }
02-16-2014 09:12 AM
Find all posts by this user Quote this message in a reply
xzessmedia Offline
Member

Post: #5
RE: Getting Obj from World Manager
ah im sorry to forgot to read it again as you mentioned.

thank you very much this helped!
02-16-2014 09:42 AM
Find all posts by this user Quote this message in a reply
Post Reply