diff --git a/EHR.sln.DotSettings b/EHR.sln.DotSettings
index 4f43706a5..24140ddf2 100644
--- a/EHR.sln.DotSettings
+++ b/EHR.sln.DotSettings
@@ -67,6 +67,7 @@
TS
UI
VN
+ WAV
XOR
<Policy><Descriptor Staticness="Any" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="non_field_members_should_be_pascal_case"><ElementKinds><Kind Name="PROPERTY" /><Kind Name="EVENT" /><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="False" Prefix="Get" Suffix="" Style="AaBb" /></Policy>
diff --git a/Gamemodes/BedWars.cs b/Gamemodes/BedWars.cs
index e28a47fac..ee200ed61 100644
--- a/Gamemodes/BedWars.cs
+++ b/Gamemodes/BedWars.cs
@@ -78,7 +78,7 @@ public static class BedWars
private static readonly Item[] Selections = Enum.GetValues- ();
private static readonly ItemCategory[] Categories = Enum.GetValues()[1..];
private static readonly Upgrade[] AllUpgrade = Enum.GetValues();
- public static (Color Color, string Team) WinnerData = (Color.white, "No one wins");
+ public static (UnityEngine.Color Color, string Team) WinnerData = (Color.white, "No one wins");
public static void SetupCustomOption()
{
diff --git a/Gamemodes/HotPotato.cs b/Gamemodes/HotPotato.cs
index 374d31934..3c1dafef2 100644
--- a/Gamemodes/HotPotato.cs
+++ b/Gamemodes/HotPotato.cs
@@ -4,7 +4,6 @@ using System.Linq;
using AmongUs.GameOptions;
using EHR.Modules;
using Hazel;
-using InnerNet;
using UnityEngine;
namespace EHR.Gamemodes;
@@ -213,7 +212,7 @@ internal static class HotPotato
LateTask.New(() => target.SetKillCooldownNonSync(1f), 0.2f, log: false);
}
- if (aapcCount < HolderHasArrowToNearestPlayerIfPlayersLessThan.GetInt() && aapcCount > 1)
+ if (aapcCount < HolderHasArrowToNearestPlayerIfPlayersLessThan.GetInt())
{
Vector2 pos = target.Pos();
TargetArrow.Add(HotPotatoState.HolderID, aapc.Without(target).Where(x => x.PlayerId != HotPotatoState.LastHolderID).MinBy(x => Vector2.Distance(x.Pos(), pos)).PlayerId);
diff --git a/Gamemodes/KingOfTheZones.cs b/Gamemodes/KingOfTheZones.cs
index f0482d978..056391f31 100644
--- a/Gamemodes/KingOfTheZones.cs
+++ b/Gamemodes/KingOfTheZones.cs
@@ -1,12 +1,11 @@
-using AmongUs.GameOptions;
-using EHR.Modules;
-using Hazel;
-using System;
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
+using AmongUs.GameOptions;
+using EHR.Modules;
+using Hazel;
using UnityEngine;
-using static EHR.Roles.Adventurer;
using static EHR.Translator;
namespace EHR.Gamemodes;
@@ -33,7 +32,7 @@ public static class KingOfTheZones
private static readonly KOTZTeam[] AllKOTZTeam = Enum.GetValues();
private static readonly StringBuilder Suffix = new();
- public static (Color Color, string Team) WinnerData = (Color.white, "No one wins");
+ public static (UnityEngine.Color Color, string Team) WinnerData = (Color.white, "No one wins");
private static readonly Dictionary>> DefaultZones = new()
{
diff --git a/Gamemodes/Snowdown.cs b/Gamemodes/Snowdown.cs
index 7cf0830da..09ba8819b 100644
--- a/Gamemodes/Snowdown.cs
+++ b/Gamemodes/Snowdown.cs
@@ -1,8 +1,8 @@
-using EHR.Roles;
-using Hazel;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
+using EHR.Roles;
+using Hazel;
using UnityEngine;
namespace EHR.Gamemodes;
diff --git a/Gamemodes/SoloPVP.cs b/Gamemodes/SoloPVP.cs
index 9ac43ab8b..bf780624f 100644
--- a/Gamemodes/SoloPVP.cs
+++ b/Gamemodes/SoloPVP.cs
@@ -136,14 +136,14 @@ internal static class SoloPVP
var x = (int)(PlayerHP[pc.PlayerId] / PlayerHPMax[pc.PlayerId] * 10 * 50);
var r = 255;
var g = 255;
- var b = 0;
+ const int b = 0;
if (x > 255)
r -= x - 255;
else
g = x;
- return new((byte)r, (byte)g, (byte)b, byte.MaxValue);
+ return new((byte)r, (byte)g, b, byte.MaxValue);
}
private static string GetStatsForVanilla(PlayerControl pc)
diff --git a/Main.cs b/Main.cs
index f05b80785..0fde12dfa 100644
--- a/Main.cs
+++ b/Main.cs
@@ -244,11 +244,10 @@ public class Main : BasePlugin
public static ConfigEntry Preset20 { get; private set; }
// Other Configs
- public static ConfigEntry WebhookUrl { get; private set; }
public static ConfigEntry BetaBuildUrl { get; private set; }
public static ConfigEntry LastKillCooldown { get; private set; }
public static ConfigEntry LastShapeshifterCooldown { get; private set; }
- public static ConfigEntry AckdPrivacyPolicy { get; set; }
+ public static ConfigEntry AckdPrivacyPolicy { get; private set; }
public static PlayerControl[] AllPlayerControlsToArray => CachedAllPlayerControlsList.ToArray();
public static PlayerControl[] AllAlivePlayerControlsToArray => CachedAlivePlayerControlsList.ToArray();
@@ -430,7 +429,7 @@ public class Main : BasePlugin
Preset18 = Config.Bind("Preset Name Options", "Preset18", "Preset_18");
Preset19 = Config.Bind("Preset Name Options", "Preset19", "Preset_19");
Preset20 = Config.Bind("Preset Name Options", "Preset20", "Preset_20");
- WebhookUrl = Config.Bind("Other", "WebhookURL", "none");
+ Config.Bind("Other", "WebhookURL", "none");
BetaBuildUrl = Config.Bind("Other", "BetaBuildURL", string.Empty);
MessageWait = Config.Bind("Other", "MessageWait", 0);
LastKillCooldown = Config.Bind("Other", "LastKillCooldown", (float)30);
@@ -1336,4 +1335,4 @@ public enum TieMode
Random
}
-public class Coroutines : MonoBehaviour { }
+public class Coroutines : MonoBehaviour;
diff --git a/Modules/AntiBlackout.cs b/Modules/AntiBlackout.cs
index 0fa04b902..e03fd3298 100644
--- a/Modules/AntiBlackout.cs
+++ b/Modules/AntiBlackout.cs
@@ -4,7 +4,6 @@ using System.Linq;
using AmongUs.GameOptions;
using EHR.Modules;
using EHR.Patches;
-using Hazel;
namespace EHR;
diff --git a/Modules/ClientOptionItem.cs b/Modules/ClientOptionItem.cs
index a04751880..536afcc58 100644
--- a/Modules/ClientOptionItem.cs
+++ b/Modules/ClientOptionItem.cs
@@ -85,9 +85,10 @@ public class ClientOptionItem
ToggleButton = Object.Instantiate(mouseMoveToggle, CustomBackground.transform);
OptionButtons.Add(ToggleButton);
+ // ReSharper disable once PossibleLossOfFraction
ToggleButton.transform.localPosition = new(
(OptionButtons.Count - 1) % 3 == 0 ? -2.6f : ((OptionButtons.Count - 1) % 3 == 1 ? 0f : 2.6f),
- 2.2f - (0.5f * ((OptionButtons.Count - 1) / 3)),
+ 2.2f - (0.5f * ((OptionButtons.Count - 1) / 3)),
-6f);
ToggleButton.name = name;
@@ -97,7 +98,7 @@ public class ClientOptionItem
passiveButton.OnClick.AddListener(new Action(() =>
{
- if (config != null) config.Value = !config.Value;
+ config?.Value = !config.Value;
UpdateToggle();
additionalOnClickAction?.Invoke();
@@ -126,9 +127,9 @@ public class ClientOptionItem
int totalRows = (OptionButtons.Count + 2) / 3;
- float topPosition = 2.2f;
- float bottomLimit = -1.6f;
- float availableHeight = topPosition - bottomLimit;
+ const float topPosition = 2.2f;
+ const float bottomLimit = -1.6f;
+ const float availableHeight = topPosition - bottomLimit;
float rowSpacing = totalRows > 1 ? availableHeight / (totalRows - 1) : 0f;
for (int i = 0; i < OptionButtons.Count; i++)
diff --git a/Modules/CustomRoleSelector.cs b/Modules/CustomRoleSelector.cs
index f9dee9c9f..98702794d 100644
--- a/Modules/CustomRoleSelector.cs
+++ b/Modules/CustomRoleSelector.cs
@@ -596,7 +596,7 @@ internal static class CustomRoleSelector
private class RoleAssignInfo(CustomRoles role, int spawnChance, int maxCount)
{
public CustomRoles Role => role;
- public int SpawnChance { get; set; } = spawnChance;
+ public int SpawnChance { get; } = spawnChance;
public int MaxCount => maxCount;
public int AssignedCount { get; set; }
diff --git a/Modules/CustomRolesHelper.cs b/Modules/CustomRolesHelper.cs
index 51e52a9f1..0a80418fe 100644
--- a/Modules/CustomRolesHelper.cs
+++ b/Modules/CustomRolesHelper.cs
@@ -1,12 +1,12 @@
-using AmongUs.GameOptions;
-using EHR.Gamemodes;
-using EHR.Modules;
-using EHR.Roles;
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
+using AmongUs.GameOptions;
+using EHR.Gamemodes;
+using EHR.Modules;
+using EHR.Roles;
using UnityEngine;
namespace EHR;
@@ -1754,8 +1754,13 @@ internal static class CustomRolesHelper
: CountTypes.Crew
};
}
- }
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public string ToColoredString()
+ {
+ return role.ColoredTextByRole(Translator.GetString(role.ToString()));
+ }
+ }
extension(Team team)
{
@@ -1786,11 +1791,6 @@ internal static class CustomRolesHelper
}
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static string ToColoredString(this CustomRoles role)
- {
- return role.ColoredTextByRole(Translator.GetString(role.ToString()));
- }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ColoredTextByRole(this CustomRoles role, string str)
{
diff --git a/Modules/CustomSounds.cs b/Modules/CustomSounds.cs
index 397eeb2c6..6047ad4a1 100644
--- a/Modules/CustomSounds.cs
+++ b/Modules/CustomSounds.cs
@@ -1,9 +1,9 @@
-using Hazel;
-using Il2CppInterop.Runtime.InteropTypes.Arrays;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
+using Hazel;
+using Il2CppInterop.Runtime.InteropTypes.Arrays;
using UnityEngine;
namespace EHR.Modules;
@@ -88,18 +88,18 @@ public static class CustomSoundsManager
catch (Exception e) { Utils.ThrowException(e); }
}
- private static readonly Dictionary audioCache = [];
+ private static readonly Dictionary AudioCache = [];
private static void StartPlay(string path, float volume = 1f, float pitch = 1f)
{
- if (!audioCache.TryGetValue(path, out var clip))
+ if (!AudioCache.TryGetValue(path, out var clip))
{
clip = LoadWAV(path);
- audioCache[path] = clip;
+ AudioCache[path] = clip;
}
if (clip)
- SoundManager.Instance.PlaySoundImmediate(clip, false, volume);
+ SoundManager.Instance.PlaySoundImmediate(clip, false, volume, pitch);
}
private static AudioClip LoadWAV(string path)
@@ -169,8 +169,7 @@ public static class CustomSoundsManager
// Allocate memory (right will be null if only mono sound)
LeftChannel = new Il2CppStructArray(SampleCount);
- if (ChannelCount == 2) RightChannel = new Il2CppStructArray(SampleCount);
- else RightChannel = null;
+ RightChannel = ChannelCount == 2 ? new Il2CppStructArray(SampleCount) : null;
int end = pos + dataSize;
// Write to double array/s:
@@ -183,7 +182,7 @@ public static class CustomSoundsManager
if (ChannelCount == 2)
{
- RightChannel[i] = BytesToFloat(wav[pos], wav[pos + 1]);
+ RightChannel?[i] = BytesToFloat(wav[pos], wav[pos + 1]);
pos += 2;
}
i++;
@@ -191,6 +190,7 @@ public static class CustomSoundsManager
}
// Returns left and right double arrays. 'right' will be null if sound is mono.
+/*
public Il2CppStructArray GetStereoData()
{
if (RightChannel == null) return LeftChannel;
@@ -205,5 +205,6 @@ public static class CustomSoundsManager
return stereoData;
}
+*/
}
}
diff --git a/Modules/DataFlagRateLimiter.cs b/Modules/DataFlagRateLimiter.cs
index 96c240226..adf6a514b 100644
--- a/Modules/DataFlagRateLimiter.cs
+++ b/Modules/DataFlagRateLimiter.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Hazel;
@@ -15,7 +16,7 @@ public static class DataFlagRateLimiter
public bool Done;
public bool Dropped;
- public System.Collections.IEnumerator Wait()
+ public IEnumerator Wait()
{
while (!Done)
yield return null;
diff --git a/Modules/Debugger.cs b/Modules/Debugger.cs
index de2871cd9..91515aaff 100644
--- a/Modules/Debugger.cs
+++ b/Modules/Debugger.cs
@@ -233,10 +233,21 @@ public class CustomLogger
{
if (message[i] != '<') continue;
char c = message[i + 1];
- if (c == 'b') hasB = true;
- else if (c == 'u') hasU = true;
- else if (c == 'i') hasI = true;
- else if (c == 's') hasS = true;
+ switch (c)
+ {
+ case 'b':
+ hasB = true;
+ break;
+ case 'u':
+ hasU = true;
+ break;
+ case 'i':
+ hasI = true;
+ break;
+ case 's':
+ hasS = true;
+ break;
+ }
}
if (hasB) message.Append("");
if (hasU) message.Append("");
diff --git a/Modules/DisableDevice.cs b/Modules/DisableDevice.cs
index 895d6624f..b99d3d565 100644
--- a/Modules/DisableDevice.cs
+++ b/Modules/DisableDevice.cs
@@ -63,7 +63,7 @@ internal static class DisableDevice
foreach (var ps in Main.PlayerStates.Values)
{
var role = ps.Role;
- if (role is Rogue rogue && rogue.DisableDevices)
+ if (role is Rogue { DisableDevices: true })
{
rogueForce = true;
break;
@@ -139,7 +139,6 @@ internal static class DisableDevice
{
DesyncComms.Remove(pc.PlayerId);
hasValue = true;
- activateSabComms = false;
}
if (!hasValue) return;
diff --git a/Modules/DoorsReset.cs b/Modules/DoorsReset.cs
index 8c37f7fc2..b2dd06640 100644
--- a/Modules/DoorsReset.cs
+++ b/Modules/DoorsReset.cs
@@ -63,7 +63,7 @@ public static class DoorsReset
}
DoorsSystemType doorsSystem = DoorsSystem;
- if (doorsSystem != null) doorsSystem.IsDirty = true;
+ doorsSystem?.IsDirty = true;
}
/// Close all doors on the map
@@ -79,7 +79,7 @@ public static class DoorsReset
}
DoorsSystemType doorsSystem = DoorsSystem;
- if (doorsSystem != null) doorsSystem.IsDirty = true;
+ doorsSystem?.IsDirty = true;
}
/// Randomly opens and closes all doors on the map
@@ -94,7 +94,7 @@ public static class DoorsReset
}
DoorsSystemType doorsSystem = DoorsSystem;
- if (doorsSystem != null) doorsSystem.IsDirty = true;
+ doorsSystem?.IsDirty = true;
}
/// Sets the open/close status of the door. Do nothing for doors that cannot be closed by sabotage
diff --git a/Modules/EAC.cs b/Modules/EAC.cs
index 74e9bfef7..684369310 100644
--- a/Modules/EAC.cs
+++ b/Modules/EAC.cs
@@ -239,8 +239,8 @@ internal static class EAC
var target = sr.ReadNetObject();
var resultFlags = (MurderResultFlags)sr.ReadInt32();
- if (GameStates.IsInTask && !resultFlags.HasFlag(MurderResultFlags.FailedError) && !resultFlags.HasFlag(MurderResultFlags.FailedProtected) && target != null && !target.Data.IsDead)
- LateTask.New(() => target.RpcRevive(), 0.1f, log: false);
+ if (GameStates.IsInTask && !resultFlags.HasFlag(MurderResultFlags.FailedError) && !resultFlags.HasFlag(MurderResultFlags.FailedProtected) && target && !target.Data.IsDead)
+ LateTask.New(target.RpcRevive, 0.1f, log: false);
Report(pc, "Directly Murder Player");
HandleCheat(pc, "Directly Murder Player");
diff --git a/Modules/ErrorText.cs b/Modules/ErrorText.cs
index 70e59644d..ee7c6f401 100644
--- a/Modules/ErrorText.cs
+++ b/Modules/ErrorText.cs
@@ -28,11 +28,11 @@ public class ErrorText : MonoBehaviour
if (AllErrors.Count == 0) return;
AllErrors.ForEach(err => err.IncreaseTimer());
- ErrorData[] ToRemove = AllErrors.Where(err => err.ErrorLevel <= 1 && 30f < err.Timer).ToArray();
+ ErrorData[] toRemove = AllErrors.Where(err => err.ErrorLevel <= 1 && 30f < err.Timer).ToArray();
- if (ToRemove.Length > 0)
+ if (toRemove.Length > 0)
{
- AllErrors.RemoveAll(err => ToRemove.Contains(err));
+ AllErrors.RemoveAll(toRemove.Contains);
UpdateText();
if (HnSFlag) Destroy(gameObject);
}
diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs
index 0970b42ad..84cf9e4a0 100644
--- a/Modules/ExtendedPlayerControl.cs
+++ b/Modules/ExtendedPlayerControl.cs
@@ -2510,13 +2510,10 @@ internal static class ExtendedPlayerControl
{
if (ShipStatus.Instance.FastRooms.TryGetValue(systemTypes, out var fastRoom))
return fastRoom;
- else
- {
- foreach (var room in ShipStatus.Instance.AllRooms)
- if (room.RoomId == systemTypes)
- return room;
- }
- return default;
+ foreach (var room in ShipStatus.Instance.AllRooms)
+ if (room.RoomId == systemTypes)
+ return room;
+ return null;
}
public static void RpcExitVentDesync(this PlayerPhysics physics, int ventId, PlayerControl seer)
diff --git a/Modules/Extensions/HazelExtensions.cs b/Modules/Extensions/HazelExtensions.cs
index 0f0a4c33c..24d598c3f 100644
--- a/Modules/Extensions/HazelExtensions.cs
+++ b/Modules/Extensions/HazelExtensions.cs
@@ -1,5 +1,4 @@
-using System.Text;
-using Hazel;
+using Hazel;
using UnityEngine;
namespace EHR;
diff --git a/Modules/FixedUpdateCaller.cs b/Modules/FixedUpdateCaller.cs
index c336c727c..be8e72942 100644
--- a/Modules/FixedUpdateCaller.cs
+++ b/Modules/FixedUpdateCaller.cs
@@ -1,5 +1,4 @@
using System;
-using System.Linq;
using EHR.Gamemodes;
using EHR.Patches;
using HarmonyLib;
diff --git a/Modules/GameOptionsSender/NormalGameOptionsSender.cs b/Modules/GameOptionsSender/NormalGameOptionsSender.cs
index 19fe3123c..aab050e4c 100644
--- a/Modules/GameOptionsSender/NormalGameOptionsSender.cs
+++ b/Modules/GameOptionsSender/NormalGameOptionsSender.cs
@@ -3,7 +3,6 @@ using System.Collections;
using AmongUs.GameOptions;
using Hazel;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
-using InnerNet;
namespace EHR.Modules;
diff --git a/Modules/GameState.cs b/Modules/GameState.cs
index a9ceb083f..7be781807 100644
--- a/Modules/GameState.cs
+++ b/Modules/GameState.cs
@@ -400,13 +400,12 @@ public class PlayerState(byte playerId)
{
int count = 0;
var states = Main.PlayerStates.Values;
- byte myId = PlayerId;
foreach (var state in states)
{
- if (state.PlayerId == myId) continue;
+ if (state.PlayerId == PlayerId) continue;
- if (state.GetRealKiller() == myId)
+ if (state.GetRealKiller() == PlayerId)
count++;
}
diff --git a/Modules/LocateArrow.cs b/Modules/LocateArrow.cs
index 5652f773a..b120a04f3 100644
--- a/Modules/LocateArrow.cs
+++ b/Modules/LocateArrow.cs
@@ -1,7 +1,7 @@
-using EHR.Modules;
-using Hazel;
using System.Collections.Generic;
using System.Linq;
+using EHR.Modules;
+using Hazel;
using UnityEngine;
namespace EHR;
diff --git a/Modules/LogHandler/ILogHandler.cs b/Modules/LogHandler/ILogHandler.cs
deleted file mode 100644
index e262deff2..000000000
--- a/Modules/LogHandler/ILogHandler.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-
-namespace EHR.Modules;
-
-public interface ILogHandler
-{
- public void Info(string text);
- public void Warn(string text);
- public void Error(string text);
- public void Fatal(string text);
- public void Msg(string text);
- public void Exception(Exception ex);
-}
\ No newline at end of file
diff --git a/Modules/LogHandler/LogHandler.cs b/Modules/LogHandler/LogHandler.cs
index 270fb83d9..0311016fe 100644
--- a/Modules/LogHandler/LogHandler.cs
+++ b/Modules/LogHandler/LogHandler.cs
@@ -2,7 +2,7 @@ using System;
namespace EHR.Modules;
-internal class LogHandler(string tag) : ILogHandler
+internal class LogHandler(string tag)
{
public string Tag { get; } = tag;
diff --git a/Modules/NameColorManager.cs b/Modules/NameColorManager.cs
index 4b9d0f177..346df0580 100644
--- a/Modules/NameColorManager.cs
+++ b/Modules/NameColorManager.cs
@@ -298,9 +298,7 @@ public static class NameColorManager
private static void Remove(byte seerId, byte targetId)
{
PlayerState state = Main.PlayerStates[seerId];
- if (!state.TargetColorData.ContainsKey(targetId)) return;
-
- state.TargetColorData.Remove(targetId);
+ if (!state.TargetColorData.Remove(targetId)) return;
SendRPC(seerId, targetId);
}
diff --git a/Modules/NameNotifyManager.cs b/Modules/NameNotifyManager.cs
index 12541b491..323f8c2f9 100644
--- a/Modules/NameNotifyManager.cs
+++ b/Modules/NameNotifyManager.cs
@@ -1,7 +1,7 @@
-using EHR.Modules;
-using Hazel;
-using System;
+using System;
using System.Collections.Generic;
+using EHR.Modules;
+using Hazel;
using UnityEngine;
namespace EHR;
@@ -69,9 +69,7 @@ public static class NameNotifyManager
var notifyEnumerator = Notifies.GetEnumerator();
while (notifyEnumerator.MoveNext())
{
- var pair = notifyEnumerator.Current;
- byte id = pair.Key;
- var dict = pair.Value;
+ (byte id, Dictionary dict) = notifyEnumerator.Current;
List toRemove = null;
var innerEnumerator = dict.GetEnumerator();
diff --git a/Modules/OptionItem/OptionItem.cs b/Modules/OptionItem/OptionItem.cs
index 8480810eb..f675048d5 100644
--- a/Modules/OptionItem/OptionItem.cs
+++ b/Modules/OptionItem/OptionItem.cs
@@ -1,7 +1,7 @@
-using EHR.Modules;
-using EHR.Patches;
using System;
using System.Collections.Generic;
+using EHR.Modules;
+using EHR.Patches;
using UnityEngine;
namespace EHR;
@@ -12,8 +12,6 @@ public abstract class OptionItem
public const int PresetId = 0;
public readonly List Children;
- private Dictionary _replacementDictionary;
-
public OptionBehaviour OptionBehaviour;
protected OptionItem(int id, string name, int defaultValue, TabGroup tab, bool isSingleValue)
@@ -70,13 +68,13 @@ public abstract class OptionItem
public Dictionary ReplacementDictionary
{
- get => _replacementDictionary;
+ get;
set
{
if (value == null)
- _replacementDictionary?.Clear();
+ field?.Clear();
else
- _replacementDictionary = value;
+ field = value;
}
}
@@ -306,12 +304,12 @@ public abstract class OptionItem
public static OptionItem operator ++(OptionItem item)
{
- return item.Do(item => item.SetValue(item.CurrentValue + 1));
+ return item.Do(optionItem => optionItem.SetValue(optionItem.CurrentValue + 1));
}
public static OptionItem operator --(OptionItem item)
{
- return item.Do(item => item.SetValue(item.CurrentValue - 1));
+ return item.Do(optionItem => optionItem.SetValue(optionItem.CurrentValue - 1));
}
protected static void SwitchPreset(int newPreset)
@@ -329,7 +327,7 @@ public abstract class OptionItem
if (
PlayerControl.AllPlayerControls.Count <= 1
|| !AmongUsClient.Instance.AmHost
- || PlayerControl.LocalPlayer == null
+ || !PlayerControl.LocalPlayer
)
return;
diff --git a/Modules/OptionItem/TextOptionItem.cs b/Modules/OptionItem/TextOptionItem.cs
index 5ebed2761..8ec1cc539 100644
--- a/Modules/OptionItem/TextOptionItem.cs
+++ b/Modules/OptionItem/TextOptionItem.cs
@@ -2,27 +2,15 @@ namespace EHR;
public class TextOptionItem : OptionItem
{
- public IntegerValueRule Rule;
-
public TextOptionItem(int id, string name, TabGroup tab, int defaultValue = 0, bool isSingleValue = false) : base(id, name, defaultValue, tab, isSingleValue)
{
IsText = true;
IsHeader = true;
}
- public bool CollapsesSection { get; set; } = false;
+ public bool CollapsesSection { get; set; }
// Getter
- public override int GetInt()
- {
- return Rule.GetValueByIndex(CurrentValue);
- }
-
- public override float GetFloat()
- {
- return Rule.GetValueByIndex(CurrentValue);
- }
-
public override string GetString()
{
return Translator.GetString(Name);
diff --git a/Modules/OptionItem/ValueRule.cs b/Modules/OptionItem/ValueRule.cs
index 98d07d93e..582549e2e 100644
--- a/Modules/OptionItem/ValueRule.cs
+++ b/Modules/OptionItem/ValueRule.cs
@@ -4,16 +4,12 @@ namespace EHR;
public abstract class ValueRule(T minValue, T maxValue, T step)
{
- public ValueRule((T, T, T) tuple)
+ protected ValueRule((T, T, T) tuple)
: this(tuple.Item1, tuple.Item2, tuple.Item3) { }
- public T MinValue { get; protected set; } = minValue;
- public T MaxValue { get; protected set; } = maxValue;
- public T Step { get; protected set; } = step;
-
- public abstract int RepeatIndex(int value);
- public abstract T GetValueByIndex(int index);
- public abstract int GetNearestIndex(T num);
+ public T MinValue { get; } = minValue;
+ public T MaxValue { get; } = maxValue;
+ public T Step { get; } = step;
}
public class IntegerValueRule : ValueRule
@@ -29,21 +25,21 @@ public class IntegerValueRule : ValueRule
return new(tuple);
}
- public override int RepeatIndex(int value)
+ public virtual int RepeatIndex(int value)
{
- int MaxIndex = (MaxValue - MinValue) / Step;
- value %= MaxIndex + 1;
- if (value < 0) value = MaxIndex;
+ int maxIndex = (MaxValue - MinValue) / Step;
+ value %= maxIndex + 1;
+ if (value < 0) value = maxIndex;
return value;
}
- public override int GetValueByIndex(int index)
+ public virtual int GetValueByIndex(int index)
{
return (RepeatIndex(index) * Step) + MinValue;
}
- public override int GetNearestIndex(int num)
+ public virtual int GetNearestIndex(int num)
{
return (int)Math.Round((num - MinValue) / (float)Step);
}
@@ -62,21 +58,21 @@ public class FloatValueRule : ValueRule
return new(tuple);
}
- public override int RepeatIndex(int value)
+ public virtual int RepeatIndex(int value)
{
- var MaxIndex = (int)((MaxValue - MinValue) / Step);
- value %= MaxIndex + 1;
- if (value < 0) value = MaxIndex;
+ var maxIndex = (int)((MaxValue - MinValue) / Step);
+ value %= maxIndex + 1;
+ if (value < 0) value = maxIndex;
return value;
}
- public override float GetValueByIndex(int index)
+ public virtual float GetValueByIndex(int index)
{
return (RepeatIndex(index) * Step) + MinValue;
}
- public override int GetNearestIndex(float num)
+ public virtual int GetNearestIndex(float num)
{
return (int)Math.Round((num - MinValue) / Step);
}
diff --git a/Modules/SimpleButton.cs b/Modules/SimpleButton.cs
index f4015b586..bdbe43c8b 100644
--- a/Modules/SimpleButton.cs
+++ b/Modules/SimpleButton.cs
@@ -7,9 +7,6 @@ namespace EHR;
public class SimpleButton
{
private static PassiveButton BaseButton;
- private readonly BoxCollider2D buttonCollider;
- private float _fontSize;
- private Vector2 _scale;
/// Creates a new button
/// Parent object
@@ -36,7 +33,7 @@ public class SimpleButton
Label = Button.transform.Find("FontPlacer/Text_TMP").GetComponent();
NormalSprite = Button.inactiveSprites.GetComponent();
HoverSprite = Button.activeSprites.GetComponent();
- buttonCollider = Button.GetComponent();
+ Button.GetComponent();
// Center the label
Transform container = Label.transform.parent;
@@ -59,18 +56,6 @@ public class SimpleButton
public SpriteRenderer NormalSprite { get; }
public SpriteRenderer HoverSprite { get; }
- public Vector2 Scale
- {
- get => _scale;
- set => _scale = NormalSprite.size = HoverSprite.size = buttonCollider.size = value;
- }
-
- public float FontSize
- {
- get => _fontSize;
- set => _fontSize = Label.fontSize = Label.fontSizeMin = Label.fontSizeMax = value;
- }
-
public static void SetBase(PassiveButton passiveButton)
{
if (BaseButton || !passiveButton) return;
diff --git a/Modules/SpamManager.cs b/Modules/SpamManager.cs
index e30679d56..1d74abcb7 100644
--- a/Modules/SpamManager.cs
+++ b/Modules/SpamManager.cs
@@ -5,7 +5,6 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
-using Hazel;
using static EHR.Translator;
namespace EHR;
diff --git a/Modules/StateMachineWrapper.cs b/Modules/StateMachineWrapper.cs
index 0674cd1bc..64385ac9b 100644
--- a/Modules/StateMachineWrapper.cs
+++ b/Modules/StateMachineWrapper.cs
@@ -3,6 +3,7 @@
using System;
using System.Reflection;
using HarmonyLib;
+
#pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
namespace EHR.Modules;
diff --git a/Modules/TemplateManager.cs b/Modules/TemplateManager.cs
index 6164ee969..1d3393454 100644
--- a/Modules/TemplateManager.cs
+++ b/Modules/TemplateManager.cs
@@ -18,7 +18,7 @@ public static class TemplateManager
private static readonly string TemplateFilePath = $"{Main.DataPath}/EHR_DATA/template.txt";
private static readonly Regex HeaderRegex = new(
- @"^([a-zA-Z0-9_]+)(?:\[([^\]""]*(?:""[^""]*""[^\]""]*)*)\])?:\s*(.*)$",
+ """^([a-zA-Z0-9_]+)(?:\[([^\]"]*(?:"[^"]*"[^\]"]*)*)\])?:\s*(.*)$""",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex PropertyRegex = new(
@@ -74,7 +74,7 @@ public static class TemplateManager
["GameDuration"] = () => { if (!GameStates.IsInGame) return "00:00"; int e = (int)(Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS); return $"{e / 60:00}:{e % 60:00}"; },
["Date"] = () => DateTime.Now.ToShortDateString(),
["Time"] = () => DateTime.Now.ToShortTimeString(),
- ["Preset"] = () => GetString($"Preset_{OptionItem.CurrentPreset + 1}"),
+ ["Preset"] = () => GetString($"Preset_{OptionItem.CurrentPreset + 1}")
};
private class TemplateEntry
@@ -285,7 +285,9 @@ public static class TemplateManager
// Pulls `key="..."` out of propString, returning the quoted value and the remaining string
private static string ExtractQuotedProperty(string input, string key, out string value, out string remaining)
{
- Match m = Regex.Match(input, $@"(?:^|,)\s*{Regex.Escape(key)}\s*=\s*""((?:[^""\\]|\\.)*)""", RegexOptions.IgnoreCase);
+ Match m = Regex.Match(input, $"""
+ (?:^|,)\s*{Regex.Escape(key)}\s*=\s*"((?:[^"\\]|\\.)*)"
+ """, RegexOptions.IgnoreCase);
if (m.Success)
{
value = Regex.Unescape(m.Groups[1].Value);
diff --git a/Modules/Translator.cs b/Modules/Translator.cs
index 01e5c7933..c7603a93b 100644
--- a/Modules/Translator.cs
+++ b/Modules/Translator.cs
@@ -1,5 +1,4 @@
-using EHR.Gamemodes;
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -7,6 +6,7 @@ using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json;
+using EHR.Gamemodes;
namespace EHR;
@@ -36,7 +36,7 @@ public static class Translator
try
{
// Get the directory containing the JSON files (e.g., EHR.Resources.Lang)
- var jsonDirectory = "EHR.Resources.Lang";
+ const string jsonDirectory = "EHR.Resources.Lang";
// Get the assembly containing the resources
var assembly = Assembly.GetExecutingAssembly();
string[] jsonFileNames = GetJsonFileNames(assembly, jsonDirectory);
@@ -174,7 +174,7 @@ public static class Translator
string str = GetString(s, langId);
- if (replacementDic != null && replacementDic.Count > 0)
+ if (replacementDic is { Count: > 0 })
{
foreach (KeyValuePair rd in replacementDic)
str = str.Replace(rd.Key, rd.Value);
diff --git a/Modules/Utils.cs b/Modules/Utils.cs
index f6e0480aa..1d02197bc 100644
--- a/Modules/Utils.cs
+++ b/Modules/Utils.cs
@@ -1,3 +1,14 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Text.RegularExpressions;
using AmongUs.Data;
using AmongUs.GameOptions;
using AmongUs.InnerNet.GameDataMessages;
@@ -12,17 +23,6 @@ using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using InnerNet;
using Newtonsoft.Json;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Text.RegularExpressions;
using UnityEngine;
using static EHR.Translator;
using Tree = EHR.Roles.Tree;
@@ -330,7 +330,7 @@ public static class Utils
foreach (PlayerControl seer in Main.CachedAllPlayerControls())
{
- if (KillFlashCheck(killer, target, seer))
+ if (seer.Is(CustomRoles.GM) || seer.Is(CustomRoles.Seer))
{
seer.KillFlash();
continue;
@@ -358,15 +358,6 @@ public static class Utils
}
}
- private static bool KillFlashCheck(PlayerControl killer, PlayerControl target, PlayerControl seer)
- {
- if (seer.Is(CustomRoles.GM) || seer.Is(CustomRoles.Seer)) return true;
-
- // if (!seer.IsAlive() || killer == seer || target == seer) return false;
-
- return false;
- }
-
public static void BlackOut(this IGameOptions opt, bool blackOut)
{
opt.SetFloat(FloatOptionNames.ImpostorLightMod, blackOut ? 0 : Main.DefaultImpostorVision);
@@ -3137,7 +3128,7 @@ public static class Utils
var state = states[devourerList[index]];
var role = state.Role;
- if (role is Devourer dv && dv.IsEnable && dv.PlayerSkinsCosumed.Contains(seerId))
+ if (role is Devourer { IsEnable: true } dv && dv.PlayerSkinsCosumed.Contains(seerId))
{
selfName = GetString("DevouredName");
break;
@@ -3477,7 +3468,7 @@ public static class Utils
var state = states[devourerList[index]];
var role = state.Role;
- if (role is Devourer dv && dv.IsEnable && dv.PlayerSkinsCosumed.Contains(seerId))
+ if (role is Devourer { IsEnable: true } dv && dv.PlayerSkinsCosumed.Contains(seerId))
{
targetPlayerName = GetString("DevouredName");
break;
@@ -3600,9 +3591,7 @@ public static class Utils
var markList = Markseeker.PlayerIdList;
for (int i = 0; i < markList.Count; i++)
{
- if (states[markList[i]].Role is Markseeker role &&
- role.IsEnable &&
- role.TargetRevealed &&
+ if (states[markList[i]].Role is Markseeker { IsEnable: true, TargetRevealed: true } role &&
role.MarkedId == targetId)
return true;
}
@@ -3680,10 +3669,6 @@ public static class Utils
break;
case CustomRoles.Jackal:
- if (local.Is(CustomRoles.Jackal) || local.Is(CustomRoles.Sidekick))
- return true;
- break;
-
case CustomRoles.Sidekick:
if (local.Is(CustomRoles.Jackal) || local.Is(CustomRoles.Sidekick))
return true;
@@ -3746,9 +3731,7 @@ public static class Utils
var markList = Markseeker.PlayerIdList;
for (int i = 0; i < markList.Count; i++)
{
- if (states[markList[i]].Role is Markseeker role &&
- role.IsEnable &&
- role.TargetRevealed &&
+ if (states[markList[i]].Role is Markseeker { IsEnable: true, TargetRevealed: true } role &&
role.MarkedId == targetId)
return true;
}
diff --git a/Patches/AprilFoolsPatch.cs b/Patches/AprilFoolsPatch.cs
index d82a3743c..8eb3592ff 100644
--- a/Patches/AprilFoolsPatch.cs
+++ b/Patches/AprilFoolsPatch.cs
@@ -33,7 +33,6 @@ public static class GetNormalBodyTypePatch
if (Main.ClassicMode.Value || AprilFoolsMode.ShouldClassicMode())
{
__result = PlayerBodyTypes.Classic;
- return;
}
}
catch { }
diff --git a/Patches/CheckGameEndPatch.cs b/Patches/CheckGameEndPatch.cs
index 4c093454c..f3f415e5e 100644
--- a/Patches/CheckGameEndPatch.cs
+++ b/Patches/CheckGameEndPatch.cs
@@ -1,3 +1,7 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
using AmongUs.GameOptions;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using EHR.Gamemodes;
@@ -6,10 +10,6 @@ using EHR.Roles;
using HarmonyLib;
using Hazel;
using InnerNet;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
using UnityEngine;
using static EHR.CustomWinnerHolder;
using static EHR.Translator;
diff --git a/Patches/ClientPatch.cs b/Patches/ClientPatch.cs
index 45d850dd4..f08fdd0d0 100644
--- a/Patches/ClientPatch.cs
+++ b/Patches/ClientPatch.cs
@@ -1,11 +1,12 @@
-using AmongUs.Data;
-using EHR.Modules;
-using HarmonyLib;
-using Il2CppInterop.Runtime.InteropTypes;
-using InnerNet;
using System;
using System.Linq;
using System.Reflection;
+using AmongUs.Data;
+using EHR.Modules;
+using HarmonyLib;
+using Hazel;
+using Il2CppInterop.Runtime.InteropTypes;
+using InnerNet;
using TMPro;
using UnityEngine;
using static EHR.Translator;
@@ -35,7 +36,7 @@ internal static class MakePublicPatch
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.StartRpcImmediately))]
static class StartRpcImmediatelyPatch
{
- public static void Postfix(uint targetNetId, byte callId, Hazel.SendOption option, int targetClientId = -1)
+ public static void Postfix(uint targetNetId, byte callId, SendOption option, int targetClientId = -1)
{
if (callId is 21 or 44 or 45 or 104) return;
Logger.Info($"Starting RPC: {callId} ({RPC.GetRpcName(callId)}) as {Main.CachedAllPlayerControls().FirstOrDefault(x => x.NetId == targetNetId)?.GetRealName() ?? targetNetId.ToString()} with SendOption {option} to {Utils.GetClientById(targetClientId)?.Character?.GetRealName() ?? targetClientId.ToString()}", "StartRpcImmediately");
diff --git a/Patches/ControlPatch.cs b/Patches/ControlPatch.cs
index 71eb36ddc..f6ffe5536 100644
--- a/Patches/ControlPatch.cs
+++ b/Patches/ControlPatch.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.Linq;
using EHR.Modules;
using EHR.Patches;
using HarmonyLib;
@@ -35,6 +34,9 @@ internal static class ControllerManagerUpdatePatch
private static readonly KeyCode[] ShowActiveSettingsKey = [KeyCode.N, KeyCode.LeftControl];
private static readonly KeyCode[] ResetAllOptionsKey = [KeyCode.Delete, KeyCode.LeftControl, KeyCode.LeftShift];
private static readonly KeyCode[] HostKillSelfKey = [KeyCode.Return, KeyCode.E, KeyCode.LeftShift];
+ private static readonly KeyCode[] OpenClientControlGUILeftKey = [KeyCode.LeftControl, KeyCode.BackQuote];
+ private static readonly KeyCode[] OpenClientControlGUIRightKey = [KeyCode.RightControl, KeyCode.BackQuote];
+#if DEBUG
private static readonly KeyCode[] IsAlsoInGameKey = [KeyCode.F2, KeyCode.LeftControl];
private static readonly KeyCode[] KillFlashKey = [KeyCode.Return, KeyCode.F, KeyCode.LeftShift];
private static readonly KeyCode[] ShowIntroKey = [KeyCode.Return, KeyCode.G, KeyCode.LeftShift];
@@ -42,8 +44,7 @@ internal static class ControllerManagerUpdatePatch
private static readonly KeyCode[] RpcUpdateSystemKey = [KeyCode.Return, KeyCode.D, KeyCode.LeftShift];
private static readonly KeyCode[] SetKillTimerKey = [KeyCode.Return, KeyCode.K, KeyCode.LeftShift];
private static readonly KeyCode[] RpcCompleteTaskKey = [KeyCode.Return, KeyCode.T, KeyCode.LeftShift];
- private static readonly KeyCode[] OpenClientControlGUILeftKey = [KeyCode.LeftControl, KeyCode.BackQuote];
- private static readonly KeyCode[] OpenClientControlGUIRightKey = [KeyCode.RightControl, KeyCode.BackQuote];
+#endif
private static bool IsResetting;
diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs
index 6179938be..1a96f7c93 100644
--- a/Patches/CredentialsPatch.cs
+++ b/Patches/CredentialsPatch.cs
@@ -1,9 +1,8 @@
-using EHR.Modules;
-using HarmonyLib;
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Runtime.CompilerServices;
+using EHR.Modules;
+using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
diff --git a/Patches/Crowded.cs b/Patches/Crowded.cs
index 32bea3448..b0f6f10ef 100644
--- a/Patches/Crowded.cs
+++ b/Patches/Crowded.cs
@@ -1,11 +1,11 @@
-using AmongUs.GameOptions;
-using HarmonyLib;
-using Il2CppInterop.Runtime.Attributes;
-using Il2CppInterop.Runtime.InteropTypes.Arrays;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using AmongUs.GameOptions;
+using HarmonyLib;
+using Il2CppInterop.Runtime.Attributes;
+using Il2CppInterop.Runtime.InteropTypes.Arrays;
using TMPro;
using UnityEngine;
using static EHR.GameStates;
diff --git a/Patches/DisconnectPenaltyPatch.cs b/Patches/DisconnectPenaltyPatch.cs
deleted file mode 100644
index be0c9ef93..000000000
--- a/Patches/DisconnectPenaltyPatch.cs
+++ /dev/null
@@ -1 +0,0 @@
-namespace EHR.Patches;
\ No newline at end of file
diff --git a/Patches/DleksPatch.cs b/Patches/DleksPatch.cs
index 1c0f9e558..be4efa1a8 100644
--- a/Patches/DleksPatch.cs
+++ b/Patches/DleksPatch.cs
@@ -1,7 +1,8 @@
-using EHR.Patches;
+using System.Linq;
+using EHR.Patches;
using HarmonyLib;
-using System;
-using System.Linq;
+using Il2CppSystem;
+using Exception = System.Exception;
namespace EHR;
@@ -14,22 +15,22 @@ internal static class AllMapIconsPatch
[HarmonyPrefix]
public static void GameStartManagerStart_Prefix(GameStartManager __instance)
{
- if (__instance.AllMapIcons.TrueForAll((Il2CppSystem.Predicate)(x => x.Name != MapNames.Dleks)))
+ if (__instance.AllMapIcons.TrueForAll((Predicate)(x => x.Name != MapNames.Dleks)))
{
__instance.AllMapIcons.Insert((int)MapNames.Dleks, new MapIconByName
{
Name = MapNames.Dleks,
- MapIcon = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 160f),
+ MapIcon = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 160f)
});
}
if (SubmergedCompatibility.Loaded)
{
- if (__instance.AllMapIcons.TrueForAll((Il2CppSystem.Predicate)(x => x.Name != (MapNames)6)))
+ if (__instance.AllMapIcons.TrueForAll((Predicate)(x => x.Name != (MapNames)6)))
{
__instance.AllMapIcons.Insert((int)(MapNames)6, new MapIconByName
{
Name = (MapNames)6,
- MapIcon = Utils.LoadSprite("EHR.Resources.Images.Submerged-Wordart.png", 380f),
+ MapIcon = Utils.LoadSprite("EHR.Resources.Images.Submerged-Wordart.png", 380f)
});
}
}
diff --git a/Patches/ExilePatch.cs b/Patches/ExilePatch.cs
index 601a8b3a1..a0deb6502 100644
--- a/Patches/ExilePatch.cs
+++ b/Patches/ExilePatch.cs
@@ -1,11 +1,12 @@
-using System;
using System.Diagnostics;
using System.Linq;
+using System.Reflection;
using AmongUs.Data;
using EHR.Modules;
using EHR.Roles;
using HarmonyLib;
using Hazel;
+using Il2CppInterop.Runtime.InteropTypes;
namespace EHR.Patches;
@@ -220,12 +221,12 @@ internal static class ExileControllerWrapUpPatch
[HarmonyPatch]
static class AirshipExileControllerPatch
{
- public static System.Reflection.MethodBase TargetMethod()
+ public static MethodBase TargetMethod()
{
return Utils.GetStateMachineMoveNext(nameof(AirshipExileController.WrapUpAndSpawn));
}
- public static void Postfix(Il2CppInterop.Runtime.InteropTypes.Il2CppObjectBase __instance, ref bool __result)
+ public static void Postfix(Il2CppObjectBase __instance, ref bool __result)
{
var wrapper = new StateMachineWrapper(__instance);
diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs
index d6550e66c..307c76769 100644
--- a/Patches/GameStartManagerPatch.cs
+++ b/Patches/GameStartManagerPatch.cs
@@ -1,3 +1,6 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
using AmongUs.Data;
using AmongUs.GameOptions;
using EHR.Gamemodes;
@@ -5,10 +8,6 @@ using EHR.Patches;
using EHR.Roles;
using HarmonyLib;
using InnerNet;
-using Rewired.Utils.Platforms.Windows;
-using System;
-using System.Collections.Generic;
-using System.Linq;
using TMPro;
using UnityEngine;
using static EHR.Translator;
diff --git a/Patches/HandshakePatch.cs b/Patches/HandshakePatch.cs
index d8721f6a7..2400216ff 100644
--- a/Patches/HandshakePatch.cs
+++ b/Patches/HandshakePatch.cs
@@ -38,7 +38,7 @@ public enum ModFlags : ushort
///
/// Notifies the game server that the host has authority over game logic.
///
- DisableServerAuthority = 1 << 3,
+ DisableServerAuthority = 1 << 3
}
@@ -60,7 +60,7 @@ public enum ReactorProtocolVersion : byte
///
/// Latest version.
///
- Latest = V3,
+ Latest = V3
}
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.GetConnectionData))]
diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs
index f754f04da..9ed7a0c43 100644
--- a/Patches/HudPatch.cs
+++ b/Patches/HudPatch.cs
@@ -1,15 +1,14 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
using AmongUs.GameOptions;
using EHR.Gamemodes;
using EHR.Modules;
using EHR.Roles;
using HarmonyLib;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.Linq;
-using System.Reflection;
using TMPro;
using UnityEngine;
using static EHR.Translator;
@@ -269,12 +268,12 @@ internal static class HudManagerPatch
break;
}
- if (ShouldHideAbilityButton(role, player))
+ if (ShouldHideAbilityButton())
{
__instance.AbilityButton?.Hide();
}
- bool ShouldHideAbilityButton(CustomRoles role, PlayerControl player)
+ bool ShouldHideAbilityButton()
{
if (!role.PetActivatedAbility()
|| Options.CurrentGameMode != CustomGameMode.Standard
@@ -341,12 +340,11 @@ internal static class HudManagerPatch
{
Sb.Clear();
Suffixes.Clear();
- string suffixText = string.Empty;
var subRoles = state.SubRoles;
for (int i = 0; i < subRoles.Count; i++)
{
- suffixText = subRoles[i] switch
+ string suffixText = subRoles[i] switch
{
CustomRoles.Asthmatic => Asthmatic.GetSuffixText(player.PlayerId),
CustomRoles.Spurt => Spurt.GetSuffix(player, true),
@@ -924,7 +922,7 @@ internal static class SabotageMapPatch
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.Start))]
internal static class MapRoomDoorsStartPatch
{
- public static void Postfix(MapRoom __instance)
+ public static void Postfix()
{
ShipStatus shipStatusInstance = ShipStatus.Instance;
if (!shipStatusInstance || SubmergedCompatibility.IsSubmerged()) return;
@@ -945,9 +943,9 @@ internal static class MapRoomDoorsUpdatePatch
{
public static Dictionary DoorTimerTexts = [];
private static readonly int Percent = Shader.PropertyToID("_Percent");
- public static DoorsSystemType DoorsSystemType = null;
- public static AutoDoorsSystemType AutoDoorsSystemType = null;
- public static Dictionary AutoOpenDoors = [];
+ public static DoorsSystemType DoorsSystemType;
+ public static AutoDoorsSystemType AutoDoorsSystemType;
+ public static readonly Dictionary AutoOpenDoors = [];
public static bool Prefix(MapRoom __instance)
{
@@ -957,8 +955,8 @@ internal static class MapRoomDoorsUpdatePatch
if (!doorSprite || !shipStatusInstance || SubmergedCompatibility.IsSubmerged()) return false;
SystemTypes room = __instance.room;
- float total = 0f;
- float timer = 0f;
+ float total;
+ float timer;
if (DoorsSystemType != null)
{
@@ -1048,7 +1046,6 @@ internal static class SpawnTaskHeaderPatch
internal static class TaskPanelBehaviourPatch
{
// Role info tab panel code from https://github.com/All-Of-Us-Mods/MiraAPI and https://github.com/AU-Avengers/TOU-Mira
- private static readonly StringBuilder Sb = new();
private static readonly StringBuilder InnerSb = new();
private static readonly StringBuilder RoleWithInfoBuilder = new();
private static readonly StringBuilder FinalTextBuilder = new();
@@ -1059,7 +1056,6 @@ internal static class TaskPanelBehaviourPatch
private static readonly List<(PlayerControl pc, string points_string, int points_int)> TempPointsData = [];
private static readonly List SortedPlayers = [];
- private static readonly List SummaryTextList = [];
private static readonly Dictionary SummaryText = [];
public static PassiveButton RolePanelButton;
@@ -1116,7 +1112,7 @@ internal static class TaskPanelBehaviourPatch
string roleInfo = player.GetRoleInfo();
Dictionary playerStates = Main.PlayerStates;
- List AllPlayers = Main.CachedAllPlayerControls();
+ List allPlayers = Main.CachedAllPlayerControls();
RoleWithInfoBuilder.Clear();
int wordCount = 0;
@@ -1203,7 +1199,7 @@ internal static class TaskPanelBehaviourPatch
InnerSb.Clear().Append("\r\n\r\n")
.Append(subRole.ToColoredString())
.Append(":\r\n")
- .Append(GetString(subRole.ToString() + "Info"));
+ .Append(GetString(subRole + "Info"));
FinalTextBuilder.Append(Utils.ColorString(Utils.GetRoleColor(subRole), InnerSb.ToString()));
}
@@ -1215,7 +1211,7 @@ internal static class TaskPanelBehaviourPatch
var chunk = 4;
for (int index = 0; index < countSubRoles; index++)
{
- if (GetString(subRoles[index].ToString()).IndexOf(' ') >= 0)
+ if (GetString(subRoles[index].ToString()).Contains(' '))
{
chunk = 3;
break;
@@ -1270,11 +1266,8 @@ internal static class TaskPanelBehaviourPatch
SortedPlayers.Add(key);
if (SortedPlayers.Count >= 2)
- SortedPlayers.Sort((a, b) =>
- {
- return SoloPVP.GetRankFromScore(a)
- .CompareTo(SoloPVP.GetRankFromScore(b));
- });
+ SortedPlayers.Sort((a, b) => SoloPVP.GetRankFromScore(a)
+ .CompareTo(SoloPVP.GetRankFromScore(b)));
for (int sPId = 0; sPId < SortedPlayers.Count; sPId++)
{
@@ -1298,11 +1291,8 @@ internal static class TaskPanelBehaviourPatch
SortedPlayers.Add(key);
if (SortedPlayers.Count >= 2)
- SortedPlayers.Sort((a, b) =>
- {
- return FreeForAll.GetRankFromScore(a)
- .CompareTo(FreeForAll.GetRankFromScore(b));
- });
+ SortedPlayers.Sort((a, b) => FreeForAll.GetRankFromScore(a)
+ .CompareTo(FreeForAll.GetRankFromScore(b)));
for (int sPId = 0; sPId < SortedPlayers.Count; sPId++)
{
@@ -1397,9 +1387,9 @@ internal static class TaskPanelBehaviourPatch
case CustomGameMode.NaturalDisasters:
{
TempPlayerData.Clear();
- for (int i = 0; i < AllPlayers.Count; i++)
+ for (int i = 0; i < allPlayers.Count; i++)
{
- var pc = AllPlayers[i];
+ var pc = allPlayers[i];
TempPlayerData.Add((pc, pc.IsAlive(), NaturalDisasters.SurvivalTime(pc.PlayerId)));
}
if (TempPlayerData.Count >= 2)
@@ -1415,7 +1405,7 @@ internal static class TaskPanelBehaviourPatch
for (int i = 0; i < TempPlayerData.Count; i++)
{
- var (pc, alive, time) = TempPlayerData[i];
+ (PlayerControl pc, bool alive, int time) = TempPlayerData[i];
FinalTextBuilder.Append("\r\n")
.Append(pc.PlayerId.ColoredPlayerName())
@@ -1434,9 +1424,9 @@ internal static class TaskPanelBehaviourPatch
if (!RoomRush.PointsSystem)
{
- for (int i = 0; i < AllPlayers.Count; i++)
+ for (int i = 0; i < allPlayers.Count; i++)
{
- var pc = AllPlayers[i];
+ var pc = allPlayers[i];
TempPlayerData.Add((pc, pc.IsAlive(), RoomRush.GetSurvivalTime(pc.PlayerId)));
}
if (TempPlayerData.Count >= 2)
@@ -1450,7 +1440,7 @@ internal static class TaskPanelBehaviourPatch
for (int i = 0; i < TempPlayerData.Count; i++)
{
- var (pc, alive, time) = TempPlayerData[i];
+ (PlayerControl pc, bool alive, int time) = TempPlayerData[i];
FinalTextBuilder.Append("\r\n")
.Append(pc.PlayerId.ColoredPlayerName())
@@ -1461,9 +1451,9 @@ internal static class TaskPanelBehaviourPatch
}
else
{
- for (int i = 0; i < AllPlayers.Count; i++)
+ for (int i = 0; i < allPlayers.Count; i++)
{
- var pc = AllPlayers[i];
+ var pc = allPlayers[i];
string pointsStr = RoomRush.GetPoints(pc.PlayerId);
int pointsInt = ParsePointsFast(pointsStr);
@@ -1474,7 +1464,7 @@ internal static class TaskPanelBehaviourPatch
for (int i = 0; i < TempPointsData.Count; i++)
{
- var (pc, points_string, points_int) = TempPointsData[i];
+ (PlayerControl pc, string points_string, _) = TempPointsData[i];
FinalTextBuilder.Append("\r\n")
.Append(pc.PlayerId.ColoredPlayerName())
diff --git a/Patches/HudSpritePatch.cs b/Patches/HudSpritePatch.cs
index 463606d54..c6178053b 100644
--- a/Patches/HudSpritePatch.cs
+++ b/Patches/HudSpritePatch.cs
@@ -45,7 +45,7 @@ public static class HudSpritePatch
Sprite newSabotageButton = DefaultIcons[3];
Sprite newPetButton = DefaultIcons[4];
Sprite newReportButton = DefaultIcons[5];
- Sprite newSecondaryAbilityButton = DefaultIcons[6];
+ //Sprite newSecondaryAbilityButton = DefaultIcons[6];
if (!player.IsAlive())
{
@@ -257,7 +257,7 @@ public static class HudSpritePatch
case CustomRoles.Convener:
{
if (Options.UsePets.GetBool()) newPetButton = CustomButton.Get("Convener");
- else newPetButton = CustomButton.Get("Convener");
+ else newAbilityButton = CustomButton.Get("Convener");
break;
}
case CustomRoles.Doorjammer:
diff --git a/Patches/JoinGameButtonPatch.cs b/Patches/JoinGameButtonPatch.cs
index 21519ff41..b471e68e3 100644
--- a/Patches/JoinGameButtonPatch.cs
+++ b/Patches/JoinGameButtonPatch.cs
@@ -11,7 +11,7 @@ internal class JoinGameButtonPatch
{
if (__instance.GameIdText == null) return;
- if (__instance.GameIdText.text == "" && Regex.IsMatch(GUIUtility.systemCopyBuffer.Trim('\r', '\n'), @"^[A-Z]{6}$"))
+ if (__instance.GameIdText.text == "" && Regex.IsMatch(GUIUtility.systemCopyBuffer.Trim('\r', '\n'), "^[A-Z]{6}$"))
{
Logger.Info($"{GUIUtility.systemCopyBuffer}", "ClipBoard");
__instance.GameIdText.SetText(GUIUtility.systemCopyBuffer.Trim('\r', '\n'));
diff --git a/Patches/LogoAndStampPatch.cs b/Patches/LogoAndStampPatch.cs
deleted file mode 100644
index 17613f7d3..000000000
--- a/Patches/LogoAndStampPatch.cs
+++ /dev/null
@@ -1,152 +0,0 @@
-using System.Collections;
-using BepInEx.Unity.IL2CPP.Utils;
-using HarmonyLib;
-using UnityEngine;
-using static EHR.Translator;
-
-namespace EHR;
-
-// Credit: https://github.com/ykundesu/SuperNewRoles/blob/master/SuperNewRoles/Patches/LogoAndStampPatch.cs
-[HarmonyPatch]
-public static class CredentialsPatch
-{
- [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))]
- public static class LogoPatch
- {
- private static string BoosterData = string.Empty;
- private static string SponsersData = string.Empty;
- private static string DevsData = string.Empty;
- private static string TransData = string.Empty;
-
- private static IEnumerator ViewCredentialsCoro(MainMenuManager __instance)
- {
- while (true)
- {
- yield return new WaitForSecondsRealtime(1f);
-
- if (__instance != null)
- {
- // ViewBoosterPatch(__instance);
- }
-
- break;
- }
- }
-
- public static void InitCredentialsData()
- {
- BoosterData = string.Empty;
- SponsersData = string.Empty;
- DevsData = string.Empty;
- TransData = string.Empty;
-
- DevsData += $"♥咔皮呆 & Gurge44 - {GetString("MainDev")}";
- DevsData += $"\n♥IRIDESCENT - {GetString("Art")}";
- DevsData += $"\nNCSIMON - {GetString("RoleDev")}";
- DevsData += $"\n天寸梦初 - {GetString("RoleDev")}&{GetString("TechSup")}";
- DevsData += $"\nCommandf1 - {GetString("RoleDev")}&{GetString("FeatureDev")}";
- DevsData += $"\n喜 - {GetString("RoleDev")}";
- DevsData += $"\nSHAAARKY - {GetString("RoleDev")}";
- DevsData += $"\nGurge44 - {GetString("FeatureDev")}";
-
- TransData += $"Tommy-XL - {GetString("TranEN")}&{GetString("TranRU")}";
- TransData += $"\nTem - {GetString("TranEN")}&{GetString("TranRU")}";
- TransData += $"\n阿龍 - {GetString("TranCHT")}";
- TransData += $"\nGurge44 - {GetString("TranEN")}";
- TransData += $"\n法官 - {GetString("TranCHT")}";
- TransData += $"\nSolarFlare - {GetString("TranEN")}";
- TransData += $"\nchill_ultimated - {GetString("TranRU")}";
-
- BoosterData += "bunny";
- BoosterData += "\nNamra";
- BoosterData += "\nKNIGHT";
- BoosterData += "\nSolarFlare";
-
- SponsersData += "罗寄";
- SponsersData += "\n鬼";
- SponsersData += "\n喜";
- SponsersData += "\n小叨院长";
- SponsersData += "\n波奇酱";
- SponsersData += "\n法师";
- SponsersData += "\n沐煊";
- SponsersData += "\nSolarFlare";
- SponsersData += "\n林林林";
- SponsersData += "\n撒币";
- SponsersData += "\n斯卡蒂Skadi";
- SponsersData += "\nltemten";
- SponsersData += $"\n\n({GetString("OnlyShowPart")})";
- }
-
- /*
- static void ViewBoosterPatch(MainMenuManager __instance)
- {
- var template = __instance.transform.FindChild("StatsPopup");
- var obj = Object.Instantiate(template, template.transform.parent).gameObject;
- Object.Destroy(obj.GetComponent());
-
- var devtitletext = obj.transform.FindChild("StatNumsText_TMP");
- devtitletext.GetComponent().text = GetString("Developer");
- devtitletext.GetComponent().alignment = TextAlignmentOptions.Center;
- devtitletext.localPosition = new(-2.4f, 1.65f, -2f);
- devtitletext.localScale = new(0.8f, 0.8f, 0.8f);
-
- var devtext = obj.transform.FindChild("StatsText_TMP");
- devtext.GetComponent().text = DevsData;
- devtext.GetComponent().alignment = TextAlignmentOptions.Capline;
- devtext.localPosition = new(-2.4f, 1.27f, -2f);
- devtext.localScale = new(0.5f, 0.5f, 1f);
-
- var transtitletext = Object.Instantiate(devtitletext, obj.transform);
- transtitletext.GetComponent().text = GetString("Translator");
- transtitletext.GetComponent().alignment = TextAlignmentOptions.Center;
- transtitletext.localPosition = new(0f, 1.65f, -2f);
- transtitletext.localScale = new(0.8f, 0.8f, 1f);
-
- var transtext = Object.Instantiate(devtext, obj.transform);
- transtext.GetComponent().text = TransData;
- transtext.GetComponent().alignment = TextAlignmentOptions.Capline;
- transtext.localPosition = new(0f, 1.27f, -2f);
- transtext.localScale = new(0.5f, 0.5f, 1f);
-
- var boostertitletext = Object.Instantiate(devtitletext, obj.transform);
- boostertitletext.GetComponent().text = GetString("Booster");
- boostertitletext.GetComponent().alignment = TextAlignmentOptions.Center;
- boostertitletext.localPosition = new(-2.4f, -1f, -2f);
- boostertitletext.localScale = new(0.8f, 0.8f, 1f);
-
- var boostertext = Object.Instantiate(devtext, obj.transform);
- boostertext.GetComponent().text = BoosterData;
- boostertext.GetComponent().alignment = TextAlignmentOptions.Capline;
- boostertext.localPosition = new(-2.4f, -1.38f, -2f);
- boostertext.localScale = new(0.5f, 0.5f, 1f);
-
- var sponsortitletext = Object.Instantiate(devtitletext, obj.transform);
- sponsortitletext.GetComponent().text = GetString("Sponsor");
- sponsortitletext.GetComponent().alignment = TextAlignmentOptions.Center;
- sponsortitletext.localPosition = new(2.4f, 1.65f, -2f);
- sponsortitletext.localScale = new(0.8f, 0.8f, 1f);
-
- var sponsortext = Object.Instantiate(devtext, obj.transform);
- sponsortext.GetComponent().text = SponsersData;
- sponsortext.GetComponent().alignment = TextAlignmentOptions.Capline;
- sponsortext.localPosition = new(2.4f, 1.27f, -2f);
- sponsortext.localScale = new(0.5f, 0.5f, 1f);
-
- var textobj = obj.transform.FindChild("Title_TMP");
- Object.Destroy(textobj.GetComponent());
- textobj.GetComponent().text = GetString("DevAndSpnTitle");
- textobj.GetComponent().alignment = TextAlignmentOptions.Center;
- textobj.localScale = new(1.2f, 1.2f, 1f);
- textobj.localPosition = new(0f, 2.2f, -2f);
- obj.transform.FindChild("Background").localScale = new(1.5f, 1f, 1f);
- obj.transform.FindChild("CloseButton").localPosition = new(-3.75f, 2.65f, 0);
- }
- */
-
- public static void Postfix(MainMenuManager __instance)
- {
- InitCredentialsData();
- AmongUsClient.Instance.StartCoroutine(ViewCredentialsCoro(__instance));
- }
- }
-}
\ No newline at end of file
diff --git a/Patches/MapPickerMenuPatch.cs b/Patches/MapPickerMenuPatch.cs
index 847defeb8..50b18f8ab 100644
--- a/Patches/MapPickerMenuPatch.cs
+++ b/Patches/MapPickerMenuPatch.cs
@@ -1,6 +1,8 @@
-using System;
-using HarmonyLib;
+using HarmonyLib;
+using Il2CppSystem;
using UnityEngine.SceneManagement;
+using Action = System.Action;
+using Exception = System.Exception;
namespace EHR.Patches;
@@ -23,26 +25,26 @@ public static class GameOptionsMapPickerPatch
[HarmonyPrefix]
public static void Postfix_Prefix(GameOptionsMapPicker __instance)
{
- if (__instance.AllMapIcons.TrueForAll((Il2CppSystem.Predicate)(x => x.Name != MapNames.Dleks)))
+ if (__instance.AllMapIcons.TrueForAll((Predicate)(x => x.Name != MapNames.Dleks)))
{
__instance.AllMapIcons.Insert((int)MapNames.Dleks, new MapIconByName
{
Name = MapNames.Dleks,
MapImage = Utils.LoadSprite("EHR.Resources.Images.DleksBanner.png", 100f),
MapIcon = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Icon.png", 95f),
- NameImage = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 160f),
+ NameImage = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 160f)
});
}
if (SubmergedCompatibility.Loaded)
{
- if (__instance.AllMapIcons.TrueForAll((Il2CppSystem.Predicate)(x => x.Name != (MapNames)6)))
+ if (__instance.AllMapIcons.TrueForAll((Predicate)(x => x.Name != (MapNames)6)))
{
__instance.AllMapIcons.Insert((int)(MapNames)6, new MapIconByName
{
Name = (MapNames)6,
MapImage = Utils.LoadSprite("EHR.Resources.Images.SubmergedBanner.png", 100f),
//MapIcon = Utils.LoadSprite("EHR.Resources.Images.Submerged-Icon.png", 100f),
- NameImage = Utils.LoadSprite("EHR.Resources.Images.Submerged-Wordart.png", 100f),
+ NameImage = Utils.LoadSprite("EHR.Resources.Images.Submerged-Wordart.png", 100f)
});
}
}
diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs
index 6bdfc719a..4d14a1ae6 100644
--- a/Patches/MeetingHudPatch.cs
+++ b/Patches/MeetingHudPatch.cs
@@ -655,32 +655,38 @@ internal static class ExtendedMeetingHud
if (Poache.PoachedPlayers.Contains(ps.TargetPlayerId)) voteNum = 0;
if (Silencer.ForSilencer.Contains(ps.TargetPlayerId) && Main.AllAlivePlayerControlsCount > Silencer.MaxPlayersAliveForSilencedToVote.GetInt()) voteNum = 0;
- if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Magistrate) && Magistrate.CallCourtNextMeeting) voteNum += Magistrate.ExtraVotes.GetInt();
if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Knighted)) voteNum += 1;
- if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Glitch) && !Glitch.CanVote.GetBool()) voteNum = 0;
- if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Shifter) && !Shifter.CanVote.GetBool()) voteNum = 0;
- if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Vindicator)) voteNum += Options.VindicatorAdditionalVote.GetInt();
if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Schizophrenic) && Options.DualVotes.GetBool()) voteNum += voteNum;
if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Stealer)) voteNum += (int)(Main.EnumeratePlayerControls().Count(x => x.GetRealKiller()?.PlayerId == ps.TargetPlayerId) * Options.VotesPerKill.GetFloat());
- if (CheckForEndVotingPatch.CheckRole(ps.TargetPlayerId, CustomRoles.Pickpocket)) voteNum += (int)(Main.EnumeratePlayerControls().Count(x => x.GetRealKiller()?.PlayerId == ps.TargetPlayerId) * Pickpocket.VotesPerKill.GetFloat());
-
+
switch (Main.PlayerStates[ps.TargetPlayerId].Role)
{
+ case Dad { IsEnable: true } dad when dad.UsingAbilities.Contains(Dad.Ability.GoForMilk):
+ case Shifter when !Shifter.CanVote.GetBool():
+ case Glitch when !Glitch.CanVote.GetBool():
+ voteNum = 0;
+ break;
case Adventurer { IsEnable: true } av when av.ActiveWeapons.Contains(Adventurer.Weapon.Proxy):
voteNum++;
break;
- case Dad { IsEnable: true } dad when dad.UsingAbilities.Contains(Dad.Ability.GoForMilk):
- voteNum = 0;
- break;
case Amogus { IsEnable: true, ExtraVotes: > 0 } amogus:
voteNum += amogus.ExtraVotes;
break;
case Mayor mayor:
voteNum += Mayor.MayorAdditionalVote.GetInt() + mayor.TaskVotes;
break;
- case Survivor survivor when Main.AllAlivePlayerControlsCount <= Survivor.ThirdAbility.GetInt():
+ case Survivor when Main.AllAlivePlayerControlsCount <= Survivor.ThirdAbility.GetInt():
voteNum += Survivor.AdditionalVote.GetInt();
break;
+ case Pickpocket:
+ voteNum += (int)(Main.EnumeratePlayerControls().Count(x => x.GetRealKiller()?.PlayerId == ps.TargetPlayerId) * Pickpocket.VotesPerKill.GetFloat());
+ break;
+ case Vindicator:
+ voteNum += Options.VindicatorAdditionalVote.GetInt();
+ break;
+ case Magistrate when Magistrate.CallCourtNextMeeting:
+ voteNum += Magistrate.ExtraVotes.GetInt();
+ break;
}
if (ps.TargetPlayerId == ps.VotedFor && Options.MadmateSpawnMode.GetInt() == 2 && CustomRoles.Madmate.IsEnable() && MeetingStates.FirstMeeting) voteNum = 0;
diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs
index b5bd43415..3f0b95887 100644
--- a/Patches/OnGameStartedPatch.cs
+++ b/Patches/OnGameStartedPatch.cs
@@ -36,13 +36,11 @@ internal static class ChangeRoleSettings
IEnumerator