So I have an optional netcode layer sitting on top of Unity’s ECS, and when the netcode is enabled, every entity that should be updated by this client only is given a flag: NetCodeOwnershipFlag
Therefore, in some of my systems, where I call Entities.ForEach(...)
, I would like to add .WithAll<NetCodeOwnershipFlag>()
. However, I only want to do this when multiplayer is enabled. Thus, this extension method:
[AllowMultipleInvocationsAttribute]
public static ForEachLambdaJobDescription WithNetCodeOwnership(this ForEachLambdaJobDescription builder)
{
if (IsMultiplayer)
{
return builder.WithAll<NetCodeOwnershipFlag>();
}
return builder;
}
This means that consumers of my netcode API don’t need to care what this is doing under the hood.
However, AllowMultipleInvocationsAttribute
is internal, so it just needs to be exposed (assuming that does not break your design intent).
Optionally, another way to elegantly solve this would be appreciated.