mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-19 15:51:42 +00:00
To prevent needing to pull in Impostor.Hazel, use an extension method instead. Thanks Niko for researching this part Co-Authored-By: Niko233 <139348239+NikoCat233@users.noreply.github.com>
25 lines
693 B
C#
25 lines
693 B
C#
using System;
|
|
using Impostor.Api.Innersloth.GameOptions;
|
|
using Impostor.Hazel;
|
|
|
|
namespace Impostor.Server.Extensions;
|
|
|
|
public static class IGameOptionsExtensions
|
|
{
|
|
public static byte[] ToBytes(this IGameOptions gameOptions)
|
|
{
|
|
using var writer = MessageWriter.Get(MessageType.Unreliable);
|
|
writer.Write(gameOptions.Version);
|
|
writer.StartMessage(0);
|
|
writer.Write((byte)gameOptions.GameMode);
|
|
gameOptions.Serialize(writer);
|
|
writer.EndMessage();
|
|
return writer.ToByteArray(false);
|
|
}
|
|
|
|
public static string ToBase64String(this IGameOptions gameOptions)
|
|
{
|
|
return Convert.ToBase64String(gameOptions.ToBytes());
|
|
}
|
|
}
|