Original Post
I've been trying (sort of unsuccessfully) to flatten out my object tree and convert to using something similar to a componenet based design. I've read all I could find here, along with the postmortem on dungeon siege, and the slide show presentation about component models used in dungeon siege. Without seeing any actual implementation, I'm having a difficult time understanding several parts of this design. the first problem i have is more or less the proper way to break down object specific code into componenets and still have them work together without tightly coupling my component objects - take for example, collision reaction type code. Generally, i have seen: 1) each object handling its own collision such as object1.collided(object2), which is then followed by a switch statement for the type of object, or 2) using a double dispatch type thing to call the correct function Object::collideWith(object &obj){ obj.collideWith(this); } i have no clue how i would break this behavior down with components..im assuming i would have a collision routing function, that subscribes to a global ON_COLLISION event, which then sends the event and associated info on down to the objects. The object then passes that message and associated data on to the component registered to that event...but at that point i'm lost. I can see how this would work with something simple such as a "ExplodeOnCollision" component, but a little trouble conceptualizing how i would handle something such as a player collision component, that has to switch depending on the type of collision (since double dispatching no longer would work here), and would require specific information from the object, from a component that may or may not exist. it seems that this style of making objects just moves from having individual classes per object (which contains specific collision handling, actions, behaviors), to a single base object with separate components for every object (a playerCollision component, playerBehavior compoenent, enemySoldierBehavior componenet).. i think i may be misunderstanding exactly how this is used...any help would be appreciated, even if its to say i write way to much and say very little...