Skip to content

Commit

Permalink
Merge pull request #1303 from tukasa0001/develop-5.1.3
Browse files Browse the repository at this point in the history
Develop 5.1.3
  • Loading branch information
Hyz-sui authored Nov 6, 2023
2 parents 2e5b26f + 370c7b8 commit 0c96219
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 110 deletions.
20 changes: 20 additions & 0 deletions Helpers/ColorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,31 @@ public static Color ToMarkingColor(this Color color, bool bright = true)
var markingColor = Color.HSVToRGB(h, MarkerSat, bright ? MarkerVal : v).SetAlpha(MarkerAlpha);
return markingColor;
}
/// <summary>白背景での可読性を保てる色に変換する</summary>
public static Color ToReadableColor(this Color color)
{
Color.RGBToHSV(color, out var h, out var s, out var v);
// 適切な彩度でない場合は彩度を変更
if (s < ReadableSat)
{
s = ReadableSat;
}
// 適切な明度でない場合は明度を変更
if (v > ReadableVal)
{
v = ReadableVal;
}
return Color.HSVToRGB(h, s, v);
}

/// <summary>マーカー色のS値 = 彩度</summary>
private const float MarkerSat = 1f;
/// <summary>マーカー色のV値 = 明度</summary>
private const float MarkerVal = 1f;
/// <summary>マーカー色のアルファ = 不透明度</summary>
private const float MarkerAlpha = 0.2f;
/// <summary>白背景テキスト色の最大S = 彩度</summary>
private const float ReadableSat = 0.8f;
/// <summary>白背景テキスト色の最大V = 明度</summary>
private const float ReadableVal = 0.8f;
}
10 changes: 9 additions & 1 deletion Helpers/CustomRolesHelper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using AmongUs.GameOptions;

