// Notify plugins.
await _eventManager.CallAsync(new PlayerExileEvent(Game, Game.GetClientPlayer(OwnerId)!, this));
}
+
+ public async ValueTask StartVanishAsync()
+ {
+ using var writer = Game.StartRpc(NetId, RpcCalls.StartVanish);
+ Rpc63StartVanish.Serialize(writer);
+ await Game.FinishRpcAsync(writer);
+ }
+
+ public async ValueTask StartAppearAsync(bool shouldAnimate)
+ {
+ using var writer = Game.StartRpc(NetId, RpcCalls.StartAppear);
+ Rpc65StartAppear.Serialize(writer, shouldAnimate);
+ await Game.FinishRpcAsync(writer);
+ }
}
}
}
Rpc62CheckVanish.Deserialize(reader, out var maxDuration);
- break;
+ return await HandleCheckVanish(sender, maxDuration);
}
case RpcCalls.StartVanish:
}
Rpc63StartVanish.Deserialize(reader);
- break;
+ return await HandleStartVanish(sender);
}
case RpcCalls.CheckAppear:
return false;
}
- Rpc64CheckAppear.Deserialize(reader, out bool shouldAnimate);
- break;
+ Rpc64CheckAppear.Deserialize(reader, out var shouldAnimate);
+ return await HandleCheckAppear(sender, shouldAnimate);
}
case RpcCalls.StartAppear:
return false;
}
- Rpc65StartAppear.Deserialize(reader, out _);
- break;
+ Rpc65StartAppear.Deserialize(reader, out var shouldAnimate);
+ return await HandleStartAppear(sender, shouldAnimate);
}
default:
return true;
}
+
+ private async ValueTask<bool> HandleCheckVanish(ClientPlayer sender, float maxDuration)
+ {
+ // TODO: Check if operation is taking place during lobby/meetings
+ // TODO: Check that the player unvanished before the maximum duration is reached
+ // If the game is host authoritive, the RPC is handled by the host, otherwise by the server
+ if (_game.IsHostAuthoritive)
+ {
+ return true;
+ }
+ else
+ {
+ await StartVanishAsync();
+ return false;
+ }
+ }
+
+ private async ValueTask<bool> HandleStartVanish(ClientPlayer sender)
+ {
+ if (!_game.IsHostAuthoritive)
+ {
+ if (await sender.Client.ReportCheatAsync(RpcCalls.StartVanish, CheatCategory.GameFlow, "Client tried to send StartVanish directly"))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private async ValueTask<bool> HandleCheckAppear(ClientPlayer sender, bool shouldAnimate)
+ {
+ // If the game is host authoritive, the RPC is handled by the host, otherwise by the server
+ if (_game.IsHostAuthoritive)
+ {
+ return true;
+ }
+ else
+ {
+ await StartAppearAsync(shouldAnimate);
+ return false;
+ }
+ }
+
+ private async ValueTask<bool> HandleStartAppear(ClientPlayer sender, bool shouldAnimate)
+ {
+ if (!_game.IsHostAuthoritive)
+ {
+ if (await sender.Client.ReportCheatAsync(RpcCalls.StartAppear, CheatCategory.GameFlow, "Client tried to send StartAppear directly"))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
}