mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
23 files changed
+84
-85
No files matched your search
+2
-2
@@ -42,7 +42,7 @@ internal class BAUPlugin : BasePlugin
|
||||
text = $"v{BetterAmongUsVersion}{newLineText}Beta {ModInfo.BetaNum}";
|
||||
break;
|
||||
case ReleaseTypes.Dev:
|
||||
text = $"v{BetterAmongUsVersion}{newLineText}Dev {ModInfo.ReleaseDate}";
|
||||
text = $"v{BetterAmongUsVersion}{newLineText}Dev {ModInfo.CommitHash}-{ModInfo.BuildDate}";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -106,7 +106,7 @@ internal class BAUPlugin : BasePlugin
|
||||
Logger_.Log("Better Among Us successfully loaded!");
|
||||
|
||||
string SupportedVersions = string.Join(" ", SupportedAmongUsVersions);
|
||||
Logger_.Log($"BetterAmongUs {BetterAmongUsVersion}-{ModInfo.ReleaseDate} - [{AppVersion} --> {SupportedVersions}] {Utils.GetPlatformName(PlatformData.Platform)}");
|
||||
Logger_.Log($"BetterAmongUs {BetterAmongUsVersion}-{ModInfo.BuildDate} - [{AppVersion} --> {SupportedVersions}] {Utils.GetPlatformName(PlatformData.Platform)}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -7,10 +7,27 @@
|
||||
<langVersion>preview</langVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Build Events -->
|
||||
<!-- Meta Data -->
|
||||
<PropertyGroup>
|
||||
<CommitHash Condition="'$(CommitHash)' == ''">unknown</CommitHash>
|
||||
<BuildDate>$([System.DateTime]::UtcNow.ToString(MM.dd.yyyy))</BuildDate>
|
||||
<IsCI Condition="'$(CI)' == 'true' or '$(GITHUB_ACTIONS)' == 'true' or '$(TF_BUILD)' == 'true'">true</IsCI>
|
||||
<IsCI Condition="'$(IsCI)' == ''">false</IsCI>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Build Events -->
|
||||
<ItemGroup>
|
||||
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
|
||||
<_Parameter1>CommitHash</_Parameter1>
|
||||
<_Parameter2>$(CommitHash)</_Parameter2>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
|
||||
<_Parameter1>BuildDate</_Parameter1>
|
||||
<_Parameter2>$(BuildDate)</_Parameter2>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ModPathFile>build\mod_folder_path</ModPathFile>
|
||||
<GamePath Condition="Exists('$(ModPathFile)') and '$(IsCI)' != 'true'">$([System.IO.File]::ReadAllText('$(ModPathFile)').Trim())</GamePath>
|
||||
<ModsPath>$(GamePath)</ModsPath>
|
||||
@@ -28,6 +45,7 @@
|
||||
<Message Text="Mod was NOT copied to game folder!" Importance="high" />
|
||||
</Target>
|
||||
|
||||
<!-- Packages -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2025.11.18" />
|
||||
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1">
|
||||
@@ -37,8 +55,8 @@
|
||||
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.692" Private="false" ExcludeAssets="runtime;native" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Resources -->
|
||||
<ItemGroup>
|
||||
<!-- Embed all files in the Resources folder -->
|
||||
<EmbeddedResource Include="Resources\**\*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -7,7 +7,7 @@ internal static class EnumHelper
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of enum to be obtained</typeparam>
|
||||
/// <returns>All values of T</returns>
|
||||
internal static T[] GetAllValues<T>() where T : Enum => Enum.GetValues(typeof(T)) as T[];
|
||||
internal static T[]? GetAllValues<T>() where T : Enum => Enum.GetValues(typeof(T)) as T[];
|
||||
/// <summary>
|
||||
/// Get all names in enum
|
||||
/// </summary>
|
||||
@@ -22,13 +22,13 @@ internal static class EnumHelper
|
||||
/// <typeparam name="TEnum">Type of enum to be obtained</typeparam>
|
||||
/// <param name="chunkSize">The number of elements each chunk should contain. </param>
|
||||
/// <returns>A list of arrays, each containing up to <paramref name="chunkSize"/> elements of the enum type.</returns>
|
||||
internal static List<TEnum[]> Achunk<TEnum>(int chunkSize, bool shuffle = false, Func<TEnum, bool> exclude = null) where TEnum : Enum
|
||||
internal static List<TEnum[]> Achunk<TEnum>(int chunkSize, bool shuffle = false, Func<TEnum, bool>? exclude = null) where TEnum : Enum
|
||||
{
|
||||
List<TEnum[]> chunkedList = [];
|
||||
TEnum[] allValues = GetAllValues<TEnum>();
|
||||
TEnum[]? allValues = GetAllValues<TEnum>();
|
||||
var rnd = new Random();
|
||||
if (shuffle) allValues = allValues.Shuffle(rnd).ToArray();
|
||||
if (exclude != null) allValues = allValues.Where(exclude).ToArray();
|
||||
if (shuffle) allValues = [.. allValues.Shuffle(rnd)];
|
||||
if (exclude != null) allValues = [.. allValues.Where(exclude)];
|
||||
|
||||
for (int i = 0; i < allValues.Length; i += chunkSize)
|
||||
{
|
||||
|
||||
@@ -359,7 +359,7 @@ internal static class InnerNetClientHelper
|
||||
messageWriter.ForEach(mW => mW.Write("RPC TEST"));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
*/
|
||||
internal static List<MessageWriter> StartRpcDesync(this InnerNetClient client, uint playerNetId, byte callId, SendOption option, int ignoreClientId = -1, Func<ClientData, bool> clientCheck = null)
|
||||
internal static List<MessageWriter> StartRpcDesync(this InnerNetClient client, uint playerNetId, byte callId, SendOption option, int ignoreClientId = -1, Func<ClientData, bool>? clientCheck = null)
|
||||
{
|
||||
List<MessageWriter> messageWriters = [];
|
||||
|
||||
|
||||
@@ -124,14 +124,12 @@ static class PlayerControlHelper
|
||||
{
|
||||
longModeParts[i].material.SetFloat("_Outline", active ? 1 : 0);
|
||||
}
|
||||
if (color != null)
|
||||
|
||||
player.cosmetics.currentBodySprite.BodySprite.material.SetColor("_OutlineColor", color);
|
||||
longModeParts = player.cosmetics.currentBodySprite.LongModeParts;
|
||||
for (int i = 0; i < longModeParts.Length; i++)
|
||||
{
|
||||
player.cosmetics.currentBodySprite.BodySprite.material.SetColor("_OutlineColor", color);
|
||||
longModeParts = player.cosmetics.currentBodySprite.LongModeParts;
|
||||
for (int i = 0; i < longModeParts.Length; i++)
|
||||
{
|
||||
longModeParts[i].material.SetColor("_OutlineColor", color);
|
||||
}
|
||||
longModeParts[i].material.SetColor("_OutlineColor", color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ internal static class Utils
|
||||
if (Application.internetReachability == NetworkReachability.NotReachable)
|
||||
return false;
|
||||
|
||||
UnityWebRequest www = null;
|
||||
UnityWebRequest? www = null;
|
||||
try
|
||||
{
|
||||
www = UnityWebRequest.Get("http://clients3.google.com/generate_204");
|
||||
@@ -317,7 +317,7 @@ internal static class Utils
|
||||
}
|
||||
|
||||
// Resource loading
|
||||
internal static Sprite LoadSprite(string path, float pixelsPerUnit = 1f)
|
||||
internal static Sprite? LoadSprite(string path, float pixelsPerUnit = 1f)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
+19
-7
@@ -1,15 +1,27 @@
|
||||
namespace BetterAmongUs;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
internal static class ModInfo
|
||||
{
|
||||
internal static readonly ReleaseTypes ReleaseBuildType = ReleaseTypes.Beta;
|
||||
internal const string BetaNum = "2";
|
||||
internal const string HotfixNum = "1";
|
||||
internal const bool IsHotFix = true;
|
||||
internal static readonly ReleaseTypes ReleaseBuildType = ReleaseTypes.Release;
|
||||
internal const string BetaNum = "0";
|
||||
internal const string HotfixNum = "0";
|
||||
internal const bool IsHotFix = false;
|
||||
internal const string PluginName = "BetterAmongUs";
|
||||
internal const string PluginGuid = "com.d1gq.betteramongus";
|
||||
internal const string PluginVersion = "1.3.1";
|
||||
internal const string ReleaseDate = "01.09.2026"; // mm/dd/yyyy
|
||||
internal const string Github = "https://github.com/D1GQ/BetterAmongUs-Public";
|
||||
internal const string Github = "https://github.com/D1GQ/BetterAmongUs";
|
||||
internal const string Discord = "https://discord.gg/vjYrXpzNAn";
|
||||
public static string CommitHash => GetAssemblyMetadata("CommitHash");
|
||||
public static string BuildDate => GetAssemblyMetadata("BuildDate");
|
||||
|
||||
private static string GetAssemblyMetadata(string key)
|
||||
{
|
||||
var attribute = Assembly.GetExecutingAssembly()
|
||||
.GetCustomAttributes<AssemblyMetadataAttribute>()
|
||||
.FirstOrDefault(a => a.Key == key);
|
||||
|
||||
return attribute?.Value ?? "unknown";
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ internal sealed class ClientOptionItem
|
||||
finally { numOptions++; }
|
||||
}
|
||||
|
||||
internal static ClientOptionItem Create(string name, ConfigEntry<bool> config, OptionsMenuBehaviour optionsMenuBehaviour, Action? additionalOnClickAction = null, Func<bool>? toggleCheck = null, bool IsToggle = true)
|
||||
internal static ClientOptionItem Create(string name, ConfigEntry<bool>? config, OptionsMenuBehaviour optionsMenuBehaviour, Action? additionalOnClickAction = null, Func<bool>? toggleCheck = null, bool IsToggle = true)
|
||||
{
|
||||
toggleCheck ??= () => true;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ internal sealed class OptionDividerItem : OptionItem
|
||||
return Item;
|
||||
}
|
||||
|
||||
protected void CreateBehavior()
|
||||
private void CreateBehavior()
|
||||
{
|
||||
if (!GameSettingMenu.Instance) return;
|
||||
AllTBROptionsTemp.Add(this);
|
||||
|
||||
@@ -22,7 +22,7 @@ internal sealed class OptionHeaderItem : OptionItem
|
||||
return Item;
|
||||
}
|
||||
|
||||
protected void CreateBehavior()
|
||||
private void CreateBehavior()
|
||||
{
|
||||
if (!GameSettingMenu.Instance) return;
|
||||
AllTBROptionsTemp.Add(this);
|
||||
|
||||
@@ -22,7 +22,7 @@ internal sealed class OptionTitleItem : OptionItem
|
||||
return Item;
|
||||
}
|
||||
|
||||
protected void CreateBehavior()
|
||||
private void CreateBehavior()
|
||||
{
|
||||
if (!GameSettingMenu.Instance) return;
|
||||
AllTBROptionsTemp.Add(this);
|
||||
|
||||
@@ -7,7 +7,7 @@ internal sealed class OptionCheckboxItem : OptionItem<bool>
|
||||
{
|
||||
internal sealed override bool ShowChildren => base.ShowChildren && Value;
|
||||
|
||||
internal static OptionCheckboxItem Create(int id, OptionTab tab, string tranStr, bool defaultValue, OptionItem parent = null)
|
||||
internal static OptionCheckboxItem Create(int id, OptionTab tab, string tranStr, bool defaultValue, OptionItem? parent = null)
|
||||
{
|
||||
if (GetOptionById(id) is OptionCheckboxItem checkboxItem)
|
||||
{
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace BetterAmongUs.Modules.OptionItems;
|
||||
internal class OptionFloatItem : OptionItem<float>
|
||||
{
|
||||
internal override bool ShowChildren => base.ShowChildren && Value > 0f;
|
||||
protected FloatRange Range { get; set; }
|
||||
protected FloatRange? Range { get; set; }
|
||||
protected float Increment { get; set; }
|
||||
protected bool CanBeInfinite { get; set; }
|
||||
protected (string prefix, string postfix) Fixs { get; set; }
|
||||
|
||||
internal static OptionFloatItem Create(int id, OptionTab tab, string tranStr, (float minValue, float maxValue, float incrementValue) Min_Max_Increment, float defaultValue, (string prefix, string postfix) Prefix_Postfix = new(), OptionItem parent = null, bool canBeInfinite = false)
|
||||
internal static OptionFloatItem Create(int id, OptionTab tab, string tranStr, (float minValue, float maxValue, float incrementValue) Min_Max_Increment, float defaultValue, (string prefix, string postfix) Prefix_Postfix = new(), OptionItem? parent = null, bool canBeInfinite = false)
|
||||
{
|
||||
if (GetOptionById(id) is OptionFloatItem floatItem)
|
||||
{
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace BetterAmongUs.Modules.OptionItems;
|
||||
internal sealed class OptionIntItem : OptionItem<int>
|
||||
{
|
||||
internal sealed override bool ShowChildren => base.ShowChildren && Value > 0;
|
||||
protected IntRange Range { get; set; }
|
||||
protected int Increment { get; set; }
|
||||
protected bool CanBeInfinite { get; set; }
|
||||
protected (string prefix, string postfix) Fixs { get; set; }
|
||||
private IntRange? Range { get; set; }
|
||||
private int Increment { get; set; }
|
||||
private bool CanBeInfinite { get; set; }
|
||||
private (string prefix, string postfix) Fixs { get; set; }
|
||||
|
||||
internal static OptionIntItem Create(int id, OptionTab tab, string tranStr, (int minValue, int maxValue, int incrementValue) Min_Max_Increment, int defaultValue, (string prefix, string postfix) Prefix_Postfix = new(), OptionItem parent = null, bool canBeInfinite = false)
|
||||
internal static OptionIntItem Create(int id, OptionTab tab, string tranStr, (int minValue, int maxValue, int incrementValue) Min_Max_Increment, int defaultValue, (string prefix, string postfix) Prefix_Postfix = new(), OptionItem? parent = null, bool canBeInfinite = false)
|
||||
{
|
||||
if (GetOptionById(id) is OptionIntItem intItem)
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ internal abstract class OptionItem
|
||||
|
||||
List<TreeNode> treeNodes = [];
|
||||
|
||||
void CollectTreeData(OptionItem option, int depth, bool isLastChild, TreeNode parent)
|
||||
void CollectTreeData(OptionItem option, int depth, bool isLastChild, TreeNode? parent)
|
||||
{
|
||||
var node = new TreeNode
|
||||
{
|
||||
@@ -190,7 +190,7 @@ internal abstract class OptionItem
|
||||
|
||||
List<TreeNode> treeNodes = [];
|
||||
|
||||
void CollectTreeData(OptionItem option, int depth, bool isLastChild, TreeNode parent)
|
||||
void CollectTreeData(OptionItem option, int depth, bool isLastChild, TreeNode? parent)
|
||||
{
|
||||
var node = new TreeNode
|
||||
{
|
||||
@@ -363,7 +363,7 @@ internal abstract class OptionItem
|
||||
class TreeNode
|
||||
{
|
||||
internal TreeNode? ParentNode { get; set; }
|
||||
internal string Text { get; set; }
|
||||
internal string? Text { get; set; }
|
||||
internal int Depth { get; set; }
|
||||
internal bool IsLastChild { get; set; }
|
||||
}
|
||||
@@ -433,7 +433,7 @@ internal abstract class OptionItem<T> : OptionItem
|
||||
|
||||
internal virtual void SetValue(T newValue)
|
||||
{
|
||||
T oldValue = Value;
|
||||
T? oldValue = Value;
|
||||
Value = newValue;
|
||||
UpdateVisuals();
|
||||
PopNotification();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
internal sealed class OptionPercentItem : OptionFloatItem
|
||||
{
|
||||
internal static OptionPercentItem Create(int id, OptionTab tab, string tranStr, float defaultValue, OptionItem parent = null)
|
||||
internal static OptionPercentItem Create(int id, OptionTab tab, string tranStr, float defaultValue, OptionItem? parent = null)
|
||||
{
|
||||
if (GetOptionById(id) is OptionPercentItem floatItem)
|
||||
{
|
||||
|
||||
@@ -8,12 +8,12 @@ internal sealed class OptionPlayerItem : OptionItem<int>
|
||||
internal sealed override bool ShowChildren => base.ShowChildren && Value > Min;
|
||||
private int Max => BAUPlugin.AllPlayerControls.Count - 1;
|
||||
private int Min => CanBeRandom ? -1 : 0;
|
||||
protected bool CanBeRandom { get; set; }
|
||||
private bool CanBeRandom { get; set; }
|
||||
internal override bool CanLoad => false;
|
||||
|
||||
private static List<OptionPlayerItem> optionPlayerItems = [];
|
||||
|
||||
internal static OptionPlayerItem Create(int id, OptionTab tab, string tranStr, OptionItem parent = null, bool canBeRandom = true)
|
||||
internal static OptionPlayerItem Create(int id, OptionTab tab, string tranStr, OptionItem? parent = null, bool canBeRandom = true)
|
||||
{
|
||||
if (optionPlayerItems.FirstOrDefault(opt => opt.Id == id) is OptionPlayerItem playerItem)
|
||||
{
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace BetterAmongUs.Modules.OptionItems;
|
||||
|
||||
internal sealed class OptionStringItem : OptionItem<int>
|
||||
{
|
||||
protected IntRange Range { get; set; } = new();
|
||||
protected string[] TranslatorStrings { get; set; } = [];
|
||||
protected bool CanBeRandom { get; set; }
|
||||
private IntRange Range { get; set; } = new();
|
||||
private string[] TranslatorStrings { get; set; } = [];
|
||||
private bool CanBeRandom { get; set; }
|
||||
|
||||
internal static OptionStringItem Create(int id, OptionTab tab, string tranStr, string[] tranStrings, int defaultValue, OptionItem parent = null, bool canBeRandom = false)
|
||||
internal static OptionStringItem Create(int id, OptionTab tab, string tranStr, string[] tranStrings, int defaultValue, OptionItem? parent = null, bool canBeRandom = false)
|
||||
{
|
||||
if (tranStrings.Length < 2)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@ internal class PlayerInfoDisplay : MonoBehaviour
|
||||
private readonly StringBuilder _sbTagBottom = new(256);
|
||||
private string _lastTopText = "", _lastBottomText = "", _lastInfoText = "";
|
||||
private int _lastUpdateFrame;
|
||||
private bool _lastPlayerState;
|
||||
private const int UPDATE_COOLDOWN = 10;
|
||||
|
||||
// Cached regex patterns
|
||||
|
||||
@@ -30,6 +30,7 @@ internal static class OptionsMenuBehaviourPatch
|
||||
[HarmonyPrefix]
|
||||
private static void Start_Postfix(OptionsMenuBehaviour __instance)
|
||||
{
|
||||
/*
|
||||
static bool toggleCheckInGamePlay(string buttonName)
|
||||
{
|
||||
bool flag = GameState.IsInGame && !GameState.IsLobby || GameState.IsFreePlay;
|
||||
@@ -38,6 +39,8 @@ internal static class OptionsMenuBehaviourPatch
|
||||
|
||||
return flag;
|
||||
}
|
||||
*/
|
||||
|
||||
static bool toggleCheckInGame(string buttonName)
|
||||
{
|
||||
bool flag = GameState.IsInGame;
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace BetterAmongUs.Patches.Client;
|
||||
[HarmonyPatch(typeof(MainMenuManager))]
|
||||
internal static class MainMenuPatch
|
||||
{
|
||||
private static SpriteRenderer? sprite;
|
||||
internal static PassiveButton? ButtonPrefab;
|
||||
|
||||
[HarmonyPatch(nameof(MainMenuManager.LateUpdate))]
|
||||
|
||||
@@ -26,7 +26,6 @@ class BetterGameSettings
|
||||
internal static OptionCheckboxItem? CensorDetectionReason;
|
||||
internal static OptionCheckboxItem? RemovePetOnDeath;
|
||||
internal static OptionCheckboxItem? DisableSabotages;
|
||||
internal static OptionCheckboxItem? ShowRoleForClients;
|
||||
}
|
||||
|
||||
class BetterGameSettingsTemp
|
||||
@@ -44,7 +43,7 @@ internal static class GameSettingMenuPatch
|
||||
|
||||
internal static void SetupSettings(bool IsPreload = false)
|
||||
{
|
||||
// Use 1800 next ID
|
||||
// Use 1700 next ID
|
||||
|
||||
BetterSettingsTab = OptionTab.Create(3, "BetterSetting", "BetterSetting.Description", Color.green);
|
||||
|
||||
@@ -63,12 +62,6 @@ internal static class GameSettingMenuPatch
|
||||
BetterGameSettings.UseBanNameList = OptionCheckboxItem.Create(400, BetterSettingsTab, "BetterSetting.Setting.UseBanNameList", true);
|
||||
BetterGameSettings.UseBanWordList = OptionCheckboxItem.Create(500, BetterSettingsTab, "BetterSetting.Setting.UseBanWordList", true);
|
||||
BetterGameSettings.UseBanWordListOnlyLobby = OptionCheckboxItem.Create(1400, BetterSettingsTab, "BetterSetting.Setting.UseBanWordListOnlyLobby", true, BetterGameSettings.UseBanWordList);
|
||||
|
||||
/*
|
||||
OptionDividerItem.Create(BetterSettingsTab);
|
||||
BetterGameSettings.ShowRoleForClients = OptionCheckboxItem.Create(1700, BetterSettingsTab, "BetterSetting.Setting.ShowRoleForClients", false);
|
||||
OptionDividerItem.Create(BetterSettingsTab);
|
||||
*/
|
||||
}
|
||||
|
||||
OptionTitleItem.Create(BetterSettingsTab, "BetterSetting.TextHeader.Detections");
|
||||
|
||||
@@ -126,7 +126,7 @@ internal static class RoleManagerPatch
|
||||
|
||||
if (Impostors.Count < NumImpostors && RNG() > ImpostorMultiplier[Utils.GetHashPuid(pc)])
|
||||
{
|
||||
var impRoles = Shuffle(ImpostorRoles);
|
||||
var impRoles = ImpostorRoles.Shuffle();
|
||||
foreach (var kvp in impRoles)
|
||||
{
|
||||
if (RNG() <= GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(kvp.Key) && kvp.Value > 0)
|
||||
@@ -163,7 +163,7 @@ internal static class RoleManagerPatch
|
||||
}
|
||||
else
|
||||
{
|
||||
var crewRoles = Shuffle(CrewmateRoles);
|
||||
var crewRoles = CrewmateRoles.Shuffle();
|
||||
foreach (var kvp in crewRoles)
|
||||
{
|
||||
if (RNG() <= GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(kvp.Key) && kvp.Value > 0)
|
||||
@@ -316,7 +316,7 @@ internal static class RoleManagerPatch
|
||||
}
|
||||
}
|
||||
|
||||
var ghostRoles = Shuffle(GhostRoles);
|
||||
var ghostRoles = GhostRoles.Shuffle();
|
||||
|
||||
foreach (var kvp in ghostRoles)
|
||||
{
|
||||
@@ -346,29 +346,6 @@ internal static class RoleManagerPatch
|
||||
|
||||
private static bool IsImpostorRole(RoleTypes role) => role is RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom or RoleTypes.Viper;
|
||||
|
||||
private static Dictionary<TKey, TValue> Shuffle<TKey, TValue>(Dictionary<TKey, TValue> dictionary)
|
||||
{
|
||||
List<TKey> keys = dictionary.Keys.ToList();
|
||||
|
||||
// Fisher-Yates shuffle algorithm
|
||||
for (int i = keys.Count - 1; i > 0; i--)
|
||||
{
|
||||
int j = random.Next(0, i + 1);
|
||||
TKey temp = keys[i];
|
||||
keys[i] = keys[j];
|
||||
keys[j] = temp;
|
||||
}
|
||||
|
||||
// Rebuild dictionary with shuffled keys
|
||||
var shuffledDictionary = new Dictionary<TKey, TValue>();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
shuffledDictionary[key] = dictionary[key];
|
||||
}
|
||||
|
||||
return shuffledDictionary;
|
||||
}
|
||||
|
||||
internal static int RNG()
|
||||
{
|
||||
switch (BetterGameSettings.RoleRandomizer.GetStringValue())
|
||||
|
||||
Reference in new issue
Block a user