using TownOfHost.Roles.Core;
Expand All @@ -6,7 +7,14 @@ namespace TownOfHost
{
static class CustomRolesHelper
{
public static readonly CustomRoles[] AllRoles = EnumHelper.GetAllValues<CustomRoles>();
/// <summary>すべての役職(属性は含まない)</summary>
public static readonly CustomRoles[] AllRoles = EnumHelper.GetAllValues<CustomRoles>().Where(role => role < CustomRoles.NotAssigned).ToArray();
/// <summary>すべての属性</summary>
public static readonly CustomRoles[] AllAddOns = EnumHelper.GetAllValues<CustomRoles>().Where(role => role > CustomRoles.NotAssigned).ToArray();
/// <summary>スタンダードモードで出現できるすべての役職</summary>
public static readonly CustomRoles[] AllStandardRoles = AllRoles.Where(role => role is not (CustomRoles.HASFox or CustomRoles.HASTroll)).ToArray();
/// <summary>HASモードで出現できるすべての役職</summary>
public static readonly CustomRoles[] AllHASRoles = { CustomRoles.HASFox, CustomRoles.HASTroll };
public static readonly CustomRoleTypes[] AllRoleTypes = EnumHelper.GetAllValues<CustomRoleTypes>();

public static bool IsImpostor(this CustomRoles role)
Expand Down
2 changes: 2 additions & 0 deletions Modules/OptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public static CustomGameMode CurrentGameMode
public static OptionItem DisableAirshipMovingPlatform;
public static OptionItem ResetDoorsEveryTurns;
public static OptionItem DoorsResetMode;
public static OptionItem DisableFungleSporeTrigger;

// その他
public static OptionItem FixFirstKillCooldown;
Expand Down Expand Up @@ -482,6 +483,7 @@ public static void Load()
DisableAirshipMovingPlatform = BooleanOptionItem.Create(101700, "DisableAirshipMovingPlatform", false, TabGroup.MainSettings, false).SetParent(MapModification);
ResetDoorsEveryTurns = BooleanOptionItem.Create(101800, "ResetDoorsEveryTurns", false, TabGroup.MainSettings, false).SetParent(MapModification);
DoorsResetMode = StringOptionItem.Create(101810, "DoorsResetMode", EnumHelper.GetAllNames<DoorsReset.ResetMode>(), 0, TabGroup.MainSettings, false).SetParent(ResetDoorsEveryTurns);
DisableFungleSporeTrigger = BooleanOptionItem.Create(101900, "DisableFungleSporeTrigger", false, TabGroup.MainSettings, false).SetParent(MapModification);

// タスク無効化
DisableTasks = BooleanOptionItem.Create(100300, "DisableTasks", false, TabGroup.MainSettings, false)
Expand Down
4 changes: 2 additions & 2 deletions Modules/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] byte c
foreach (var co in OptionItem.AllOptions)
{
//すべてのカスタムオプションについてインデックス値で受信
co.SetValue(reader.ReadInt32());
co.SetValue(reader.ReadPackedInt32());
}
break;
case CustomRPC.SetDeathReason:
Expand Down Expand Up @@ -169,7 +169,7 @@ public static void SyncCustomSettingsRPC()
foreach (var co in OptionItem.AllOptions)
{
//すべてのカスタムオプションについてインデックス値で送信
writer.Write(co.GetValue());
writer.WritePacked(co.GetValue());
}
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
Expand Down
27 changes: 18 additions & 9 deletions Modules/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,20 @@ public static void ShowActiveSettingsHelp(byte PlayerId = byte.MaxValue)
if (Options.RandomMapsMode.GetBool()) { SendMessage(GetString("RandomMapsModeInfo"), PlayerId); }
if (Options.IsStandardHAS) { SendMessage(GetString("StandardHASInfo"), PlayerId); }
if (Options.EnableGM.GetBool()) { SendMessage(GetRoleName(CustomRoles.GM) + GetString("GMInfoLong"), PlayerId); }
foreach (var role in CustomRolesHelper.AllRoles)
foreach (var role in CustomRolesHelper.AllStandardRoles)
{
if (role is CustomRoles.HASFox or CustomRoles.HASTroll) continue;
if (role.IsEnable() && !role.IsVanilla()) SendMessage(GetRoleName(role) + GetString(Enum.GetName(typeof(CustomRoles), role) + "InfoLong"), PlayerId);
if (role.IsEnable())
{
if (role.GetRoleInfo()?.Description is { } description)
{
SendMessage(description.FullFormatHelp, PlayerId, removeTags: false);
}
// RoleInfoがない役職は従来処理
else
{
SendMessage(GetRoleName(role) + GetString(Enum.GetName(typeof(CustomRoles), role) + "InfoLong"), PlayerId);
}
}
}
}
if (Options.NoGameEnd.GetBool()) { SendMessage(GetString("NoGameEndInfo"), PlayerId); }
Expand Down Expand Up @@ -593,9 +603,8 @@ public static void ShowActiveRoles(byte PlayerId = byte.MaxValue)
sb.AppendFormat("<size={0}>", ActiveSettingsSize);
sb.Append("<size=100%>").Append(GetString("Roles")).Append('\n').Append("</size>");
sb.AppendFormat("\n{0}:{1}", GetRoleName(CustomRoles.GM), Options.EnableGM.GetString());
foreach (CustomRoles role in CustomRolesHelper.AllRoles)
foreach (CustomRoles role in CustomRolesHelper.AllStandardRoles)
{
if (role is CustomRoles.HASFox or CustomRoles.HASTroll) continue;
if (role.IsEnable()) sb.AppendFormat("\n{0}:{1}x{2}", GetRoleName(role), $"{role.GetChance()}%", role.GetCount());
}
SendMessage(sb.ToString(), PlayerId, removeTags: false);
Expand Down Expand Up @@ -786,8 +795,8 @@ public static void NotifyRoles(bool isForMeeting = false, PlayerControl SpecifyS
if (isForMeeting && (seer.GetClient().PlatformData.Platform is Platforms.Playstation or Platforms.Switch)) fontSize = "70%";
logger.Info("NotifyRoles-Loop1-" + seer.GetNameWithRole() + ":START");

// キノコカオス中で,seerが生きていてdesyncインポスターの場合に自身の名前を消す
if (isMushroomMixupActive && seer.IsAlive() && !seer.Is(CustomRoleTypes.Impostor) && seer.GetCustomRole().GetRoleInfo()?.IsDesyncImpostor == true)
// 会議じゃなくて,キノコカオス中で,seerが生きていてdesyncインポスターの場合に自身の名前を消す
if (!isForMeeting && isMushroomMixupActive && seer.IsAlive() && !seer.Is(CustomRoleTypes.Impostor) && seer.GetCustomRole().GetRoleInfo()?.IsDesyncImpostor == true)
{
seer.RpcSetNamePrivate("<size=0>", true, force: NoCache);
}
Expand Down Expand Up @@ -860,8 +869,8 @@ public static void NotifyRoles(bool isForMeeting = false, PlayerControl SpecifyS
if (target == seer) continue;
logger.Info("NotifyRoles-Loop2-" + target.GetNameWithRole() + ":START");

// キノコカオス中で,targetが生きていてseerがdesyncインポスターの場合にtargetの名前を消す
if (isMushroomMixupActive && target.IsAlive() && !seer.Is(CustomRoleTypes.Impostor) && seer.GetCustomRole().GetRoleInfo()?.IsDesyncImpostor == true)
// 会議じゃなくて,キノコカオス中で,targetが生きていてseerがdesyncインポスターの場合にtargetの名前を消す
if (!isForMeeting && isMushroomMixupActive && target.IsAlive() && !seer.Is(CustomRoleTypes.Impostor) && seer.GetCustomRole().GetRoleInfo()?.IsDesyncImpostor == true)
{
target.RpcSetNamePrivate("<size=0>", true, seer, force: NoCache);
}
Expand Down
35 changes: 30 additions & 5 deletions Patches/ChatCommandPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,15 @@ public static bool Prefix(ChatController __instance)
case "/m":
case "/myrole":
canceled = true;
var role = PlayerControl.LocalPlayer.GetCustomRole();
if (GameStates.IsInGame)
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, GetString(role.ToString()) + PlayerControl.LocalPlayer.GetRoleInfo(true));
{
var role = PlayerControl.LocalPlayer.GetCustomRole();
HudManager.Instance.Chat.AddChat(
PlayerControl.LocalPlayer,
role.GetRoleInfo()?.Description?.FullFormatHelp ??
// roleInfoがない役職
GetString(role.ToString()) + PlayerControl.LocalPlayer.GetRoleInfo(true));
}
break;

case "/t":
Expand Down Expand Up @@ -311,7 +317,16 @@ public static void GetRolesInfo(string role)

if (String.Compare(role, roleName, true) == 0 || String.Compare(role, roleShort, true) == 0)
{
Utils.SendMessage(GetString(roleName) + GetString($"{roleName}InfoLong"));
var roleInfo = r.Key.GetRoleInfo();
if (roleInfo != null && roleInfo.Description != null)
{
Utils.SendMessage(roleInfo.Description.FullFormatHelp, removeTags: false);
}
// RoleInfoがない役職は従来の処理
else
{
Utils.SendMessage(GetString(roleName) + GetString($"{roleName}InfoLong"));
}
return;
}

Expand Down Expand Up @@ -391,9 +406,19 @@ public static void OnReceiveChat(PlayerControl player, string text)

case "/m":
case "/myrole":
var role = player.GetCustomRole();
if (GameStates.IsInGame)
Utils.SendMessage(GetString(role.ToString()) + player.GetRoleInfo(true), player.PlayerId);
{
var role = player.GetCustomRole();
if (role.GetRoleInfo()?.Description is { } description)
{
Utils.SendMessage(description.FullFormatHelp, player.PlayerId, removeTags: false);
}
// roleInfoがない役職
else
{
Utils.SendMessage(GetString(role.ToString()) + player.GetRoleInfo(true), player.PlayerId);
}
}
break;

case "/t":
Expand Down
5 changes: 3 additions & 2 deletions Patches/ISystemType/SabotageSystemTypePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ private static bool CanSabotage(PlayerControl player)
}
return true;
}
public static void Postfix(SabotageSystemType __instance)
public static void Postfix(SabotageSystemType __instance, bool __runOriginal /* Prefixの結果,本体処理が実行されたかどうか */ )
{
if (!isCooldownModificationEnabled || !AmongUsClient.Instance.AmHost)
if (!__runOriginal || !isCooldownModificationEnabled || !AmongUsClient.Instance.AmHost)
{
return;
}
// サボタージュクールダウンを変更
__instance.Timer = modifiedCooldownSec;
__instance.IsDirty = true;
}
Expand Down
12 changes: 12 additions & 0 deletions Patches/PlayerContorolPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,16 @@ public static void Postfix(PlayerControl __instance)
}
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckSporeTrigger))]
public static class PlayerControlCheckSporeTriggerPatch
{
public static bool Prefix()
{
if (Options.DisableFungleSporeTrigger.GetBool())
{
return false;
}
return true;
}
}
}
4 changes: 2 additions & 2 deletions Patches/onGameStartedPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static void Postfix()
}
else
{
foreach (var role in CustomRolesHelper.AllRoles.Where(x => x < CustomRoles.NotAssigned))
foreach (var role in CustomRolesHelper.AllStandardRoles)
{
if (role.IsVanilla()) continue;
if (CustomRoleManager.GetRoleInfo(role)?.IsDesyncImpostor == true) continue;
Expand Down Expand Up @@ -442,7 +442,7 @@ private static void AssignLoversRoles(int RawCount = -1)
public static int GetRoleTypesCount(RoleTypes roleTypes)
{
int count = 0;
foreach (var role in CustomRolesHelper.AllRoles.Where(x => x < CustomRoles.NotAssigned))
foreach (var role in CustomRolesHelper.AllRoles)
{
if (CustomRoleManager.GetRoleInfo(role)?.IsDesyncImpostor == true) continue;
if (role == CustomRoles.Egoist && Main.NormalOptions.GetInt(Int32OptionNames.NumImpostors) <= 1) continue;
Expand Down
8 changes: 8 additions & 0 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,14 @@ After meetings, all door openings are reset to the specified state.
| Reset Doors After Meeting(Airship/Polus/Fungle) | |
| ┗ Reset Mode | Select from All Open/All Closed/Random By Door |

### Prevent Spores Trigger(Fungle)

Prevents spores to be released when mushrooms are stepped on.

| Name |
| ------------------------------ |
| Prevent Spores Trigger(Fungle) |

## Mode

### DisableTasks
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,14 @@ Polus や The Airship のドアを開けるとその部屋の全てのドアが
| 会議後にドア状況をリセットする(エアシップ・ポーラス・ファングル) | |
| ┗ リセットモード | 全て開放/全て閉鎖/ドアごとにランダム から選択 |

### きのこの胞子を無効化(ファングル)

きのこを踏んでも、胞子が出なくなります。

| 設定名 |
| -------------------------------- |
| きのこの胞子を無効化(ファングル) |

## モード

### DisableTasks/タスクを無効化する
Expand Down
Loading

0 comments on commit 0c96219

Please sign in to comment.