Fix stuff

This commit is contained in:
Gurge44 committed 2024-06-10 11:02:21 +02:00
1 parent de62db8bec
commit 097cc8e307
12 files changed
+49 -43

No files matched your search

+2 -8
View File
@@ -1,13 +1,9 @@
using HarmonyLib;
using UnityEngine;
namespace EHR;
public static class ObjectHelper
{
/// <summary>
/// オブジェクトの<see cref="TextTranslatorTMP"/>コンポーネントを破棄します
/// </summary>
public static void DestroyTranslator(this GameObject obj)
{
if (obj == null) return;
@@ -15,8 +11,6 @@ public static class ObjectHelper
TextTranslatorTMP[] translator = obj.GetComponentsInChildren<TextTranslatorTMP>(true);
translator?.Do(Object.Destroy);
}
/// <summary>
/// オブジェクトの<see cref="TextTranslatorTMP"/>コンポーネントを破棄します
/// </summary>
public static void DestroyTranslator(this MonoBehaviour obj) => obj?.gameObject?.DestroyTranslator();
public static void DestroyTranslator(this MonoBehaviour obj) => obj?.gameObject.DestroyTranslator();
}
+1
View File
@@ -327,6 +327,7 @@ public static class GuessManager
if (!isUI) Utils.SendMessage(GetString("GuessSuperStar"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessSuperStar"));
return true;
case CustomRoles.Shifter:
case CustomRoles.Goose when !Goose.CanBeGuessed.GetBool():
case CustomRoles.Disco:
case CustomRoles.Glow:
+9 -8
View File
@@ -431,6 +431,7 @@ public static class Utils
var self = seerId == targetId || Main.PlayerStates[seerId].IsDead;
bool isHnsAgentOverride = Options.CurrentGameMode == CustomGameMode.HideAndSeek && targetMainRole == CustomRoles.Agent && HnSManager.PlayerRoles[seerId].Interface.Team != Team.Impostor;
bool loversShowDifferentRole = false;
if (!GameStates.IsEnded && targetMainRole == CustomRoles.LovingImpostor && !self && seerMainRole != CustomRoles.LovingCrewmate && !seerSubRoles.Contains(CustomRoles.Lovers))
{
targetMainRole = Lovers.LovingImpostorRoleForOtherImps.GetValue() switch
@@ -439,10 +440,11 @@ public static class Utils
1 => Lovers.LovingImpostorRole,
_ => CustomRoles.LovingImpostor
};
loversShowDifferentRole = true;
}
string RoleText = GetRoleName(isHnsAgentOverride ? CustomRoles.Hider : targetMainRole);
Color RoleColor = GetRoleColor(targetMainRole);
Color RoleColor = GetRoleColor(loversShowDifferentRole ? CustomRoles.Impostor : targetMainRole);
if (LastImpostor.currentId == targetId)
RoleText = GetRoleString("Last-") + RoleText;
@@ -829,11 +831,11 @@ public static class Utils
return __instance.Is(CustomRoles.Madmate) && PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) && Options.MadmateKnowWhosMadmate.GetBool() ||
__instance.Is(CustomRoles.Mimic) && Main.VisibleTasksCount && __instance.Data.IsDead ||
__instance.Is(CustomRoles.Lovers) && PlayerControl.LocalPlayer.Is(CustomRoles.Lovers) && Lovers.LoverKnowRoles.GetBool() ||
__instance.Is(CustomRoles.Madmate) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowWhosMadmate.GetBool() ||
__instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Crewpostor) && Options.AlliesKnowCrewpostor.GetBool() ||
__instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowAlliesRole.GetBool() ||
__instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) && Options.MadmateKnowWhosImp.GetBool() ||
Main.LoversPlayers.TrueForAll(x => x.PlayerId == __instance.PlayerId || x.PlayerId == PlayerControl.LocalPlayer.PlayerId) && Lovers.LoverKnowRoles.GetBool() ||
CustomTeamManager.AreInSameCustomTeam(__instance.PlayerId, PlayerControl.LocalPlayer.PlayerId) && CustomTeamManager.IsSettingEnabledForPlayerTeam(__instance.PlayerId, CTAOption.KnowRoles) ||
Main.PlayerStates.Values.Any(x => x.Role.KnowRole(PlayerControl.LocalPlayer, __instance)) ||
PlayerControl.LocalPlayer.IsRevealedPlayer(__instance) ||
@@ -1351,7 +1353,7 @@ public static class Utils
var sb = new StringBuilder();
if (intro)
{
bool isLovers = SubRoles.Contains(CustomRoles.Lovers);
bool isLovers = SubRoles.Contains(CustomRoles.Lovers) && Main.PlayerStates[id].MainRole is not CustomRoles.LovingCrewmate and not CustomRoles.LovingImpostor;
SubRoles.RemoveAll(x => x is CustomRoles.NotAssigned or CustomRoles.LastImpostor or CustomRoles.Lovers);
if (isLovers)
@@ -1963,7 +1965,7 @@ public static class Utils
if (Options.CurrentGameMode != CustomGameMode.Standard) goto GameMode0;
SelfMark.Append(Snitch.GetWarningArrow(seer));
if (seer.Is(CustomRoles.Lovers)) SelfMark.Append(ColorString(GetRoleColor(CustomRoles.Lovers), " ♥"));
if (Main.LoversPlayers.Contains(seer)) SelfMark.Append(ColorString(GetRoleColor(CustomRoles.Lovers), " ♥"));
if (BallLightning.IsGhost(seer)) SelfMark.Append(ColorString(GetRoleColor(CustomRoles.BallLightning), "■"));
SelfMark.Append(Medic.GetMark(seer, seer));
SelfMark.Append(Gamer.TargetMark(seer, seer));
@@ -2152,8 +2154,7 @@ public static class Utils
TargetMark.Append(Snitch.GetWarningMark(seer, target));
if ((seer.Is(CustomRoles.Lovers) && target.Is(CustomRoles.Lovers))
|| (seer.Data.IsDead && target.Is(CustomRoles.Lovers)))
if (Main.LoversPlayers.TrueForAll(x => x.PlayerId == seer.PlayerId || x.PlayerId == target.PlayerId) || (seer.Data.IsDead && Main.LoversPlayers.Contains(target)))
{
TargetMark.Append($"<color={GetRoleColorCode(CustomRoles.Lovers)}> ♥</color>");
}
@@ -2226,7 +2227,7 @@ public static class Utils
(seer.Data.IsDead && Options.GhostCanSeeOtherRoles.GetBool()) ||
(seer.Is(CustomRoles.Mimic) && target.Data.IsDead && Options.MimicCanSeeDeadRoles.GetBool()) ||
(target.Is(CustomRoles.Gravestone) && target.Data.IsDead) ||
(seer.Is(CustomRoles.Lovers) && target.Is(CustomRoles.Lovers) && Lovers.LoverKnowRoles.GetBool()) ||
(Main.LoversPlayers.TrueForAll(x => x.PlayerId == seer.PlayerId || x.PlayerId == target.PlayerId) && Lovers.LoverKnowRoles.GetBool()) ||
(seer.Is(CustomRoleTypes.Impostor) && target.Is(CustomRoleTypes.Impostor) && Options.ImpKnowAlliesRole.GetBool()) ||
(seer.Is(CustomRoles.Madmate) && target.Is(CustomRoleTypes.Impostor) && Options.MadmateKnowWhosImp.GetBool()) ||
(seer.Is(CustomRoleTypes.Impostor) && target.Is(CustomRoles.Madmate) && Options.ImpKnowWhosMadmate.GetBool()) ||
@@ -2513,7 +2514,7 @@ public static class Utils
{
if (!Lovers.IsChatActivated && Lovers.PrivateChat.GetBool() && !GameStates.IsEnded)
{
SetChatVisible();
LateTask.New(SetChatVisible, 0.5f, log: false);
Lovers.IsChatActivated = true;
return;
}
+3 -5
View File
@@ -73,14 +73,12 @@ internal class ChatCommands
switch (args[0])
{
case "/dump":
//canceled = true;
Utils.DumpLog();
break;
case "/v":
case "/version":
canceled = true;
string version_text = Main.PlayerVersion.OrderBy(pair => pair.Key).Aggregate(string.Empty, (current, kvp) => current + $"{kvp.Key}:{Main.AllPlayerNames[kvp.Key]}:{kvp.Value.forkId}/{kvp.Value.version}({kvp.Value.tag})\n");
if (version_text != string.Empty) HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, (PlayerControl.LocalPlayer.FriendCode.GetDevUser().HasTag() ? "\n" : string.Empty) + version_text);
break;
default:
@@ -764,7 +762,7 @@ internal class ChatCommands
ChatUpdatePatch.LoversMessage = true;
Utils.SendMessage(text, otherLover.PlayerId, title);
Utils.SendMessage(text, PlayerControl.LocalPlayer.PlayerId, title);
LateTask.New(() => ChatUpdatePatch.LoversMessage = false, 1f, log: false);
LateTask.New(() => ChatUpdatePatch.LoversMessage = false, Main.MessageWait.Value, log: false);
}
goto Canceled;
@@ -1408,8 +1406,8 @@ internal class ChatCommands
ChatUpdatePatch.LoversMessage = true;
Utils.SendMessage(text, otherLover.PlayerId, title);
Utils.SendMessage(text, player.PlayerId, title);
LateTask.New(() => ChatUpdatePatch.LoversMessage = false, 1f, log: false);
}, 0.5f, log: false);
LateTask.New(() => ChatUpdatePatch.LoversMessage = false, Main.MessageWait.Value, log: false);
}, 0.2f, log: false);
}
}
+3 -5
View File
@@ -240,12 +240,10 @@ class GameEndChecker
.DoIf(x => !CustomTeamManager.IsSettingEnabledForTeam(x.Key, CTAOption.WinWithOriginalTeam), x => WinnerIds.ExceptWith(x.Value), fast: true);
}
if ((WinnerTeam == CustomWinner.Lovers || WinnerIds.Any(x => Main.PlayerStates[x].SubRoles.Contains(CustomRoles.Lovers))) && Main.LoversPlayers.All(x => x.IsAlive()))
if ((WinnerTeam == CustomWinner.Lovers || WinnerIds.Any(x => Main.PlayerStates[x].SubRoles.Contains(CustomRoles.Lovers))) && Main.LoversPlayers.All(x => x.IsAlive()) && reason != GameOverReason.HumansByTask)
{
if (WinnerTeam != CustomWinner.Lovers) AdditionalWinnerTeams.Add(AdditionalWinners.Lovers);
Main.AllPlayerControls
.Where(p => p.Is(CustomRoles.Lovers))
.Do(p => WinnerIds.Add(p.PlayerId));
WinnerIds.UnionWith(Main.LoversPlayers.Select(x => x.PlayerId));
}
if (Options.NeutralWinTogether.GetBool() && WinnerIds.Any(x => GetPlayerById(x) != null && GetPlayerById(x).GetCustomRole().IsNeutral()))
@@ -378,7 +376,7 @@ class GameEndChecker
if (CustomTeamManager.CheckCustomTeamGameEnd()) return true;
if (Main.AllAlivePlayerControls.All(p => p.Is(CustomRoles.Lovers)) && !Main.LoversPlayers.All(x => x.Is(CustomRoles.LovingCrewmate)))
if (Main.AllAlivePlayerControls.All(Main.LoversPlayers.Contains) && !Main.LoversPlayers.All(x => x.Is(Team.Crewmate)))
{
ResetAndSetWinner(CustomWinner.Lovers);
return true;
+14 -6
View File
@@ -354,8 +354,18 @@ class CheckForEndVotingPatch
var crole = exiledPlayer.GetCustomRole();
var coloredRole = Utils.GetDisplayRoleName(exileId, true);
if (crole == CustomRoles.LovingImpostor && !Options.ConfirmLoversOnEject.GetBool())
{
coloredRole = (Lovers.LovingImpostorRoleForOtherImps.GetValue() switch
{
0 => CustomRoles.ImpostorEHR,
1 => Lovers.LovingImpostorRole,
_ => CustomRoles.LovingImpostor
}).ToColoredString();
}
if (Options.ConfirmEgoistOnEject.GetBool() && player.Is(CustomRoles.Egoist)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Egoist), GetRoleString("Temp.Blank") + coloredRole.RemoveHtmlTags());
if (Options.ConfirmLoversOnEject.GetBool() && player.Is(CustomRoles.Lovers)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Lovers), GetRoleString("Temp.Blank") + coloredRole.RemoveHtmlTags());
if (Options.ConfirmLoversOnEject.GetBool() && Main.LoversPlayers.Contains(player)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Lovers), GetRoleString("Temp.Blank") + coloredRole.RemoveHtmlTags());
if (Options.RascalAppearAsMadmate.GetBool() && player.Is(CustomRoles.Rascal)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Madmate), GetRoleString("Mad-") + coloredRole.RemoveHtmlTags());
var name = string.Empty;
@@ -373,9 +383,7 @@ class CheckForEndVotingPatch
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
{
if (pc == exiledPlayer.Object) continue;
var pc_role = pc.GetCustomRole();
if (pc_role.IsImpostor()) impnum++;
if (pc.GetCustomRole().IsImpostor()) impnum++;
else if (pc.IsNeutralKiller()) neutralnum++;
}
@@ -797,7 +805,7 @@ class MeetingHudStartPatch
(Main.VisibleTasksCount && PlayerControl.LocalPlayer.Data.IsDead && Options.GhostCanSeeOtherRoles.GetBool()) ||
(PlayerControl.LocalPlayer.Is(CustomRoles.Mimic) && Main.VisibleTasksCount && pc.Data.IsDead && Options.MimicCanSeeDeadRoles.GetBool()) ||
(pc.Is(CustomRoles.Gravestone) && Main.VisibleTasksCount && pc.Data.IsDead) ||
(pc.Is(CustomRoles.Lovers) && PlayerControl.LocalPlayer.Is(CustomRoles.Lovers) && Lovers.LoverKnowRoles.GetBool()) ||
(Main.LoversPlayers.TrueForAll(x => x.PlayerId == pc.PlayerId || x.PlayerId == PlayerControl.LocalPlayer.PlayerId) && Lovers.LoverKnowRoles.GetBool()) ||
(pc.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowAlliesRole.GetBool()) ||
(pc.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) && Options.MadmateKnowWhosImp.GetBool()) ||
(pc.Is(CustomRoles.Madmate) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowWhosMadmate.GetBool()) ||
@@ -964,7 +972,7 @@ class MeetingHudStartPatch
if (Silencer.ForSilencer.Contains(target.PlayerId))
sb.Append(Utils.ColorString(Utils.GetRoleColor(CustomRoles.Silencer), "╳"));
if (target.GetCustomSubRoles().Contains(CustomRoles.Lovers) && (seer.Is(CustomRoles.Lovers) || seer.Data.IsDead))
if (Main.LoversPlayers.Contains(target) && (Main.LoversPlayers.Contains(seer) || seer.Data.IsDead))
{
sb.Append(Utils.ColorString(Utils.GetRoleColor(CustomRoles.Lovers), "♥"));
}
+4 -4
View File
@@ -41,10 +41,10 @@ namespace EHR.Roles.Crewmate
public override void SetButtonTexts(HudManager hud, byte id)
{
if (UsePets.GetBool())
hud.PetButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText");
else
hud.AbilityButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText");
if (!MayorHasPortableButton.GetBool()) return;
if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText");
else hud.AbilityButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText");
}
public override void OnPet(PlayerControl pc)
+6
View File
@@ -72,6 +72,12 @@ public class SabotageMaster : RoleBase
AURoleOptions.EngineerInVentMaxTime = 0f;
}
public override string GetProgressText(byte playerId, bool comms)
{
var limit = SkillLimit.GetInt() - UsedSkillCount;
return limit + base.GetProgressText(playerId, comms);
}
public void SendRPC()
{
if (!IsEnable || !Utils.DoRPC) return;
+4 -4
View File
@@ -125,14 +125,14 @@ namespace EHR.Roles.Impostor
MonitoredRoom = room;
Utils.SendRPC(CustomRPC.SyncSentry, pc.PlayerId);
}
else DisplayRoomInfo(pc);
else DisplayRoomInfo(pc, false);
}
void DisplayRoomInfo(PlayerControl pc)
void DisplayRoomInfo(PlayerControl pc, bool fromDevice)
{
if (CannotSeeInfoDuringComms.GetBool() && Utils.IsActive(SystemTypes.Comms)) return;
if (pc.Is(CustomRoles.Sentry))
if (!fromDevice)
{
if (pc.GetAbilityUseLimit() < 1) return;
pc.RpcRemoveAbilityUse();
@@ -278,7 +278,7 @@ namespace EHR.Roles.Impostor
return;
}
DisplayRoomInfo(pc);
DisplayRoomInfo(pc, true);
UsingDevice.Add(pc.PlayerId);
}
+1 -1
View File
@@ -63,7 +63,7 @@ public class Executioner : RoleBase
try
{
List<PlayerControl> targetList = [];
targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetNeutralBenign.GetBool() || !target.IsNeutralBenign() where CanTargetNeutralEvil.GetBool() || !target.IsNeutralEvil() where CanTargetNeutralChaos.GetBool() || !target.IsNeutralChaos() where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where !Utils.GetPlayerById(playerId).Is(CustomRoles.Lovers) || !target.Is(CustomRoles.Lovers) select target);
targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetNeutralBenign.GetBool() || !target.IsNeutralBenign() where CanTargetNeutralEvil.GetBool() || !target.IsNeutralEvil() where CanTargetNeutralChaos.GetBool() || !target.IsNeutralChaos() where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where Main.LoversPlayers.TrueForAll(x => x.PlayerId != playerId) select target);
if (targetList.Count == 0)
{
+1 -1
View File
@@ -92,7 +92,7 @@ namespace EHR.Roles.Neutral
((target.Is(CustomRoles.Madmate) || target.Is(CustomRoles.Gangster)) && CanKillMadmate.GetBool())
|| ((target.Is(CustomRoles.Charmed) || target.Is(CustomRoles.Succubus)) && CanKillCharmed.GetBool())
|| ((target.Is(CustomRoles.Undead) || target.Is(CustomRoles.Necromancer) || target.Is(CustomRoles.Deathknight)) && CanKillUndead.GetBool())
|| ((target.Is(CustomRoles.Lovers) || target.Is(CustomRoles.Ntr)) && CanKillLovers.GetBool())
|| ((Main.LoversPlayers.Contains(target) || target.Is(CustomRoles.Ntr)) && CanKillLovers.GetBool())
|| ((target.Is(CustomRoles.Romantic) || target.Is(CustomRoles.RuthlessRomantic) || target.Is(CustomRoles.VengefulRomantic)
|| Romantic.PartnerId == target.PlayerId) && CanKillLovers.GetBool())
|| ((target.Is(CustomRoles.Sidekick) || target.Is(CustomRoles.Jackal) || target.Is(CustomRoles.Recruit)) && CanKillSidekicks.GetBool())
+1 -1
View File
@@ -77,7 +77,7 @@ public class Lawyer : RoleBase
if (AmongUsClient.Instance.AmHost)
{
List<PlayerControl> targetList = [];
targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetCrewmate.GetBool() || !target.Is(CustomRoleTypes.Crewmate) where CanTargetJester.GetBool() || !target.Is(CustomRoles.Jester) where !target.Is(CustomRoleTypes.Neutral) || target.IsNeutralKiller() || target.Is(CustomRoles.Jester) where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where !Utils.GetPlayerById(playerId).Is(CustomRoles.Lovers) || !target.Is(CustomRoles.Lovers) select target);
targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetCrewmate.GetBool() || !target.Is(CustomRoleTypes.Crewmate) where CanTargetJester.GetBool() || !target.Is(CustomRoles.Jester) where !target.Is(CustomRoleTypes.Neutral) || target.IsNeutralKiller() || target.Is(CustomRoles.Jester) where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where Main.LoversPlayers.TrueForAll(x => x.PlayerId != playerId) select target);
if (targetList.Count == 0)
{