I'm playing around with the component design. This is for just testing/trying out so nothing too serious. My components have events as outputs and functions as inputs. I want to stay very strict to decoupling so in no situation is a component to know about ANY other component inside itself. Instead the games created with this design would have a central place that does all the hooking up of events to functions between all components to create the actual flow of the game.
An easy example would be having a Health component attached to a player game object that has an event called OnHealthUpdated. Then having a HUD component that has a function called HealthUpdated. Create the 2 objects, attach their components and hookup the players OnHealthUpdated to the huds HealthUpdated() function and now everytime the players health components is changed it'll fire this event which will tell the hud component to update the display of health with the value that was passed to the event & function.
That's easy and there are many components like this. However when I get into enemy/player interaction things get a little more fuzzier in my head. My enemy component can do a bounding box check to see what models are all this area. However, to keep to the decoupling I can't within the result query for "player" or anything like that. Remember this is more research of ways than, I need to make a game right now with this.
So I'm looking for ideas around enemy/player interaction that is decoupled in their components. Ideally events need to be fired and functions need to be called from those events. The enemy has to somehow know the player from only events/functions linked.
Each game object is just a generic class that stores a list of components. For some reason I'm hesitant to pass around GameObject pointers to events/function. Not sure if I have to get over that or what. In my example above I'm passing around a simple health value (int) and it seems less coupled than passing a GameObject*, but since GameObject* is so generic maybe it's ok? Maybe I should track ID's (long) for each GameObject and that's what gets passed around instead? Then when I create enemy components I can just pass it the player's ID so they know what they are looking for?
Any ideas around this?