Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024.6.18.0 #64

Merged
merged 76 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
60482ac
ゲーム終了時の幽霊化にIsDeadを元に戻す処理を追加
Hyz-sui Mar 15, 2024
bbe0213
Merge pull request #466 from tukasa0001/fix/HaisonAutoMute
Hyz-sui Apr 8, 2024
708e1ef
RpcProtectedMurderPlayer時、他視点へ守護を通知しない
kou-hetare Apr 17, 2024
3ab741c
Merge pull request #475 from tukasa0001/feature/SuppressesGuardianNotice
kou-hetare Apr 17, 2024
25c6b99
Airshipでノーマルスポーンの時SnapToを実行する
kou-hetare Apr 19, 2024
9af6a72
Merge pull request #476 from tukasa0001/fix/AirshipNormalSpawn
kou-hetare Apr 19, 2024
9b2812c
Desyncベントキャンセルが出来なくなっていたため、処理変更
kou-hetare Apr 22, 2024
96849fd
Merge pull request #478 from tukasa0001/fix/OnEnterVent
kou-hetare Apr 27, 2024
a32a843
CanUseKillButton例外の排除
kou-hetare May 11, 2024
74991f7
TaskPanelBehaviourのGetCustomRole失敗排除
kou-hetare May 11, 2024
930d932
シェリフ誤爆前に死因を設定するよう変更
kou-hetare May 11, 2024
89956a6
退出失敗時用の新規エラーを追加
Hyz-sui May 12, 2024
be32ead
エラーメッセージの翻訳を追加
Hyz-sui May 12, 2024
3d14a4c
切断のエラー処理を追加
Hyz-sui May 12, 2024
9184bb0
Merge pull request #480 from tukasa0001/fix/SheriffMissFire
kou-hetare May 12, 2024
14564df
ErrorTextに黒色の背景を追加
Hyz-sui May 12, 2024
2437f77
Fix bug - April Fools mode not sync for clients
Tommy-XL Apr 4, 2024
bfedcc5
Merge pull request #482 from tukasa0001/feature/ErrorTextBg
Hyz-sui Jun 17, 2024
00b3b1b
Merge pull request #483 from tukasa0001/fetch/1312
Hyz-sui Jun 17, 2024
e060d3f
Merge pull request #481 from tukasa0001/fix/OnPlayerLeftPostfix
Hyz-sui Jun 17, 2024
2671fb4
Merge pull request #484 from tukasa0001/fix/ReduceExceptionInLobby
kou-hetare Jun 17, 2024
6521efc
PlayerInfo変更の対応
kou-hetare Jun 18, 2024
aeb6c87
Map変更はデフォルトで出来るので削除
kou-hetare Jun 18, 2024
c8fa970
ゲーム内通知の送り先を変更
kou-hetare Jun 19, 2024
2360f1e
GameSettingsがなくなったため削除
kou-hetare Jun 19, 2024
112c2c2
GameOptionsのVer変更
kou-hetare Jun 19, 2024
9bd9fef
PlayerInfo対応
kou-hetare Jun 19, 2024
929a17c
TempDataをEndGameResultに置き換え
kou-hetare Jun 19, 2024
ae72480
SetNameRPCに増えたNetworkedPlayerInfoのNetIdの書き込みを追加
Hyz-sui Jun 20, 2024
201c188
ゲームオプション V07 -> V08
Hyz-sui Jun 20, 2024
7ca8b89
PlayerOutfitの移動に対応
Hyz-sui Jun 20, 2024
cc93fb1
旧SetRoleがコルーチンとなったCoSetRoleへ移行
Hyz-sui Jun 20, 2024
22cbccb
RpcSetTasksのパッチを修復
Hyz-sui Jun 20, 2024
76f7889
名前変更に追従 RoleOptionSetting#TitleText -> titleText
Hyz-sui Jun 20, 2024
fa65258
バージョン表示を右上へ移動
Hyz-sui Jun 22, 2024
027b889
ロビーのUIを調整
Hyz-sui Jun 22, 2024
1289ba1
ゲーム設定UIを新UIに追従して調整
Hyz-sui Jun 22, 2024
f9316a6
守護天使の無効化を修復
Hyz-sui Jun 23, 2024
35c877e
ChangeTabでTOHタブを隠す処理をPrefixに変更
Hyz-sui Jun 23, 2024
5bec8a9
SetRoleのcanOverride追加漏れ
kou-hetare Jun 24, 2024
10ace44
役職スポーン確率オプションの専用クラスを作成
Hyz-sui Jun 27, 2024
5effb49
役職出現率オプションの作成を新クラスを使ったものに変更
Hyz-sui Jun 27, 2024
2b1503a
ロールオプションの背景色をロール色に,文字色を無職にそれぞれ変更
Hyz-sui Jun 27, 2024
02d50f5
名前の衝突を避けるためOptionItemフォルダをOptionItemsに改名
Hyz-sui Jun 27, 2024
24f94af
余計な空行を削除
Hyz-sui Jun 27, 2024
ddf42e2
メインオプションカテゴリのアイコンを円形のボタンに合うように変更
Hyz-sui Jun 27, 2024
baab7a0
Merge pull request #486 from tukasa0001/feature/NewMainOptionButton
Hyz-sui Jun 28, 2024
07c7674
カスタムロールに新バニラロールを追加
Hyz-sui Jun 29, 2024
8a7ba95
新バニラロールのラッパーを作成
Hyz-sui Jun 29, 2024
8c29802
必要な箇所にバニラロールの分岐を追加
Hyz-sui Jun 29, 2024
497b611
バニラロールの翻訳を追加
Hyz-sui Jun 29, 2024
521cc83
役職設定タイトルの着色を削除
Hyz-sui Jun 29, 2024
a950621
デバッグモード時以外はファントムを無効化
Hyz-sui Jun 29, 2024
f85120c
Merge pull request #485 from tukasa0001/feature/RoleOptionColor
Hyz-sui Jun 29, 2024
5de64db
Merge pull request #487 from tukasa0001/fix/Support20240618-VanillaRoles
Hyz-sui Jun 29, 2024
9bdcf89
Merge pull request #488 from tukasa0001/fix/Support20240618-DisablePh…
Hyz-sui Jun 29, 2024
65fb3f7
プレリリースかどうかのプロパティを作成
Hyz-sui Jun 29, 2024
e949fdf
プレリリースであることを示す表示を追加
Hyz-sui Jun 29, 2024
2e6df0b
カモフラージュのRPCの増えた引数を追加
Hyz-sui Jun 29, 2024
c7e4819
Merge branch 'fix/Support20240618' of https://github.com/tukasa0001/T…
Hyz-sui Jun 29, 2024
c325151
Merge pull request #489 from tukasa0001/feature/Prerelease
Hyz-sui Jun 30, 2024
3eb722c
サポートアモアスバージョンを2024.6.18へ変更
Hyz-sui Jun 30, 2024
b287d5f
readmeのアモアスバージョンを2024.6.18に変更
Hyz-sui Jun 30, 2024
5e94ecb
Merge pull request #490 from tukasa0001/fix/Support20240618
Hyz-sui Jun 30, 2024
60c8511
エラーメッセージの翻訳の表現を調整
Hyz-sui Jun 30, 2024
f733b3f
右上のテキストのzを調整
Hyz-sui Jun 30, 2024
5beb111
バージョンを5.1.7に変更
Hyz-sui Jun 30, 2024
0c76cba
Merge pull request #494 from tukasa0001/change/ErrorMsgTranslation
Hyz-sui Jul 1, 2024
3071410
Merge pull request #493 from tukasa0001/fix/PingCredentialPos
Hyz-sui Jul 1, 2024
7356a02
Merge pull request #492 from tukasa0001/verUp/5.1.7
Hyz-sui Jul 3, 2024
056e237
Merge pull request #491 from tukasa0001/doc/Readme5.1.7
Hyz-sui Jul 3, 2024
fce8043
Merge pull request #1318 from tukasa0001/develop-5.1.7
yurinakira Jul 10, 2024
321f83a
Merge branch 'main' into work/Merge5.1.7H
Hyz-sui Jul 13, 2024
7bcab65
Merge pull request #63 from Hyz-sui/work/Merge5.1.7H
Hyz-sui Jul 13, 2024
e375683
version 2024.6.18.0
Hyz-sui Jul 14, 2024
4677f02
doc: readme sns link tw -> bsky
Hyz-sui Jul 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Helpers/CustomRolesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ public static bool IsVanilla(this CustomRoles role)
role is CustomRoles.Crewmate or
CustomRoles.Engineer or
CustomRoles.Scientist or
CustomRoles.Tracker or
CustomRoles.Noisemaker or
CustomRoles.GuardianAngel or
CustomRoles.Impostor or
CustomRoles.Shapeshifter;
CustomRoles.Shapeshifter or
CustomRoles.Phantom;
}

