Merge pull request #598 from miniduikboot/fix/custom-rpc-gamelogic

Accept RPC's called on GameManager
This commit is contained in:
miniduikboot authored and GitHub committed 2024-06-14 07:13:20 +02:00
commit 34c14f69a4
2 files changed
+12 -4

No files matched your search

@@ -53,12 +53,20 @@ internal abstract class InnerGameManager : InnerNetObject, IInnerGameManager
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)
@@ -6,9 +6,9 @@ namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
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)