Struct RpcExecutor
Struct that can be used to simplify writing systems and jobs that deserialize and execute received rpc commands.
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
public struct RpcExecutor
Methods
ExecuteCreateRequestComponent<TActionSerializer, TActionRequest>(ref Parameters)
Helper method that can be used to implement the execute method for the IRpcTActionRequest
and
a Receive
public struct MyRpcConsumeSystem : ISystem
{
private Query rcpQuery;
public void OnCreate(ref SystemState state)
{
var builder = new EntityQueryBuilder(Allocator.Temp).WithAll<MyRpc, ReceiveRpcCommandRequestComponent>();
rcpQuery = state.GetEntityQuery(builder);
}
public void OnUpdate(ref SystemState state)
{
foreach(var rpc in SystemAPI.Query<MyRpc>().WithAll<ReceiveRpcCommandRequestComponent>())
{
//do something with the rpc
}
//Consumes all of them
state.EntityManager.DestroyEntity(rpcQuery);
}
}
Declaration
public static Entity ExecuteCreateRequestComponent<TActionSerializer, TActionRequest>(ref RpcExecutor.Parameters parameters) where TActionSerializer : struct, IRpcCommandSerializer<TActionRequest> where TActionRequest : unmanaged, IComponentData
Parameters
Type | Name | Description |
---|---|---|
Rpc |
parameters | Container for Entity |
Returns
Type | Description |
---|---|
Entity | Created entity for RPC request. Name of the Entity is set as 'NetCodeRPC'. |
Type Parameters
Name | Description |
---|---|
TActionSerializer | Struct of type IRpc |
TActionRequest | Unmanaged type of IComponent |