About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
Get data from Reference<obj>
Author Message
alkirah Offline
Member

Post: #1
Get data from Reference<obj>
Reference<Obj> target; //set from mouse cursor click

I want to access data of the obj stored in the reference.

How can I reach a data from the npc class in the image below? (please note it's not always npc, it can be another class like monster, item, harvestable, etc)

Is there a way besides doing a CAST for every possible type?

like if I expand npc class, I see my data there, I just want to know if I can access it without using cast smile

Thanks smile


Attached File(s) Image(s)
   
(This post was last modified: 10-18-2011 05:49 AM by alkirah.)
10-18-2011 05:26 AM
Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #2
RE: Get data from Reference<obj>
What is the inheritance hierarchy for the NPC class? Also, is the _type member variable anything to do with the class type?
10-18-2011 01:47 PM
Visit this user's website Find all posts by this user Quote this message in a reply
alkirah Offline
Member

Post: #3
RE: Get data from Reference<obj>
STRUCT(Npc , Chr)
STRUCT(Monster , Chr)
STRUCT(WorldItem, Item)

_type is something that have to do with reference

if I open NPC, I see Chr between brackets like Npc is with that object.
10-18-2011 02:37 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Get data from Reference<obj>
try Game::Obj::type()
it should return OBJ_TYPE enum

if not, then use dynamic_cast (CAST)
10-18-2011 02:40 PM
Find all posts by this user Quote this message in a reply
alkirah Offline
Member

Post: #5
RE: Get data from Reference<obj>
Actually I don't want to get type, I want to get the object pointer so if it's a npc, I want it to return *Npc, a monster would return *Monster and a worlditem would return a *WorldItem, so I could use returnvalue->data

temporarly I added elements to a physx group and when mouse click is on something, I set target=Cur.obj() and targettype=phys_group.targettype (var names here are from memory so might be erroneous) so I know what class to cast.
(This post was last modified: 10-21-2011 07:57 PM by alkirah.)
10-21-2011 05:36 PM
Find all posts by this user Quote this message in a reply
Post Reply