Struct RpcExecutor
Struct that can be used to simplify writing systems and jobs that deserialize and execute received rpc commands.
Assembly: solution.dll
Syntax
public struct RpcExecutor
Methods
Name |
Description |
ExecuteCreateRequestComponent<TActionSerializer, TActionRequest>(ref Parameters)
|
Helper method that can be used to implement the execute method for the IRpcCommandSerializer<T>
interface.
By calling the ExecuteCreateRequestComponent, a new entity (with a TActionRequest and
a ReceiveRpcCommandRequest component) is created.
It is the users responsibility to write a system that consumes the created rpcs entities. For example:
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);
}
}
|