Alright I might try to do something that sound good on paper but is incredibly stupid in a real situation.
I Joined a zip with what i'm doing.
From what I understand to share state between systems ( yes that does happen when you wwant to segment a big logic into multiples smaller chunk ) You need to use ComponentsSingleton.
What I find annoying is that it lead to a lot of repetitive code.
So I tried to do what's in the Zip. created an interface IStateComponent this is implementing IComponentData So it's a componentType
Created an ISystem BootSystem that , using reflexion, take all the IStateComponent implementation. In this case : ExampleState
Then create EntityQueries & store them into a static NativeHashMap into a ServicesStatic static class.
& Lastly ExampleAutomatedStateSystem take that reference with ServicesStatic.GetQuery<ExampleState>();
Bonus point : ExampleStateService -> still a static class have a GetExampleStateTime reference to the value in the component for usage in the OnUpdate of the system.
ExampleStateService.GetExampleStateTime(_exampleQuery) = SystemAPI.Time.DeltaTime;
Obviously here it's useless to do it this way but I was thinking on how to automate the creation of configs entity components from Scriptable Objects as a usecase.
Or to avoid having to copy the entity query code or even manually add a basic singleton query each time someone need a singleton component access.
What are your feedback on that ? I'm still in the process of learning about ECS & i'm trying to have a good framework to work with it.
Thanks !