DOTSNET comes with dependency injection for all systems in the server/client worlds.
Dependency injection is a comfort feature that you don’t need to use, but you probably will because it makes your life a lot easier.
Often times, a system might need to use another system:
usingDOTSNET;[ServerWorld]publicclassTestSystem:ComponentSystem{voidDoSomething(){ // send a messageGetExistingSystem<NetworkServerSystem>().Send(...);}voidDoSomethingElse(){ // send a messageGetExistingSystem<NetworkServerSystem>().Send(...);}}
For performance and ease of use, it makes sense to cache the system once in OnCreate:
Caching all required systems in OnStartRunning can get cumbersome. This is where Dependency Injection comes in. Simply use the [AutoAssign] attribute:
DOTSNET simply initializes all[AutoAssign]systems by calling World.GetExistingSystem at startup.
A system in the DefaultWorld can use [AutoAssign] for any other system in the Default world.
A system in the ClientWorld can use [AutoAssign] for any other system in the Client world.
A system in the ServerWorld can use [AutoAssign] for any other system in the Server world.