Monday, May 25, 2009

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:

Blogger PaulECoyote said...

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 ;-)

6:53 PM  
Blogger Hulshof said...

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.

4:41 PM  

Post a Comment

<< Home

My Photo
Name: Hulshof
Location: Guildford, Surrey, United Kingdom

Gameplay and Cutscene Scripter At Lionhead Studios. Also 2D/3D Artist, Writer/Blogger, XNA enthusiast, and Videogame addict in my spare time.

Powered by Blogger

Atom RSS feed Follow me on Twitter Facebook
Delicious LinkedIn Last.fm
Last.fm Last.fm StumbleUpon
YouTube