public override async ValueTask<bool> HandleRpcAsync(ClientPlayer sender, ClientPlayer? target, RpcCalls call, IMessageReader reader)
{
+ // Let all logic components process this RPC. If at least one component handles it, return true.
+ var result = false;
foreach (var logicComponent in _logicComponents)
{
- await logicComponent.HandleRpcAsync(call, reader);
+ result |= await logicComponent.HandleRpcAsync(call, reader);
}
- return true;
+ // If no component accepted it, try and find a custom RPC that can deal with it.
+ if (!result)
+ {
+ result |= await base.HandleRpcAsync(sender, target, call, reader);
+ }
+
+ return result;
}
public override ValueTask<bool> SerializeAsync(IMessageWriter writer, bool initialState)
internal abstract class GameLogicComponent
{
- public virtual ValueTask HandleRpcAsync(RpcCalls callId, IMessageReader reader)
+ public virtual ValueTask<bool> HandleRpcAsync(RpcCalls callId, IMessageReader reader)
{
- throw new NotImplementedException($"Unhandled RpcCall {callId}");
+ return ValueTask.FromResult(false);
}
public virtual ValueTask<bool> SerializeAsync(IMessageWriter writer, bool initialState)