Thus you can establish by policy a well-known set of interfaces, and with policy you guarantee to the game objects that the interfaces are valid when you call their Update() function. But also through policy you make it known that the pointers can change at any other time, and that the values may be different in between successive calls to Update(). They are valid for a limited time only. You can request a pointer to the current audio subsystem and tell it to play an audio clip, but by policy you are not to modify the pointer to the audio subsystem, nor are you are allowed to store the pointer, it is treated as invalid once the Update() function is complete.
So I should call ServiceLocator::GetRenderer() every update/render, instead of storing it once in the constructor? Isn't that kind of inefficient?
But other than that it sounds interesting, but also like a lot of extra work and complexity.
Implementing NullSound, NullRender etc, and designing the system around being able to run in a "null" state.
I can imagine it becoming kind of complicated when functions return something, like a null version of TextureCache::LoadTexture(), it would have to return a NullTexture, or some kind of default texture... hmm...
Whatever, I think I will probably give ServiceLocator a try. I have to rewrite the whole render code anyway, since I did not think ahead.
@haegarr:
How would I go about checking the state of Player inside of PlayerController?
Provide accessors for every member, like GetPosition() etc, or declare PlayerController a friend class, or something else?
Should I also seperate logic for sound playing etc into something like PlayerSoundController, or put it all into one PlayerController?
Some kind of messaging system sounds like it would make things easier, but I'm not sure if I can come up with a good one.
I coded in different scripting languages for different games (like coding Addons for World of Warcraft) and there it was always soooo easy
Register for an event, through a global variable and then just pass a function to play a sound, like event.Register(PLAYER_TAKE_DAMAGE, playMySound).
Boom, done!
I really need to learn more about decoupling and abstraction... that's one of my weaknesses, everything in my code is so "direct".