Progress at last

It’s bank holiday Monday so instead of slacking and playing games all day long I played a bit in the morning then had to drag myself to the front of the computer to tackle the problem I have been long stuck on.

I had no idea how to reference the parent Entity inside the components. It was pretty simple really.

All I had to do was to add a function to my IComponent interface (and implement them in the Components).

EntityBase GetParentEntity()
void SetParentEntity(Entitybase entity).

Now when I add the component that I read from the Data I have in the XML file, I also add a reference to the parent entity.

component.SetParentEntity(this)

it was very simple and it was right in front of me all along, but it took a long thread from people from work to get the idea right in my head.

Now on to implementing SimpleAI. Now we are moving into more complex stuff.

2 Comments

  • By PaulECoyote, May 25, 2009 @ 10:53 am

    course double linking (parent<->child) like that creates a more complicated object graph, but I'm pretty sure I'm in the the minority of people who you know who think that might matter ;-)

  • By Hulshof, May 28, 2009 @ 8:41 am

    Yeah… I’ll just make the GetPhysics() Public because right now I can’t think of anything that might need to be extracted from the other entities.

Other Links to this Post

RSS feed for comments on this post. TrackBack URI

Leave a comment

WordPress Themes