more fixes 💀

This commit is contained in:
Gurge44 committed 2025-07-14 21:13:58 +02:00
1 parent b27e49bc45
commit d30c645a37
11 files changed
+37 -31

No files matched your search

+2 -1
View File
@@ -490,7 +490,8 @@ internal static class CustomHnS
}
catch { }
if (DangerMeter.GetBool() || (TimeLeft + 1) % 60 == 0 || TimeLeft <= 60) Utils.NotifyRoles();
if (DangerMeter.GetBool() || (TimeLeft + 1) % 60 == 0 || TimeLeft <= 60)
Utils.NotifyRoles();
}
}
}
+1 -1
View File
@@ -140,7 +140,7 @@ internal static class HotPotato
{
HotPotatoState.TimeLeft--;
LastFixedUpdate = now;
Utils.NotifyRoles();
Utils.NotifyRoles(SendOption: SendOption.None);
}
if (HotPotatoState.TimeLeft <= 0)
+2 -1
View File
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using EHR.Modules;
using HarmonyLib;
using Hazel;
using UnityEngine;
using static EHR.Translator;
@@ -506,7 +507,7 @@ public static class Quiz
{
yield return new WaitForSeconds(1f);
if (GameStates.IsMeeting || ExileController.Instance || !GameStates.InGame || GameStates.IsLobby) yield break;
Utils.NotifyRoles();
Utils.NotifyRoles(SendOption: SendOption.None);
stillLiving.RemoveAll(x => x == null || !x.IsAlive());
if (stillLiving.Count <= 1) break;
}
+2 -1
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using EHR.Modules;
using Hazel;
using UnityEngine;
using static EHR.RandomSpawn;
@@ -321,7 +322,7 @@ internal static class SoloPVP
RoundTime--;
Utils.NotifyRoles();
Utils.NotifyRoles(SendOption: SendOption.None);
}
}
+2 -11
View File
@@ -51,20 +51,11 @@ public static class CollectionExtensions
/// </summary>
/// <param name="dictionary">The dictionary to adjust the values of</param>
/// <param name="adjust">The function to adjust the values with</param>
/// <param name="predicate">The predicate to filter the keys by. If <c>null</c>, all keys will be adjusted</param>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
public static void AdjustAllValues<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Func<TValue, TValue> adjust, [Annotations.CanBeNull] Func<TKey, bool> predicate = null)
public static void AdjustAllValues<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Func<TValue, TValue> adjust)
{
if (predicate == null)
{
foreach (TKey key in dictionary.Keys.ToArray())
dictionary[key] = adjust(dictionary[key]);
return;
}
foreach (TKey key in dictionary.Keys.Where(predicate).ToArray())
foreach (TKey key in dictionary.Keys.ToArray())
dictionary[key] = adjust(dictionary[key]);
}
@@ -100,8 +100,11 @@ public abstract class GameOptionsSender
{
AllSenders.RemoveAll(s => s == null || !s.AmValid());
foreach (GameOptionsSender sender in AllSenders)
for (var index = 0; index < AllSenders.Count; index++)
{
if (index >= AllSenders.Count) yield break; // Safety check
GameOptionsSender sender = AllSenders[index];
if (sender.IsDirty)
{
sender.SendGameOptions();
@@ -119,6 +122,7 @@ public abstract class GameOptionsSender
// ReSharper disable once ForCanBeConvertedToForeach
for (var index = 0; index < AllSenders.Count; index++)
{
if (index >= AllSenders.Count) return; // Safety check
GameOptionsSender sender = AllSenders[index];
if (sender.IsDirty) sender.SendGameOptions();
+7
View File
@@ -137,6 +137,13 @@ public static class GuessManager
if (target != null)
{
if ((pc.IsCrewmate() && target.IsCrewmate() && !Options.CrewCanGuessCrew.GetBool()) ||
(pc.IsImpostor() && target.IsImpostor() && !Options.ImpCanGuessImp.GetBool()))
{
ShowMessage("GuessNotAllowed");
return true;
}
Main.GuesserGuessed.TryAdd(pc.PlayerId, 0);
Main.GuesserGuessedMeeting.TryAdd(pc.PlayerId, 0);
+7 -2
View File
@@ -44,7 +44,12 @@ public static class Statistics
Main.NumWinsPerGM.TryAdd(gm, []);
Main.NumWinsPerGM[gm].AddRange(winners, false);
Main.NumWinsPerGM[gm].AdjustAllValues(x => ++x, winners.ContainsKey);
foreach (string hashedpuid in Main.NumWinsPerGM[gm].Keys.ToArray())
{
if (winners.ContainsKey(hashedpuid))
Main.NumWinsPerGM[gm][hashedpuid]++;
}
if (Main.NumWinsPerGM[gm].Count != 0)
{
@@ -112,7 +117,7 @@ public static class Statistics
if (Main.PlayerStates.Values.Count(x => x.GetRealKiller() == lp.PlayerId) >= 7)
Achievements.Type.TheKillingMachine2Point0.CompleteAfterGameEnd();
if (won && lp.IsCrewmate() && aapc.Length == 1)
if (won && lp.IsCrewmate() && aapc.Length == 1 && lp.IsAlive())
Achievements.Type.TheLastSurvivor.CompleteAfterGameEnd();
if (addons.Contains(CustomRoles.Spurt) && Spurt.LocalPlayerAvoidsZeroAndOneHundredPrecent)
+2 -2
View File
@@ -72,8 +72,6 @@ internal static class GameEndChecker
if (WinnerTeam != CustomWinner.Default)
{
Statistics.OnGameEnd();
Ended = true;
LoadingEndScreen = true;
@@ -339,6 +337,8 @@ internal static class GameEndChecker
}
}
Statistics.OnGameEnd();
Camouflage.BlockCamouflage = true;
ShipStatus.Instance.enabled = false;
StartEndGame(reason);
+4 -10
View File
@@ -80,7 +80,7 @@ public class Snitch : RoleBase
IsComplete.Remove(playerId);
}
public static bool IsSnitch(byte playerId)
private static bool IsSnitch(byte playerId)
{
return PlayerIdList.Contains(playerId);
}
@@ -98,7 +98,7 @@ public class Snitch : RoleBase
return (target.Is(CustomRoleTypes.Impostor) && !target.Is(CustomRoles.Trickster)) || (target.IsNeutralKiller() && CanFindNeutralKiller) || (target.Is(CustomRoleTypes.Coven) && CanFindCoven) || (target.Is(CustomRoles.Madmate) && CanFindMadmate) || (target.Is(CustomRoles.Rascal) && CanFindMadmate);
}
public static void CheckTask(PlayerControl snitch)
private static void CheckTask(PlayerControl snitch)
{
if (!snitch.IsAlive() || snitch.Is(CustomRoles.Madmate) || snitch.IsConverted()) return;
@@ -150,9 +150,7 @@ public class Snitch : RoleBase
public static string GetWarningArrow(PlayerControl seer, PlayerControl target = null)
{
if (GameStates.IsMeeting || !IsSnitchTarget(seer)) return string.Empty;
if (target != null && seer.PlayerId != target.PlayerId) return string.Empty;
if (GameStates.IsMeeting || !IsSnitchTarget(seer) || (target != null && seer.PlayerId != target.PlayerId)) return string.Empty;
IEnumerable<byte> exposedSnitch = PlayerIdList.Where(s => !Main.PlayerStates[s].IsDead && IsExposed[s]);
byte[] snitch = exposedSnitch as byte[] ?? exposedSnitch.ToArray();
@@ -170,11 +168,7 @@ public class Snitch : RoleBase
public override string GetSuffix(PlayerControl seer, PlayerControl target, bool hud = false, bool meeting = false)
{
if (seer.Is(CustomRoles.Madmate)) return string.Empty;
if (!EnableTargetArrow || GameStates.IsMeeting || seer.PlayerId != SnitchId) return string.Empty;
if (target != null && seer.PlayerId != target.PlayerId) return string.Empty;
if (seer.Is(CustomRoles.Madmate) || !EnableTargetArrow || GameStates.IsMeeting || seer.PlayerId != SnitchId || (target != null && seer.PlayerId != target.PlayerId)) return string.Empty;
var arrows = string.Empty;
+3 -1
View File
@@ -169,7 +169,9 @@ public class Swooper : RoleBase
if (!player.IsModdedClient() && UsedRole != CustomRoles.Chameleon)
{
long cooldown = lastTime + (long)Cooldown - now;
if ((int)cooldown != CD) player.Notify(string.Format(GetString("CDPT"), cooldown + 1), 3f, true);
if ((int)cooldown != CD && !(UsedRole != CustomRoles.Chameleon && UsePhantomBasis.GetBool() && (UsedRole != CustomRoles.Wraith || UsePhantomBasisForNKs.GetBool())))
player.Notify(string.Format(GetString("CDPT"), cooldown + 1), 3f, true);
CD = (int)cooldown;
}