public static CustomRoleTypes GetCustomRoleTypes(this CustomRoles role)
Expand All @@ -74,7 +77,10 @@ public static int GetCount(this CustomRoles role)
{
CustomRoles.Engineer => roleOpt.GetNumPerGame(RoleTypes.Engineer),
CustomRoles.Scientist => roleOpt.GetNumPerGame(RoleTypes.Scientist),
CustomRoles.Tracker => roleOpt.GetNumPerGame(RoleTypes.Tracker),
CustomRoles.Noisemaker => roleOpt.GetNumPerGame(RoleTypes.Noisemaker),
CustomRoles.Shapeshifter => roleOpt.GetNumPerGame(RoleTypes.Shapeshifter),
CustomRoles.Phantom => roleOpt.GetNumPerGame(RoleTypes.Phantom),
CustomRoles.GuardianAngel => roleOpt.GetNumPerGame(RoleTypes.GuardianAngel),
CustomRoles.Crewmate => roleOpt.GetNumPerGame(RoleTypes.Crewmate),
_ => 0
Expand All @@ -94,7 +100,10 @@ public static int GetChance(this CustomRoles role)
{
CustomRoles.Engineer => roleOpt.GetChancePerGame(RoleTypes.Engineer),
CustomRoles.Scientist => roleOpt.GetChancePerGame(RoleTypes.Scientist),
CustomRoles.Noisemaker => roleOpt.GetChancePerGame(RoleTypes.Noisemaker),
CustomRoles.Tracker => roleOpt.GetChancePerGame(RoleTypes.Tracker),
CustomRoles.Shapeshifter => roleOpt.GetChancePerGame(RoleTypes.Shapeshifter),
CustomRoles.Phantom => roleOpt.GetChancePerGame(RoleTypes.Phantom),
CustomRoles.GuardianAngel => roleOpt.GetChancePerGame(RoleTypes.GuardianAngel),
CustomRoles.Crewmate => roleOpt.GetChancePerGame(RoleTypes.Crewmate),
_ => 0
Expand Down
27 changes: 15 additions & 12 deletions Modules/AntiBlackout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,28 @@ public static void RestoreIsDead(bool doSend = true, [CallerMemberName] string c
public static void SendGameData([CallerMemberName] string callerMethodName = "")
{
logger.Info($"SendGameData is called from {callerMethodName}");
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
// 書き込み {}は読みやすさのためです。
writer.StartMessage(5); //0x05 GameData
foreach (var playerinfo in GameData.Instance.AllPlayers)
{
writer.Write(AmongUsClient.Instance.GameId);
writer.StartMessage(1); //0x01 Data
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
// 書き込み {}は読みやすさのためです。
writer.StartMessage(5); //0x05 GameData
{
writer.WritePacked(GameData.Instance.NetId);
GameData.Instance.Serialize(writer, true);
writer.Write(AmongUsClient.Instance.GameId);
writer.StartMessage(1); //0x01 Data
{
writer.WritePacked(playerinfo.NetId);
playerinfo.Serialize(writer, true);

}
writer.EndMessage();
}
writer.EndMessage();
}
writer.EndMessage();

AmongUsClient.Instance.SendOrDisconnect(writer);
writer.Recycle();
AmongUsClient.Instance.SendOrDisconnect(writer);
writer.Recycle();
}
}
public static void OnDisconnect(GameData.PlayerInfo player)
public static void OnDisconnect(NetworkedPlayerInfo player)
{
// 実行条件: クライアントがホストである, IsDeadが上書きされている, playerが切断済み
if (!AmongUsClient.Instance.AmHost || !IsCached || !player.Disconnected) return;
Expand Down
15 changes: 10 additions & 5 deletions Modules/Camouflague.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace TownOfHost
{
static class PlayerOutfitExtension
{
public static GameData.PlayerOutfit Set(this GameData.PlayerOutfit instance, string playerName, int colorId, string hatId, string skinId, string visorId, string petId)
public static NetworkedPlayerInfo.PlayerOutfit Set(this NetworkedPlayerInfo.PlayerOutfit instance, string playerName, int colorId, string hatId, string skinId, string visorId, string petId)
{
instance.PlayerName = playerName;
instance.ColorId = colorId;
Expand All @@ -15,7 +15,7 @@ public static GameData.PlayerOutfit Set(this GameData.PlayerOutfit instance, str
instance.PetId = petId;
return instance;
}
public static bool Compare(this GameData.PlayerOutfit instance, GameData.PlayerOutfit targetOutfit)
public static bool Compare(this NetworkedPlayerInfo.PlayerOutfit instance, NetworkedPlayerInfo.PlayerOutfit targetOutfit)
{
return instance.ColorId == targetOutfit.ColorId &&
instance.HatId == targetOutfit.HatId &&
Expand All @@ -24,17 +24,17 @@ public static bool Compare(this GameData.PlayerOutfit instance, GameData.PlayerO
instance.PetId == targetOutfit.PetId;

}
public static string GetString(this GameData.PlayerOutfit instance)
public static string GetString(this NetworkedPlayerInfo.PlayerOutfit instance)
{
return $"{instance.PlayerName} Color:{instance.ColorId} {instance.HatId} {instance.SkinId} {instance.VisorId} {instance.PetId}";
}
}
public static class Camouflage
{
static GameData.PlayerOutfit CamouflageOutfit = new GameData.PlayerOutfit().Set("", 15, "", "", "", "");
static NetworkedPlayerInfo.PlayerOutfit CamouflageOutfit = new NetworkedPlayerInfo.PlayerOutfit().Set("", 15, "", "", "", "");

public static bool IsCamouflage;
public static Dictionary<byte, GameData.PlayerOutfit> PlayerSkins = new();
public static Dictionary<byte, NetworkedPlayerInfo.PlayerOutfit> PlayerSkins = new();

[GameModuleInitializer]
public static void Init()
Expand Down Expand Up @@ -104,27 +104,32 @@ public static void RpcSetSkin(PlayerControl target, bool ForceRevert = false, bo

target.SetColor(newOutfit.ColorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetColor)
.Write(target.Data.NetId)
.Write(newOutfit.ColorId)
.EndRpc();

target.SetHat(newOutfit.HatId, newOutfit.ColorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetHatStr)
.Write(newOutfit.HatId)
.Write(target.GetNextRpcSequenceId(RpcCalls.SetHatStr))
.EndRpc();

target.SetSkin(newOutfit.SkinId, newOutfit.ColorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetSkinStr)
.Write(newOutfit.SkinId)
.Write(target.GetNextRpcSequenceId(RpcCalls.SetSkinStr))
.EndRpc();

target.SetVisor(newOutfit.VisorId, newOutfit.ColorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetVisorStr)
.Write(newOutfit.VisorId)
.Write(target.GetNextRpcSequenceId(RpcCalls.SetVisorStr))
.EndRpc();

target.SetPet(newOutfit.PetId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetPetStr)
.Write(newOutfit.PetId)
.Write(target.GetNextRpcSequenceId(RpcCalls.SetPetStr))
.EndRpc();

sender.SendMessage();
Expand Down
1 change: 1 addition & 0 deletions Modules/CustomRpcSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public static void RpcSetRole(this CustomRpcSender sender, PlayerControl player,
{
sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetRole, targetClientId)
.Write((ushort)role)
.Write(false)
.EndRpc();
}
public static void RpcMurderPlayer(this CustomRpcSender sender, PlayerControl player, PlayerControl target, int targetClientId = -1)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void Enable(string tag, bool toGame = false)
public static void SendInGame(string text, bool isAlways = false)
{
if (!isEnable) return;
if (DestroyableSingleton<HudManager>._instance) DestroyableSingleton<HudManager>.Instance.Notifier.AddItem(text);
if (DestroyableSingleton<HudManager>._instance) DestroyableSingleton<HudManager>.Instance.Notifier.AddDisconnectMessage(text);
}
private static void SendToFile(string text, LogLevel level = LogLevel.Info, string tag = "", bool escapeCRLF = true, int lineNumber = 0, string fileName = "")
{
Expand Down
43 changes: 40 additions & 3 deletions Modules/ErrorText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,32 @@ public static void Create(TMPro.TextMeshPro baseText)
Text.color = Color.red;
Text.outlineColor = Color.black;
Text.alignment = TMPro.TextAlignmentOptions.Top;

// 背景
var bgObject = new GameObject("Background") { layer = LayerMask.NameToLayer("UI") };
var bgRenderer = instance.background = bgObject.AddComponent<SpriteRenderer>();
var bgTexture = new Texture2D(Screen.width, 150, TextureFormat.ARGB32, false);
for (var x = 0; x < bgTexture.width; x++)
{
for (var y = 0; y < bgTexture.height; y++)
{
bgTexture.SetPixel(x, y, new(0f, 0f, 0f, 0.6f));
}
}
bgTexture.Apply();
var bgSprite = Sprite.Create(bgTexture, new(0, 0, bgTexture.width, bgTexture.height), new(0.5f, 1f /* 上端の真ん中を中心とする */ ));
bgRenderer.sprite = bgSprite;
var bgTransform = bgObject.transform;
bgTransform.parent = instance.transform;
bgTransform.localPosition = new(0f, TextOffsetY, 1f);
bgObject.SetActive(false);
}

public TMPro.TextMeshPro Text;
private SpriteRenderer background;
public Camera Camera;
public List<ErrorData> AllErrors = new();
public Vector3 TextOffset = new(0, 0.3f, -1000f);
public Vector3 TextOffset = new(0, TextOffsetY, -1000f);
public void Update()
{
AllErrors.ForEach(err => err.IncreaseTimer());
Expand Down Expand Up @@ -95,13 +115,13 @@ public void UpdateText()
}
if (maxLevel == 0)
{
Text.enabled = false;
Hide();
}
else
{
if (!HnSFlag)
text += $"{GetString($"ErrorLevel{maxLevel}")}";
Text.enabled = true;
Show();
}
if (GameStates.IsInGame && maxLevel != 3)
text += $"\n{GetString("TerminateCommand")}: Shift+L+Enter";
Expand All @@ -112,6 +132,16 @@ public void Clear()
AllErrors.RemoveAll(err => err.ErrorLevel != 3);
UpdateText();
}
private void Show()
{
Text.enabled = true;
background.gameObject.SetActive(true);
}
private void Hide()
{
Text.enabled = false;
background.gameObject.SetActive(false);
}

public class ErrorData
{
Expand All @@ -138,6 +168,8 @@ public override string ToString()
}

public bool HnSFlag;

const float TextOffsetY = 0.3f;
}
public enum ErrorCode
{
Expand All @@ -155,6 +187,11 @@ public enum ErrorCode
OptionIDDuplicate = 001_010_3, // 001-010-3 オプションIDが重複している(DEBUGビルド時のみ)
// 002 サポート関連
UnsupportedVersion = 002_000_1, // 002-000-1 AmongUsのバージョンが古い

// 010 参加/退出関連
OnPlayerLeftPostfixFailedInGame = 010_000_2, // 010-000-2 OnPlayerLeftPatch.Postfixがゲーム中に失敗
OnPlayerLeftPostfixFailedInLobby = 010_001_2, // 010-001-2 OnPlayerLeftPatch.Postfixがロビーで失敗

// ==========
// 000 Test
NoError = 0000000, // 000-000-0 No Error
Expand Down
10 changes: 6 additions & 4 deletions Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static int GetClientId(this PlayerControl player)
var client = player.GetClient();
return client == null ? -1 : client.Id;
}
public static CustomRoles GetCustomRole(this GameData.PlayerInfo player)
public static CustomRoles GetCustomRole(this NetworkedPlayerInfo player)
{
return player == null || player.Object == null ? CustomRoles.Crewmate : player.Object.GetCustomRole();
}
Expand Down Expand Up @@ -152,6 +152,7 @@ public static void RpcSetNamePrivate(this PlayerControl player, string name, boo

var clientId = seer.GetClientId();
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetName, Hazel.SendOption.Reliable, clientId);
writer.Write(player.Data.NetId);
writer.Write(name);
writer.Write(DontShowOnModdedClient);
AmongUsClient.Instance.FinishRpcImmediately(writer);
Expand All @@ -163,11 +164,12 @@ public static void RpcSetRoleDesync(this PlayerControl player, RoleTypes role, i
if (player == null) return;
if (AmongUsClient.Instance.ClientId == clientId)
{
player.SetRole(role);
player.StartCoroutine(player.CoSetRole(role, false));
return;
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetRole, Hazel.SendOption.Reliable, clientId);
writer.Write((ushort)role);
writer.Write(false);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}

Expand Down Expand Up @@ -481,13 +483,13 @@ public static void RpcProtectedMurderPlayer(this PlayerControl killer, PlayerCon
// Other Clients
if (killer.PlayerId != 0)
{
var writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable);
var writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable, killer.GetClientId());
writer.WriteNetObject(target);
writer.Write((int)MurderResultFlags.FailedProtected);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
public static void NoCheckStartMeeting(this PlayerControl reporter, GameData.PlayerInfo target)
public static void NoCheckStartMeeting(this PlayerControl reporter, NetworkedPlayerInfo target)
{ /*サボタージュ中でも関係なしに会議を起こせるメソッド
targetがnullの場合はボタンとなる*/
MeetingRoomManager.Instance.AssignSelf(reporter, target);
Expand Down
20 changes: 10 additions & 10 deletions Modules/Extensions/IGameManagerEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ namespace TownOfHost.Modules.Extensions
public static class IGameManagerEx
{
public static void Set(this BoolOptionNames name, bool value, IGameOptions opt) => opt.SetBool(name, value);
public static void Set(this BoolOptionNames name, bool value, NormalGameOptionsV07 opt) => opt.SetBool(name, value);
public static void Set(this BoolOptionNames name, bool value, HideNSeekGameOptionsV07 opt) => opt.SetBool(name, value);
public static void Set(this BoolOptionNames name, bool value, NormalGameOptionsV08 opt) => opt.SetBool(name, value);
public static void Set(this BoolOptionNames name, bool value, HideNSeekGameOptionsV08 opt) => opt.SetBool(name, value);

public static void Set(this Int32OptionNames name, int value, IGameOptions opt) => opt.SetInt(name, value);
public static void Set(this Int32OptionNames name, int value, NormalGameOptionsV07 opt) => opt.SetInt(name, value);
public static void Set(this Int32OptionNames name, int value, HideNSeekGameOptionsV07 opt) => opt.SetInt(name, value);
public static void Set(this Int32OptionNames name, int value, NormalGameOptionsV08 opt) => opt.SetInt(name, value);
public static void Set(this Int32OptionNames name, int value, HideNSeekGameOptionsV08 opt) => opt.SetInt(name, value);

public static void Set(this FloatOptionNames name, float value, IGameOptions opt) => opt.SetFloat(name, value);
public static void Set(this FloatOptionNames name, float value, NormalGameOptionsV07 opt) => opt.SetFloat(name, value);
public static void Set(this FloatOptionNames name, float value, HideNSeekGameOptionsV07 opt) => opt.SetFloat(name, value);
public static void Set(this FloatOptionNames name, float value, NormalGameOptionsV08 opt) => opt.SetFloat(name, value);
public static void Set(this FloatOptionNames name, float value, HideNSeekGameOptionsV08 opt) => opt.SetFloat(name, value);

public static void Set(this ByteOptionNames name, byte value, IGameOptions opt) => opt.SetByte(name, value);
public static void Set(this ByteOptionNames name, byte value, NormalGameOptionsV07 opt) => opt.SetByte(name, value);
public static void Set(this ByteOptionNames name, byte value, HideNSeekGameOptionsV07 opt) => opt.SetByte(name, value);
public static void Set(this ByteOptionNames name, byte value, NormalGameOptionsV08 opt) => opt.SetByte(name, value);
public static void Set(this ByteOptionNames name, byte value, HideNSeekGameOptionsV08 opt) => opt.SetByte(name, value);

public static void Set(this UInt32OptionNames name, uint value, IGameOptions opt) => opt.SetUInt(name, value);
public static void Set(this UInt32OptionNames name, uint value, NormalGameOptionsV07 opt) => opt.SetUInt(name, value);
public static void Set(this UInt32OptionNames name, uint value, HideNSeekGameOptionsV07 opt) => opt.SetUInt(name, value);
public static void Set(this UInt32OptionNames name, uint value, NormalGameOptionsV08 opt) => opt.SetUInt(name, value);
public static void Set(this UInt32OptionNames name, uint value, HideNSeekGameOptionsV08 opt) => opt.SetUInt(name, value);
}
}
14 changes: 8 additions & 6 deletions Modules/GameOptionsSender/GameOptionsSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ public static void SendAllGameOptions()
public virtual void SendGameOptions()
{
var opt = BuildGameOptions();
var currentGameMode = AprilFoolsMode.IsAprilFoolsModeToggledOn //April fools mode toggled on by host
? opt.AprilFoolsOnMode : opt.GameMode; //Change game mode, same as well as in "RpcSyncSettings()"

// option => byte[]
MessageWriter writer = MessageWriter.Get(SendOption.None);
writer.Write(opt.Version);
writer.StartMessage(0);
writer.Write((byte)opt.GameMode);
if (opt.TryCast<NormalGameOptionsV07>(out var normalOpt))
NormalGameOptionsV07.Serialize(writer, normalOpt);
else if (opt.TryCast<HideNSeekGameOptionsV07>(out var hnsOpt))
HideNSeekGameOptionsV07.Serialize(writer, hnsOpt);
writer.Write((byte)currentGameMode);
if (opt.TryCast<NormalGameOptionsV08>(out var normalOpt))
NormalGameOptionsV08.Serialize(writer, normalOpt);
else if (opt.TryCast<HideNSeekGameOptionsV08>(out var hnsOpt))
HideNSeekGameOptionsV08.Serialize(writer, hnsOpt);
else
{
writer.Recycle();
Expand Down Expand Up @@ -93,4 +95,4 @@ protected virtual void SendOptionsArray(Il2CppStructArray<byte> optionArray, byt

public virtual bool AmValid() => true;
}
}
}
Loading