mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
Merge pull request #598 from miniduikboot/fix/custom-rpc-gamelogic
Accept RPC's called on GameManager
This commit is contained in:
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)
|
||||
|
||||
Reference in new issue
Block a user