D
D
DOTSNET
Search…
Selective System Authoring

Systems with Multiple Implementations

In some cases, we can have an abstract system type with multiple implementations. For example:
    Transports: we have one abstract TransportServer/ClientSystem class, but can have multiple implementations like kcp, and later Websockets/Steam/etc.
    Interest Management: we have one abstract InterestManagementSystem, and an explicit BruteForceInterestManagementSystem. We might also have a grid system, room system, etc. later.
By default, ECS always creates all systems in the project.
This is a problem, because even if our project has 3 different interest management implementations, we only ever want to use one of them.

The Solution

The solution is to disable systems by default, and only enable them if an authoring component is added to the scene:
1. Add the [DisableAutoCreation] attribute to systems with multiple implementations:
1
using DOTSNET;
2
3
[ServerWorld]
4
[DisableAutoCreation]
5
public class BruteForceInterestManagementSystem : InterestManagementSystem
6
{
7
}
Copied!
2. Create an Authoring component that implements our SelectiveSystemAuthoring interface:
1
using DOTSNET;
2
3
public class BruteForceAuthoring : MonoBehaviour, SelectiveSystemAuthoring
4
{
5
// add system if Authoring is used
6
public Type GetSystemType() =>
7
typeof(BruteForceInterestManagementSystem);
8
}
Copied!
So far, the system is still disabled by default.
3. Add the Authoring component to the NetworkServer/NetworkClient GameObject:
When DOTSNET starts, it will scan the Hierarchy for all SelectiveSystemAuthoring components, and then create the systems specified in GetSystemType automatically.
Last modified 5mo ago