unity – Decouple shared data from consumers

So, I was a former unity user, and after a big pause in game dev decided to try out monogame ( I’m a software engineer IRL so I’d figure this is the best way to go ).

So in unity I was using scriptable objects to de couple my data from their mutators / consumers, like explained in here actually


So f.e. I would have a S.O. that represented my player’s health, and my player entity would just have it as a public field and in the editor I could drag the S.O. in.

My UI was also interested in the health, so I could just expose a public field on my health bar and it would consume it.

Hence my data was decoupled from the once using it and no dependencies where between different systems.

So i’d like to reproduce this in monogame.

I was thinking of using something like a service provider / locator pattern where I could register the health for my player f.e., and each system needing it would retrieve it trough that.

This seems less flexible though then the way unity show’s it, as i could’ve multiple ‘healths’ registered, and to get the right one would mean I’d have to find a way to retrieve the right one ( which is totally possible but more complex then just dragging in the right S.O. in Unity ).

Someone found a nice way of doing this before I dive in ?