mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
28 files changed
+991
-280
No files matched your search
@@ -247,7 +247,7 @@ class AntiCheat
|
||||
if (reader.BytesRemaining > 0)
|
||||
{
|
||||
uint level = reader.ReadPackedUInt32();
|
||||
if (level >= BetterGameSettings.DetectedLevelAbove.GetInt())
|
||||
if (level > BetterGameSettings.DetectedLevelAbove.GetInt())
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Level: {level}");
|
||||
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {level >= 200}");
|
||||
|
||||
@@ -173,46 +173,67 @@ class BetterDataManager
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool LoadBoolSetting(int id)
|
||||
public static bool LoadBoolSetting(int id, bool Default = false)
|
||||
{
|
||||
string filePath = SettingsFile;
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, string>>(json) ?? new Dictionary<string, string>();
|
||||
|
||||
if (jsonData.ContainsKey(id.ToString()))
|
||||
try
|
||||
{
|
||||
return bool.Parse(jsonData[id.ToString()]);
|
||||
if (jsonData.ContainsKey(id.ToString()))
|
||||
{
|
||||
return bool.Parse(jsonData[id.ToString()]);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
SaveSetting(id, Default.ToString());
|
||||
}
|
||||
|
||||
return false;
|
||||
return Default;
|
||||
}
|
||||
|
||||
public static float LoadFloatSetting(int id)
|
||||
public static float LoadFloatSetting(int id, float Default = 0f)
|
||||
{
|
||||
string filePath = SettingsFile;
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, string>>(json) ?? new Dictionary<string, string>();
|
||||
|
||||
if (jsonData.ContainsKey(id.ToString()))
|
||||
try
|
||||
{
|
||||
return float.Parse(jsonData[id.ToString()]);
|
||||
if (jsonData.ContainsKey(id.ToString()))
|
||||
{
|
||||
return float.Parse(jsonData[id.ToString()]);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
SaveSetting(id, Default.ToString());
|
||||
}
|
||||
|
||||
return -1f;
|
||||
return Default;
|
||||
}
|
||||
|
||||
public static int LoadIntSetting(int id)
|
||||
public static int LoadIntSetting(int id, int Default = 0)
|
||||
{
|
||||
string filePath = SettingsFile;
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, string>>(json) ?? new Dictionary<string, string>();
|
||||
|
||||
if (jsonData.ContainsKey(id.ToString()))
|
||||
try
|
||||
{
|
||||
return int.Parse(jsonData[id.ToString()]);
|
||||
if (jsonData.ContainsKey(id.ToString()))
|
||||
{
|
||||
return int.Parse(jsonData[id.ToString()]);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
SaveSetting(id, Default.ToString());
|
||||
}
|
||||
|
||||
return -1;
|
||||
return Default;
|
||||
}
|
||||
|
||||
public static void SaveBanList(string friendCode = "", string hashPUID = "")
|
||||
|
||||
@@ -206,77 +206,104 @@ class BetterHostManager
|
||||
|
||||
foreach (PlayerControl target in Main.AllPlayerControls)
|
||||
{
|
||||
if (target == null || target == PlayerControl.LocalPlayer || target.BetterData().IsBetterUser) continue;
|
||||
if (target == null || target == PlayerControl.LocalPlayer) continue;
|
||||
|
||||
string NewName = player.CurrentOutfit.PlayerName;
|
||||
|
||||
StringBuilder sbTopTag = new StringBuilder();
|
||||
StringBuilder sbTopInfo = new StringBuilder();
|
||||
|
||||
if (GameStates.IsLobby)
|
||||
if (!player.BetterData().IsBetterUser)
|
||||
{
|
||||
NewName = player.Data.PlayerName;
|
||||
|
||||
if (player.IsHost())
|
||||
NewName = player.GetPlayerNameAndColor();
|
||||
|
||||
if (player.IsDev())
|
||||
sbTopTag.Append("<color=#6e6e6e>(<color=#0088ff>Dev</color>)</color>+++");
|
||||
|
||||
if (player == PlayerControl.LocalPlayer)
|
||||
sbTopTag.Append($"<color=#0dff00>Better Host</color>+++");
|
||||
else if (player.BetterData().IsBetterUser)
|
||||
sbTopTag.Append("<color=#0dff00>Better User</color>+++");
|
||||
}
|
||||
else if (GameStates.IsInGamePlay && !GameStates.IsHideNSeek)
|
||||
{
|
||||
string Role = $"<color={player.GetTeamHexColor()}>{player.GetRoleName()}</color>";
|
||||
if (!player.IsImpostorTeam() && player.myTasks.Count > 0)
|
||||
if (GameStates.IsLobby)
|
||||
{
|
||||
Role += $" <color=#cbcbcb>({player.Data.Tasks.ToArray().Where(task => task.Complete).Count()}/{player.Data.Tasks.Count})</color>";
|
||||
NewName = player.Data.PlayerName;
|
||||
|
||||
if (player.IsHost())
|
||||
NewName = player.GetPlayerNameAndColor();
|
||||
|
||||
if (player.IsDev())
|
||||
sbTopTag.Append("<color=#6e6e6e>(<color=#0088ff>Dev</color>)</color>+++");
|
||||
|
||||
if (player == PlayerControl.LocalPlayer)
|
||||
sbTopTag.Append($"<color=#0dff00>Better Host</color>+++");
|
||||
else if (player.BetterData().IsBetterUser)
|
||||
sbTopTag.Append("<color=#0dff00>Better User</color>+++");
|
||||
}
|
||||
if (player.IsImpostorTeam() is false || target.IsImpostorTeam() is false)
|
||||
else if (GameStates.IsInGamePlay && !GameStates.IsHideNSeek)
|
||||
{
|
||||
if (target.IsAlive() && player != target)
|
||||
string Role = $"<color={player.GetTeamHexColor()}>{player.GetRoleName()}</color>";
|
||||
if (!player.IsImpostorTeam() && player.myTasks.Count > 0)
|
||||
{
|
||||
Role = "";
|
||||
Role += $" <color=#cbcbcb>({player.Data.Tasks.ToArray().Where(task => task.Complete).Count()}/{player.Data.Tasks.Count})</color>";
|
||||
}
|
||||
if (player.IsImpostorTeam() is false || target.IsImpostorTeam() is false)
|
||||
{
|
||||
if (target.IsAlive() && player != target)
|
||||
{
|
||||
Role = "";
|
||||
}
|
||||
}
|
||||
|
||||
sbTopTag.Append($"{Role}+++");
|
||||
}
|
||||
else if (GameStates.IsInGamePlay)
|
||||
{
|
||||
if (player == target)
|
||||
{
|
||||
if (player.IsImpostorTeam())
|
||||
{
|
||||
sbTopTag.Append($"<color={Utils.GetTeamHexColor(RoleTeamTypes.Impostor)}>Seeker</color>+++");
|
||||
}
|
||||
else
|
||||
{
|
||||
sbTopTag.Append($"<color={Utils.GetTeamHexColor(RoleTeamTypes.Crewmate)}>Hider</color>+++");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sbTopTag.Append($"{Role}+++");
|
||||
}
|
||||
|
||||
for (int i = 0; i < sbTopTag.ToString().Split("+++").Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(sbTopTag.ToString().Split("+++")[i]))
|
||||
// Put +++ at the end of each tag
|
||||
static StringBuilder FormatInfo(StringBuilder source)
|
||||
{
|
||||
if (i < sbTopTag.ToString().Split("+++").Length)
|
||||
var sb = new StringBuilder();
|
||||
if (source.Length > 0)
|
||||
{
|
||||
sbTopInfo.Append(sbTopTag.ToString().Split("+++")[i]);
|
||||
string text = source.ToString();
|
||||
string[] parts = text.Split("+++");
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Utils.RemoveHtmlText(parts[i])))
|
||||
{
|
||||
sb.Append(parts[i]);
|
||||
if (i != parts.Length - 2)
|
||||
{
|
||||
sb.Append(" - ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i != sbTopTag.ToString().Split("+++").Length - 2)
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
sbTopTag = FormatInfo(sbTopTag);
|
||||
|
||||
if (sbTopTag.Length > 0)
|
||||
NewName = $"<size=65%>{sbTopTag}</size>\n{NewName}";
|
||||
else
|
||||
NewName = $"{NewName}";
|
||||
|
||||
// Don't send rpc if name is the same!
|
||||
if (player.BetterData().LastNameSetFor.TryGetValue(target.PlayerId, out var lastName))
|
||||
{
|
||||
if (lastName == NewName || !force)
|
||||
{
|
||||
sbTopInfo.Append(" - ");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player.BetterData().LastNameSetFor[target.PlayerId] = NewName;
|
||||
}
|
||||
|
||||
if (sbTopInfo.Length > 0)
|
||||
NewName = $"<size=65%>{sbTopInfo}</size>\n{NewName}";
|
||||
else
|
||||
NewName = $"{NewName}";
|
||||
|
||||
// Don't send rpc if name is the same!
|
||||
if (player.BetterData().LastNameSetFor.TryGetValue(target.PlayerId, out var lastName))
|
||||
{
|
||||
if (lastName == NewName || !force)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player.BetterData().LastNameSetFor[target.PlayerId] = NewName;
|
||||
|
||||
player.RpcSetNamePrivate(NewName, target);
|
||||
Logger.Log($"Set {player.Data.PlayerName} name to {NewName.Replace("\n", "-")} for {target.Data.PlayerName}", "RPC");
|
||||
}
|
||||
|
||||
@@ -129,11 +129,6 @@ static class ExtendedPlayerControl
|
||||
}
|
||||
|
||||
// RPCs
|
||||
public static void RpcSendHostChat(this PlayerControl player, string text, string title = "<color=#ffffff><b>(<color=#00ff44>System Message</color>)</b>", bool sendToBetterUser = true)
|
||||
{
|
||||
if (player == null) return;
|
||||
RPC.SendHostChatToPlayer(player, text, title, sendToBetterUser);
|
||||
}
|
||||
public static void RpcSetNamePrivate(this PlayerControl player, string name, PlayerControl target)
|
||||
{
|
||||
if (player == null || target == null) return;
|
||||
|
||||
@@ -7,12 +7,17 @@ public class BetterOptionCheckboxItem : BetterOptionItem
|
||||
private ToggleOption? ThisOption;
|
||||
private bool? IsChecked;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, bool DefaultValue = true, BetterOptionItem Parent = null)
|
||||
public override bool ShowChildrenCondition() => IsChecked == true;
|
||||
public override bool SelfShowCondition() => ShowCondition != null ? ShowCondition() : base.SelfShowCondition();
|
||||
public Func<bool>? ShowCondition = null;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, bool DefaultValue = true, BetterOptionItem? Parent = null, Func<bool>? selfShowCondition = null)
|
||||
{
|
||||
Id = id;
|
||||
Tab = gameOptionsMenu;
|
||||
Name = name;
|
||||
IsChecked = DefaultValue;
|
||||
ShowCondition = selfShowCondition;
|
||||
|
||||
if (gameOptionsMenu == null)
|
||||
{
|
||||
@@ -21,10 +26,17 @@ public class BetterOptionCheckboxItem : BetterOptionItem
|
||||
}
|
||||
|
||||
ToggleOption optionBehaviour = UnityEngine.Object.Instantiate<ToggleOption>(gameOptionsMenu.checkboxOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f, -2f);
|
||||
SetUp(optionBehaviour);
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>((option) => ValueChanged(id, option));
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
optionBehaviour.LabelBackground.transform.localScale = new Vector3(1.6f, 0.78f);
|
||||
optionBehaviour.LabelBackground.transform.SetLocalX(-2.4f);
|
||||
optionBehaviour.TitleText.enableAutoSizing = false;
|
||||
optionBehaviour.TitleText.transform.SetLocalX(-1.5f);
|
||||
optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Right;
|
||||
optionBehaviour.TitleText.enableWordWrapping = false;
|
||||
optionBehaviour.TitleText.fontSize = 2.5f;
|
||||
|
||||
// Set data
|
||||
optionBehaviour.CheckMark.GetComponent<SpriteRenderer>().enabled = DefaultValue;
|
||||
@@ -35,6 +47,28 @@ public class BetterOptionCheckboxItem : BetterOptionItem
|
||||
Load(DefaultValue);
|
||||
|
||||
BetterOptionItems.Add(this);
|
||||
obj = optionBehaviour.gameObject;
|
||||
|
||||
if (Parent != null)
|
||||
{
|
||||
int Index = 1;
|
||||
var tempParent = Parent;
|
||||
|
||||
while (tempParent.ThisParent != null)
|
||||
{
|
||||
tempParent = tempParent.ThisParent;
|
||||
Index++;
|
||||
}
|
||||
|
||||
optionBehaviour.LabelBackground.GetComponent<SpriteRenderer>().color -= new Color(0.25f, 0.25f, 0.25f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.localScale -= new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.position += new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.SetLocalZ(1f);
|
||||
ThisParent = Parent;
|
||||
IsChild = true;
|
||||
Parent.ChildrenList.Add(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -44,7 +78,7 @@ public class BetterOptionCheckboxItem : BetterOptionItem
|
||||
{
|
||||
if (ThisOption == null) return;
|
||||
|
||||
var Bool = BetterDataManager.LoadBoolSetting(Id);
|
||||
var Bool = BetterDataManager.LoadBoolSetting(Id, DefaultValue);
|
||||
ThisOption.CheckMark.GetComponent<SpriteRenderer>().enabled = Bool;
|
||||
IsChecked = Bool;
|
||||
}
|
||||
@@ -79,5 +113,15 @@ public class BetterOptionCheckboxItem : BetterOptionItem
|
||||
{
|
||||
IsChecked = !IsChecked;
|
||||
BetterDataManager.SaveSetting(Id, IsChecked.ToString());
|
||||
|
||||
if (IsParent || IsChild)
|
||||
{
|
||||
bool Bool = ShowChildrenCondition();
|
||||
foreach (var item in ChildrenList)
|
||||
{
|
||||
item.obj.SetActive(Bool && item.SelfShowCondition());
|
||||
}
|
||||
UpdatePositions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,18 @@ namespace BetterAmongUs;
|
||||
|
||||
public class BetterOptionFloatItem : BetterOptionItem
|
||||
{
|
||||
private NumberOption? ThisOption;
|
||||
public float CurrentValue;
|
||||
public FloatRange floatRange = new(0f, 180f);
|
||||
public float Increment = 2.5f;
|
||||
private NumberOption? ThisOption;
|
||||
private string? PostFix;
|
||||
private string? PreFix;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, float[] values, float DefaultValue, string preFix = "", string postFix = "", BetterOptionItem Parent = null)
|
||||
public override bool ShowChildrenCondition() => CurrentValue > floatRange.min;
|
||||
public override bool SelfShowCondition() => ShowCondition != null ? ShowCondition() : base.SelfShowCondition();
|
||||
public Func<bool>? ShowCondition = null;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, float[] values, float DefaultValue, string preFix = "", string postFix = "", BetterOptionItem? Parent = null, Func<bool>? selfShowCondition = null)
|
||||
{
|
||||
Id = id;
|
||||
floatRange = new(values[0], values[1]);
|
||||
@@ -20,6 +24,7 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
if (DefaultValue < floatRange.min) DefaultValue = floatRange.min;
|
||||
if (DefaultValue > floatRange.max) DefaultValue = floatRange.max;
|
||||
CurrentValue = DefaultValue;
|
||||
ShowCondition = selfShowCondition;
|
||||
|
||||
if (gameOptionsMenu == null)
|
||||
{
|
||||
@@ -30,10 +35,9 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
if (values.Length is < 3 or > 3) return null;
|
||||
|
||||
NumberOption optionBehaviour = UnityEngine.Object.Instantiate<NumberOption>(gameOptionsMenu.numberOptionOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f, -2f);
|
||||
SetUp(optionBehaviour);
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>((option) => ValueChanged(id, option));
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
// Fix Game Crash
|
||||
foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
@@ -45,6 +49,16 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => Decrease()));
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => ValueChanged(id, optionBehaviour)));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => ValueChanged(id, optionBehaviour)));
|
||||
|
||||
optionBehaviour.LabelBackground.transform.localScale = new Vector3(1.6f, 0.78f);
|
||||
optionBehaviour.LabelBackground.transform.SetLocalX(-2.4f);
|
||||
optionBehaviour.TitleText.enableAutoSizing = false;
|
||||
optionBehaviour.TitleText.transform.SetLocalX(-1.5f);
|
||||
optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Right;
|
||||
optionBehaviour.TitleText.enableWordWrapping = false;
|
||||
optionBehaviour.TitleText.fontSize = 2.5f;
|
||||
|
||||
// Set data
|
||||
Tab = gameOptionsMenu;
|
||||
@@ -59,6 +73,28 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
AdjustButtonsActiveState();
|
||||
|
||||
BetterOptionItems.Add(this);
|
||||
obj = optionBehaviour.gameObject;
|
||||
|
||||
if (Parent != null)
|
||||
{
|
||||
int Index = 1;
|
||||
var tempParent = Parent;
|
||||
|
||||
while (tempParent.ThisParent != null)
|
||||
{
|
||||
tempParent = tempParent.ThisParent;
|
||||
Index++;
|
||||
}
|
||||
|
||||
optionBehaviour.LabelBackground.GetComponent<SpriteRenderer>().color -= new Color(0.25f, 0.25f, 0.25f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.localScale -= new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.position += new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.SetLocalZ(1f);
|
||||
ThisParent = Parent;
|
||||
IsChild = true;
|
||||
Parent.ChildrenList.Add(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -99,6 +135,10 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
{
|
||||
CurrentValue += Increment * times;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentValue = floatRange.max;
|
||||
}
|
||||
|
||||
AdjustButtonsActiveState();
|
||||
}
|
||||
@@ -115,6 +155,10 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
{
|
||||
CurrentValue -= Increment * times;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentValue = floatRange.min;
|
||||
}
|
||||
|
||||
AdjustButtonsActiveState();
|
||||
}
|
||||
@@ -123,7 +167,7 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
{
|
||||
if (BetterDataManager.CanLoadSetting(Id))
|
||||
{
|
||||
var Float = BetterDataManager.LoadFloatSetting(Id);
|
||||
var Float = BetterDataManager.LoadFloatSetting(Id, DefaultValue);
|
||||
|
||||
if (Float > floatRange.max || Float < floatRange.min)
|
||||
{
|
||||
@@ -174,5 +218,14 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
|
||||
public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
||||
{
|
||||
if (IsParent || IsChild)
|
||||
{
|
||||
bool Bool = ShowChildrenCondition();
|
||||
foreach (var item in ChildrenList)
|
||||
{
|
||||
item.obj.SetActive(Bool && item.SelfShowCondition());
|
||||
}
|
||||
UpdatePositions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,18 @@ namespace BetterAmongUs;
|
||||
|
||||
public class BetterOptionIntItem : BetterOptionItem
|
||||
{
|
||||
private NumberOption? ThisOption;
|
||||
public int CurrentValue;
|
||||
public IntRange intRange = new(0, 180);
|
||||
public int Increment = 1;
|
||||
private NumberOption? ThisOption;
|
||||
private string? PostFix;
|
||||
private string? PreFix;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, int[] values, int DefaultValue, string preFix = "", string postFix = "", BetterOptionItem Parent = null)
|
||||
public override bool ShowChildrenCondition() => CurrentValue > intRange.min;
|
||||
public override bool SelfShowCondition() => ShowCondition != null ? ShowCondition() : base.SelfShowCondition();
|
||||
public Func<bool>? ShowCondition = null;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, int[] values, int DefaultValue, string preFix = "", string postFix = "", BetterOptionItem? Parent = null, Func<bool>? selfShowCondition = null)
|
||||
{
|
||||
Id = id;
|
||||
intRange = new(values[0], values[1]);
|
||||
@@ -19,6 +23,7 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
if (DefaultValue < intRange.min) DefaultValue = intRange.min;
|
||||
if (DefaultValue > intRange.max) DefaultValue = intRange.max;
|
||||
CurrentValue = DefaultValue;
|
||||
ShowCondition = selfShowCondition;
|
||||
|
||||
if (gameOptionsMenu == null)
|
||||
{
|
||||
@@ -29,10 +34,9 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
if (values.Length is < 3 or > 3) return null;
|
||||
|
||||
NumberOption optionBehaviour = UnityEngine.Object.Instantiate<NumberOption>(gameOptionsMenu.numberOptionOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f, -2f);
|
||||
SetUp(optionBehaviour);
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>((option) => ValueChanged(id, option));
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
// Fix Game Crash
|
||||
foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
@@ -44,6 +48,16 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => Decrease()));
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => ValueChanged(id, optionBehaviour)));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => ValueChanged(id, optionBehaviour)));
|
||||
|
||||
optionBehaviour.LabelBackground.transform.localScale = new Vector3(1.6f, 0.78f);
|
||||
optionBehaviour.LabelBackground.transform.SetLocalX(-2.4f);
|
||||
optionBehaviour.TitleText.enableAutoSizing = false;
|
||||
optionBehaviour.TitleText.transform.SetLocalX(-1.5f);
|
||||
optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Right;
|
||||
optionBehaviour.TitleText.enableWordWrapping = false;
|
||||
optionBehaviour.TitleText.fontSize = 2.5f;
|
||||
|
||||
// Set data
|
||||
Tab = gameOptionsMenu;
|
||||
@@ -58,6 +72,28 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
AdjustButtonsActiveState();
|
||||
|
||||
BetterOptionItems.Add(this);
|
||||
obj = optionBehaviour.gameObject;
|
||||
|
||||
if (Parent != null)
|
||||
{
|
||||
int Index = 1;
|
||||
var tempParent = Parent;
|
||||
|
||||
while (tempParent.ThisParent != null)
|
||||
{
|
||||
tempParent = tempParent.ThisParent;
|
||||
Index++;
|
||||
}
|
||||
|
||||
optionBehaviour.LabelBackground.GetComponent<SpriteRenderer>().color -= new Color(0.25f, 0.25f, 0.25f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.localScale -= new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.position += new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.SetLocalZ(1f);
|
||||
ThisParent = Parent;
|
||||
IsChild = true;
|
||||
Parent.ChildrenList.Add(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -98,6 +134,10 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
{
|
||||
CurrentValue += Increment * times;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentValue = intRange.max;
|
||||
}
|
||||
|
||||
AdjustButtonsActiveState();
|
||||
}
|
||||
@@ -114,6 +154,10 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
{
|
||||
CurrentValue -= Increment * times;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentValue = intRange.min;
|
||||
}
|
||||
|
||||
AdjustButtonsActiveState();
|
||||
}
|
||||
@@ -122,7 +166,7 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
{
|
||||
if (BetterDataManager.CanLoadSetting(Id))
|
||||
{
|
||||
var Int = BetterDataManager.LoadIntSetting(Id);
|
||||
var Int = BetterDataManager.LoadIntSetting(Id, DefaultValue);
|
||||
|
||||
if (Int > intRange.max || Int < intRange.min)
|
||||
{
|
||||
@@ -167,11 +211,20 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
optionBehaviour.data = new BaseGameSetting
|
||||
{
|
||||
Title = StringNames.None,
|
||||
Type = OptionTypes.Float,
|
||||
Type = OptionTypes.Int,
|
||||
};
|
||||
}
|
||||
|
||||
public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
||||
{
|
||||
if (IsParent || IsChild)
|
||||
{
|
||||
bool Bool = ShowChildrenCondition();
|
||||
foreach (var item in ChildrenList)
|
||||
{
|
||||
item.obj.SetActive(Bool && item.SelfShowCondition());
|
||||
}
|
||||
UpdatePositions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using TMPro;
|
||||
using BetterAmongUs.Patches;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
@@ -7,6 +8,8 @@ public class BetterOptionItem
|
||||
{
|
||||
public float StaticSpacingNum => 1f;
|
||||
public float StaticSpacingNumPlus => 0.45f;
|
||||
public static Dictionary<int, int> TempPlayerOptionData = [];
|
||||
public static int TempPlayerOptionDataNum = 0;
|
||||
public static List<BetterOptionItem> BetterOptionItems = [];
|
||||
public static float SpacingNum = 0;
|
||||
|
||||
@@ -16,6 +19,63 @@ public class BetterOptionItem
|
||||
public OptionBehaviour? Option;
|
||||
public string? Name = "None";
|
||||
public TextMeshPro? TitleText;
|
||||
public GameObject? obj;
|
||||
|
||||
public BetterOptionItem? ThisParent;
|
||||
public bool IsChild = false;
|
||||
public bool IsParent => ChildrenList.Count > 0;
|
||||
public List<BetterOptionItem> ChildrenList = [];
|
||||
public virtual bool ShowChildrenCondition() => false;
|
||||
public virtual bool SelfShowCondition() => true;
|
||||
|
||||
public static void UpdatePositions()
|
||||
{
|
||||
SpacingNum = 0f;
|
||||
|
||||
foreach (var item in BetterOptionItems)
|
||||
{
|
||||
try
|
||||
{
|
||||
item.obj.transform.SetLocalY(2f);
|
||||
|
||||
// Need to fix name not setting
|
||||
if (item.ThisParent != null)
|
||||
{
|
||||
_ = new LateTask(() =>
|
||||
{
|
||||
item.obj.SetActive(item.ThisParent.ShowChildrenCondition() && item.SelfShowCondition() && item.ThisParent.Option.gameObject.active);
|
||||
}, 0.005f, shoudLog: false);
|
||||
if (!(item.ThisParent.ShowChildrenCondition() && item.SelfShowCondition() && item.ThisParent.Option.gameObject.active))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item is BetterOptionPlayerItem player)
|
||||
{
|
||||
player.Load();
|
||||
}
|
||||
|
||||
SpacingNum += item switch
|
||||
{
|
||||
BetterOptionHeaderItem => 0.1f,
|
||||
BetterOptionDividerItem => 0.15f,
|
||||
_ => 0f,
|
||||
};
|
||||
|
||||
item.obj.transform.SetLocalY(2f - 1f * SpacingNum);
|
||||
|
||||
SpacingNum += item switch
|
||||
{
|
||||
BetterOptionHeaderItem => 0.75f,
|
||||
BetterOptionTitleItem => 0.50f,
|
||||
_ => 0.45f,
|
||||
};
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
GameSettingMenuPatch.BetterSettingsTab.scrollBar.SetYBoundsMax(1.5f * SpacingNum / 2);
|
||||
GameSettingMenuPatch.BetterSettingsTab.scrollBar.ScrollRelative(new(0f, 0f));
|
||||
}
|
||||
|
||||
public void SetUp(OptionBehaviour optionBehaviour)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
using System.Dynamic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
public class BetterOptionPlayerItem : BetterOptionItem
|
||||
{
|
||||
private NumberOption? ThisOption;
|
||||
public int CurrentIndex = -1;
|
||||
|
||||
public override bool ShowChildrenCondition() => CurrentIndex > -1;
|
||||
public override bool SelfShowCondition() => ShowCondition != null ? ShowCondition() : base.SelfShowCondition();
|
||||
public Func<bool>? ShowCondition = null;
|
||||
|
||||
public BetterOptionItem Create(GameOptionsMenu gameOptionsMenu, string name, BetterOptionItem? Parent = null, Func<bool>? selfShowCondition = null)
|
||||
{
|
||||
Id = TempPlayerOptionDataNum + 1;
|
||||
Tab = gameOptionsMenu;
|
||||
Name = name;
|
||||
ShowCondition = selfShowCondition;
|
||||
|
||||
if (gameOptionsMenu == null)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
NumberOption optionBehaviour = UnityEngine.Object.Instantiate<NumberOption>(gameOptionsMenu.numberOptionOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f, -2f);
|
||||
SetUp(optionBehaviour);
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>((option) => ValueChanged(0, option));
|
||||
|
||||
// Fix Game Crash
|
||||
foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
{
|
||||
optionBehaviour.data = rulesCategory.AllGameSettings.ToArray().FirstOrDefault(item => item.Type == OptionTypes.Player);
|
||||
}
|
||||
|
||||
optionBehaviour.PlusBtn.OnClick.RemoveAllListeners();
|
||||
optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => Decrease()));
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => ValueChanged(Id, optionBehaviour)));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => ValueChanged(Id, optionBehaviour)));
|
||||
|
||||
optionBehaviour.LabelBackground.transform.localScale = new Vector3(1.6f, 0.78f);
|
||||
optionBehaviour.LabelBackground.transform.SetLocalX(-2.4f);
|
||||
optionBehaviour.TitleText.enableAutoSizing = false;
|
||||
optionBehaviour.TitleText.transform.SetLocalX(-1.5f);
|
||||
optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Right;
|
||||
optionBehaviour.TitleText.enableWordWrapping = false;
|
||||
optionBehaviour.TitleText.fontSize = 2.5f;
|
||||
|
||||
// Set data
|
||||
TitleText = optionBehaviour.TitleText;
|
||||
Option = optionBehaviour;
|
||||
ThisOption = optionBehaviour;
|
||||
|
||||
Load();
|
||||
BetterOptionItems.Add(this);
|
||||
obj = optionBehaviour.gameObject;
|
||||
|
||||
if (Parent != null)
|
||||
{
|
||||
int Index = 1;
|
||||
var tempParent = Parent;
|
||||
|
||||
while (tempParent.ThisParent != null)
|
||||
{
|
||||
tempParent = tempParent.ThisParent;
|
||||
Index++;
|
||||
}
|
||||
|
||||
optionBehaviour.LabelBackground.GetComponent<SpriteRenderer>().color -= new Color(0.25f, 0.25f, 0.25f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.localScale -= new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.position += new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.SetLocalZ(1f);
|
||||
ThisParent = Parent;
|
||||
IsChild = true;
|
||||
Parent.ChildrenList.Add(this);
|
||||
}
|
||||
|
||||
TempPlayerOptionDataNum++;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void AdjustButtonsActiveState()
|
||||
{
|
||||
if (ThisOption == null) return;
|
||||
|
||||
if (CurrentIndex >= 0)
|
||||
{
|
||||
ThisOption.ValueText.text = Utils.PlayerFromId(CurrentIndex).GetPlayerNameAndColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
ThisOption.ValueText.text = "<color=#ababab>Random</color>";
|
||||
}
|
||||
|
||||
if (CurrentIndex >= Main.AllPlayerControls.Length - 1)
|
||||
{
|
||||
ThisOption.PlusBtn.SetInteractable(false);
|
||||
ThisOption.MinusBtn.SetInteractable(true);
|
||||
}
|
||||
else if (CurrentIndex <= -1)
|
||||
{
|
||||
ThisOption.PlusBtn.SetInteractable(true);
|
||||
ThisOption.MinusBtn.SetInteractable(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ThisOption.PlusBtn.SetInteractable(true);
|
||||
ThisOption.MinusBtn.SetInteractable(true);
|
||||
}
|
||||
|
||||
TempPlayerOptionData[Id] = CurrentIndex;
|
||||
}
|
||||
|
||||
public void Increase()
|
||||
{
|
||||
if (CurrentIndex < Main.AllPlayerControls.Length)
|
||||
{
|
||||
CurrentIndex++;
|
||||
AdjustButtonsActiveState();
|
||||
}
|
||||
}
|
||||
|
||||
public void Decrease()
|
||||
{
|
||||
if (CurrentIndex > -1)
|
||||
{
|
||||
CurrentIndex--;
|
||||
AdjustButtonsActiveState();
|
||||
}
|
||||
}
|
||||
|
||||
public int Load()
|
||||
{
|
||||
if (TempPlayerOptionData.ContainsKey(Id))
|
||||
{
|
||||
var saveindex = TempPlayerOptionData[Id];
|
||||
|
||||
if (saveindex != -1 && Utils.PlayerFromId(saveindex) == null)
|
||||
saveindex = Main.AllPlayerControls.Length - 1;
|
||||
|
||||
CurrentIndex = saveindex;
|
||||
}
|
||||
else
|
||||
{
|
||||
TempPlayerOptionData[Id] = -1;
|
||||
CurrentIndex = TempPlayerOptionData[Id];
|
||||
}
|
||||
|
||||
AdjustButtonsActiveState();
|
||||
|
||||
return CurrentIndex;
|
||||
}
|
||||
|
||||
public override int GetValue()
|
||||
{
|
||||
if (SelfShowCondition())
|
||||
{
|
||||
return Load();
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(OptionBehaviour optionBehaviour)
|
||||
{
|
||||
optionBehaviour.data = new BaseGameSetting
|
||||
{
|
||||
Title = StringNames.None,
|
||||
Type = OptionTypes.Int,
|
||||
};
|
||||
}
|
||||
|
||||
public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
||||
{
|
||||
if (IsParent || IsChild)
|
||||
{
|
||||
bool Bool = ShowChildrenCondition();
|
||||
foreach (var item in ChildrenList)
|
||||
{
|
||||
item.obj.SetActive(Bool && item.SelfShowCondition());
|
||||
}
|
||||
UpdatePositions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,15 @@ namespace BetterAmongUs;
|
||||
|
||||
public class BetterOptionStringItem : BetterOptionItem
|
||||
{
|
||||
private StringOption? ThisOption;
|
||||
public string[] Values = [];
|
||||
public int CurrentValue;
|
||||
private StringOption? ThisOption;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, string[] strings, int DefaultValue = 0, BetterOptionItem Parent = null)
|
||||
public override bool ShowChildrenCondition() => CurrentValue > 0;
|
||||
public override bool SelfShowCondition() => ShowCondition != null ? ShowCondition() : base.SelfShowCondition();
|
||||
public Func<bool>? ShowCondition = null;
|
||||
|
||||
public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, string[] strings, int DefaultValue = 0, BetterOptionItem? Parent = null, Func<bool>? selfShowCondition = null)
|
||||
{
|
||||
Id = id;
|
||||
Values = strings;
|
||||
@@ -17,6 +21,7 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
if (DefaultValue < 0) DefaultValue = 0;
|
||||
if (DefaultValue > Values.Length) DefaultValue = Values.Length;
|
||||
CurrentValue = DefaultValue;
|
||||
ShowCondition = selfShowCondition;
|
||||
|
||||
if (gameOptionsMenu == null)
|
||||
{
|
||||
@@ -25,10 +30,9 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
}
|
||||
|
||||
StringOption optionBehaviour = UnityEngine.Object.Instantiate<StringOption>(gameOptionsMenu.stringOptionOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f, -2f);
|
||||
SetUp(optionBehaviour);
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>((option) => ValueChanged(id, option));
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
// Fix Game Crash
|
||||
foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
@@ -40,6 +44,16 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => Decrease()));
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => ValueChanged(id, optionBehaviour)));
|
||||
optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => ValueChanged(id, optionBehaviour)));
|
||||
|
||||
optionBehaviour.LabelBackground.transform.localScale = new Vector3(1.6f, 0.78f);
|
||||
optionBehaviour.LabelBackground.transform.SetLocalX(-2.4f);
|
||||
optionBehaviour.TitleText.enableAutoSizing = false;
|
||||
optionBehaviour.TitleText.transform.SetLocalX(-1.5f);
|
||||
optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Right;
|
||||
optionBehaviour.TitleText.enableWordWrapping = false;
|
||||
optionBehaviour.TitleText.fontSize = 2.5f;
|
||||
|
||||
// Set data
|
||||
TitleText = optionBehaviour.TitleText;
|
||||
@@ -50,6 +64,28 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
AdjustButtonsActiveState();
|
||||
|
||||
BetterOptionItems.Add(this);
|
||||
obj = optionBehaviour.gameObject;
|
||||
|
||||
if (Parent != null)
|
||||
{
|
||||
int Index = 1;
|
||||
var tempParent = Parent;
|
||||
|
||||
while (tempParent.ThisParent != null)
|
||||
{
|
||||
tempParent = tempParent.ThisParent;
|
||||
Index++;
|
||||
}
|
||||
|
||||
optionBehaviour.LabelBackground.GetComponent<SpriteRenderer>().color -= new Color(0.25f, 0.25f, 0.25f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.localScale -= new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.position += new Vector3(0.04f, 0f, 0f) * Index;
|
||||
optionBehaviour.LabelBackground.transform.SetLocalZ(1f);
|
||||
ThisParent = Parent;
|
||||
IsChild = true;
|
||||
Parent.ChildrenList.Add(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -103,7 +139,7 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
{
|
||||
if (BetterDataManager.CanLoadSetting(Id))
|
||||
{
|
||||
var Int = BetterDataManager.LoadIntSetting(Id);
|
||||
var Int = BetterDataManager.LoadIntSetting(Id, DefaultValue);
|
||||
|
||||
if (Int > Values.Length - 1 || Int < 0)
|
||||
{
|
||||
@@ -142,5 +178,14 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
|
||||
public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
||||
{
|
||||
if (IsParent || IsChild)
|
||||
{
|
||||
bool Bool = ShowChildrenCondition();
|
||||
foreach (var item in ChildrenList)
|
||||
{
|
||||
item.obj.SetActive(Bool && item.SelfShowCondition());
|
||||
}
|
||||
UpdatePositions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,11 @@ public class BetterOptionDividerItem : BetterOptionItem
|
||||
return this;
|
||||
}
|
||||
|
||||
SpacingNum += 0.15f;
|
||||
|
||||
Tab = gameOptionsMenu;
|
||||
Name = "Divider";
|
||||
CategoryHeaderMasked categoryHeaderMasked = UnityEngine.Object.Instantiate<CategoryHeaderMasked>(gameOptionsMenu.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, 2f - StaticSpacingNum * SpacingNum, -2f);
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, 2f, -2f);
|
||||
UnityEngine.Object.Destroy(categoryHeaderMasked.Background.gameObject);
|
||||
UnityEngine.Object.Destroy(categoryHeaderMasked.Title.gameObject);
|
||||
if (categoryHeaderMasked.Divider != null)
|
||||
@@ -25,7 +23,8 @@ public class BetterOptionDividerItem : BetterOptionItem
|
||||
categoryHeaderMasked.Divider.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
|
||||
}
|
||||
|
||||
SpacingNum += 0.45f;
|
||||
BetterOptionItems.Add(this);
|
||||
obj = categoryHeaderMasked.gameObject;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@ public class BetterOptionHeaderItem : BetterOptionItem
|
||||
return this;
|
||||
}
|
||||
|
||||
SpacingNum += 0.1f;
|
||||
|
||||
Tab = gameOptionsMenu;
|
||||
Name = name;
|
||||
CategoryHeaderMasked categoryHeaderMasked = UnityEngine.Object.Instantiate<CategoryHeaderMasked>(gameOptionsMenu.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, 2f - StaticSpacingNum * SpacingNum, -2f);
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, 2f, -2f);
|
||||
categoryHeaderMasked.Title.text = name;
|
||||
categoryHeaderMasked.Background.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
|
||||
if (categoryHeaderMasked.Divider != null)
|
||||
@@ -27,7 +25,8 @@ public class BetterOptionHeaderItem : BetterOptionItem
|
||||
categoryHeaderMasked.Title.fontMaterial.SetFloat("_StencilComp", 3f);
|
||||
categoryHeaderMasked.Title.fontMaterial.SetFloat("_Stencil", maskLayer);
|
||||
|
||||
SpacingNum += 0.75f;
|
||||
BetterOptionItems.Add(this);
|
||||
obj = categoryHeaderMasked.gameObject;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,8 @@ public class BetterOptionTitleItem : BetterOptionItem
|
||||
}
|
||||
|
||||
ToggleOption optionBehaviour = UnityEngine.Object.Instantiate<ToggleOption>(gameOptionsMenu.checkboxOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
|
||||
optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f, -2f);
|
||||
SetUp(optionBehaviour);
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
UnityEngine.Object.Destroy(optionBehaviour.CheckMark.transform.parent.gameObject);
|
||||
UnityEngine.Object.Destroy(optionBehaviour.GetComponent<ToggleOption>());
|
||||
@@ -25,6 +24,14 @@ public class BetterOptionTitleItem : BetterOptionItem
|
||||
optionBehaviour.LabelBackground.color = new Color(0.6f, 0.6f, 0.6f, 1f);
|
||||
optionBehaviour.LabelBackground.transform.SetLocalZ(1f);
|
||||
|
||||
optionBehaviour.LabelBackground.transform.localScale = new Vector3(1.6f, 1f);
|
||||
optionBehaviour.LabelBackground.transform.SetLocalX(-2.4f);
|
||||
optionBehaviour.TitleText.enableAutoSizing = false;
|
||||
optionBehaviour.TitleText.transform.SetLocalX(-2.4f);
|
||||
optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Center;
|
||||
optionBehaviour.TitleText.enableWordWrapping = false;
|
||||
optionBehaviour.TitleText.fontSize = 2.5f;
|
||||
|
||||
// Set data
|
||||
Tab = gameOptionsMenu;
|
||||
Name = $"<b><size=150%>{name}</size></b>";
|
||||
@@ -32,6 +39,8 @@ public class BetterOptionTitleItem : BetterOptionItem
|
||||
TitleText = optionBehaviour.TitleText;
|
||||
|
||||
BetterOptionItems.Add(this);
|
||||
obj = optionBehaviour.gameObject;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+18
-45
@@ -92,6 +92,22 @@ public static class MessageReaderUpdateSystemPatch
|
||||
|
||||
internal static class RPC
|
||||
{
|
||||
public static void RpcSyncSettings()
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var player in Main.AllPlayerControls.Where(pc => pc != PlayerControl.LocalPlayer))
|
||||
{
|
||||
var optionsByteArray = GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions, false);
|
||||
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SyncSettings, SendOption.None, player.GetClientId());
|
||||
messageWriter.WriteBytesAndSize(optionsByteArray);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendBetterCheck()
|
||||
{
|
||||
var flag = GameStates.IsHost && Main.BetterHost.Value;
|
||||
@@ -133,51 +149,6 @@ internal static class RPC
|
||||
player.Exiled();
|
||||
}
|
||||
|
||||
public static void SendHostChatToPlayer(PlayerControl player, string text, string? title = "", bool sendToBetterUser = true)
|
||||
{
|
||||
if (!GameStates.IsHost) return;
|
||||
|
||||
if (player.BetterData().IsBetterUser)
|
||||
{
|
||||
if (sendToBetterUser)
|
||||
{
|
||||
MessageWriter messageWriter2 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, unchecked((byte)CustomRPC.AddChat), SendOption.None, player.GetClientId());
|
||||
messageWriter2.Write(text);
|
||||
messageWriter2.Write(title);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(messageWriter2);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
PlayerControl asPlayer = Main.AllPlayerControls.Where(pc => pc.IsAlive()).OrderBy(pc => pc == PlayerControl.LocalPlayer ? 0 : 1).First();
|
||||
|
||||
var oldName = asPlayer.CurrentOutfit.PlayerName;
|
||||
if (title == "")
|
||||
title = oldName;
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(asPlayer.NetId, (byte)RpcCalls.SetName, SendOption.None, player.GetClientId());
|
||||
writer.Write(asPlayer.Data.NetId);
|
||||
writer.Write(title);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
|
||||
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(asPlayer.NetId, (byte)RpcCalls.SendChat, SendOption.None, player.GetClientId());
|
||||
messageWriter.Write(text);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
|
||||
|
||||
_ = new LateTask(() =>
|
||||
{
|
||||
MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(asPlayer.NetId, (byte)RpcCalls.SetName, SendOption.None, player.GetClientId());
|
||||
writer2.Write(asPlayer.Data.NetId);
|
||||
writer2.Write(oldName);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer2);
|
||||
|
||||
SyncAllNames(force: true);
|
||||
}, 0.08f, shoudLog: false);
|
||||
*/
|
||||
}
|
||||
|
||||
public static void HandleCustomRPC(PlayerControl player, byte callId, MessageReader oldReader)
|
||||
{
|
||||
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.Data == null) return;
|
||||
@@ -201,6 +172,8 @@ internal static class RPC
|
||||
|
||||
player.BetterData().IsBetterUser = SetBetterUser;
|
||||
player.BetterData().IsBetterHost = IsBetterHost;
|
||||
|
||||
SyncAllNames(force: true);
|
||||
}
|
||||
break;
|
||||
case (byte)CustomRPC.AddChat:
|
||||
|
||||
@@ -289,4 +289,64 @@ public static class Utils
|
||||
|
||||
return $"{Tag}: {PlatformName}";
|
||||
}
|
||||
|
||||
public static string GetPlatformName(Platforms platform, bool useTag = false)
|
||||
{
|
||||
string Tag = string.Empty;
|
||||
|
||||
string PlatformName;
|
||||
switch (platform)
|
||||
{
|
||||
case Platforms.StandaloneSteamPC:
|
||||
PlatformName = "Steam";
|
||||
Tag = "PC";
|
||||
break;
|
||||
case Platforms.StandaloneEpicPC:
|
||||
PlatformName = "Epic Games";
|
||||
Tag = "PC";
|
||||
break;
|
||||
case Platforms.StandaloneWin10:
|
||||
PlatformName = "Microsoft Store";
|
||||
Tag = "PC";
|
||||
break;
|
||||
case Platforms.StandaloneMac:
|
||||
PlatformName = "Mac OS";
|
||||
Tag = "PC";
|
||||
break;
|
||||
case Platforms.StandaloneItch:
|
||||
PlatformName = "Itch.io";
|
||||
Tag = "PC";
|
||||
break;
|
||||
case Platforms.Xbox:
|
||||
PlatformName = "Xbox";
|
||||
Tag = "Console";
|
||||
break;
|
||||
case Platforms.Playstation:
|
||||
PlatformName = "Playstation";
|
||||
Tag = "Console";
|
||||
break;
|
||||
case Platforms.Switch:
|
||||
PlatformName = "Switch";
|
||||
Tag = "Console";
|
||||
break;
|
||||
case Platforms.Android:
|
||||
PlatformName = "Android";
|
||||
Tag = "Mobile";
|
||||
break;
|
||||
case Platforms.IPhone:
|
||||
PlatformName = "IPhone";
|
||||
Tag = "Mobile";
|
||||
break;
|
||||
case Platforms.Unknown:
|
||||
PlatformName = "None";
|
||||
break;
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (useTag == false)
|
||||
return PlatformName;
|
||||
|
||||
return $"{Tag}: {PlatformName}";
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,9 @@ class ChatPatch
|
||||
ChatBubble pooledBubble = __instance.GetPooledBubble();
|
||||
try
|
||||
{
|
||||
chatText = chatText.Replace("\n", "");
|
||||
if (sourcePlayer.BetterData().IsBetterUser && GameStates.IsBetterHostLobby)
|
||||
chatText = chatText.Replace("\n", "");
|
||||
|
||||
pooledBubble.transform.SetParent(__instance.scroller.Inner);
|
||||
pooledBubble.transform.localScale = Vector3.one;
|
||||
bool flag = sourcePlayer == PlayerControl.LocalPlayer;
|
||||
@@ -173,9 +175,10 @@ class ChatPatch
|
||||
if (sourcePlayer.IsDev())
|
||||
sbTag.Append("<color=#0088ff>Dev</color>+++");
|
||||
|
||||
if (((sourcePlayer == PlayerControl.LocalPlayer && GameStates.IsHost && Main.BetterHost.Value) || sourcePlayer.BetterData().IsBetterHost) && !GameStates.IsInGamePlay)
|
||||
if (((sourcePlayer == PlayerControl.LocalPlayer && GameStates.IsHost && Main.BetterHost.Value)
|
||||
|| (sourcePlayer != PlayerControl.LocalPlayer && sourcePlayer.BetterData().IsBetterHost && sourcePlayer.IsHost())))
|
||||
sbTag.Append("<color=#0dff00>Better Host</color>+++");
|
||||
else if ((sourcePlayer == PlayerControl.LocalPlayer || sourcePlayer.BetterData().IsBetterUser) && !GameStates.IsInGamePlay)
|
||||
else if ((sourcePlayer == PlayerControl.LocalPlayer || sourcePlayer.BetterData().IsBetterUser))
|
||||
sbTag.Append("<color=#0dff00>Better User</color>+++");
|
||||
|
||||
if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.SickoData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.SickoData.ContainsValue(friendCode))
|
||||
|
||||
@@ -10,7 +10,6 @@ public static class OptionsMenuBehaviourPatch
|
||||
{
|
||||
private static ClientOptionItem AntiCheat;
|
||||
private static ClientOptionItem BetterHost;
|
||||
private static ClientOptionItem BetterRoleAlgorithma;
|
||||
private static ClientOptionItem BetterNotifications;
|
||||
private static ClientOptionItem ChatInGameplay;
|
||||
private static ClientOptionItem LobbyPlayerInfo;
|
||||
@@ -63,11 +62,6 @@ public static class OptionsMenuBehaviourPatch
|
||||
}
|
||||
}
|
||||
|
||||
if (BetterRoleAlgorithma == null || BetterRoleAlgorithma.ToggleButton == null)
|
||||
{
|
||||
BetterRoleAlgorithma = ClientOptionItem.Create("<color=#4f92ff>Better Role Algorithma</color>", Main.BetterRoleAlgorithma, __instance, toggleCheck: () => !toggleCheckInGamePlay("<color=#4f92ff>Better Role Algorithma</color>"));
|
||||
}
|
||||
|
||||
if (BetterNotifications == null || BetterNotifications.ToggleButton == null)
|
||||
{
|
||||
BetterNotifications = ClientOptionItem.Create("<color=#4f92ff>Better Notifications</color>", Main.BetterNotifications, __instance, BetterNotificationsToggle);
|
||||
|
||||
@@ -246,8 +246,9 @@ class CommandsPatch
|
||||
{
|
||||
foreach (PlayerControl player in Main.AllPlayerControls)
|
||||
{
|
||||
player.RpcExile();
|
||||
player.roleAssigned = false;
|
||||
player.RpcSetRole(RoleTypes.Crewmate, true);
|
||||
player.RpcSetRole(RoleTypes.CrewmateGhost, true);
|
||||
}
|
||||
GameManager.Instance.RpcEndGame(GameOverReason.ImpostorByKill, false);
|
||||
return;
|
||||
@@ -302,11 +303,6 @@ class CommandsPatch
|
||||
case "role" or "setrole":
|
||||
if (HandleIsHost(command) == true)
|
||||
{
|
||||
if (!Main.BetterRoleAlgorithma.Value)
|
||||
{
|
||||
Utils.AddChatPrivate($"<color=#730000>{error}\nBetter Role Algorithma in better options must be turned on to use this command");
|
||||
return;
|
||||
}
|
||||
if (command[0][1..].ToLower().Trim() == "role")
|
||||
{
|
||||
var player = PlayerControl.LocalPlayer;
|
||||
|
||||
@@ -61,6 +61,13 @@ class GamePlayManager
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(LobbyBehaviour.RpcExtendLobbyTimer))]
|
||||
[HarmonyPostfix]
|
||||
private static void RpcExtendLobbyTimer_Postfix(/*LobbyBehaviour __instance*/)
|
||||
{
|
||||
GameStartManagerPatch.lobbyTimer += 30f;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(IntroCutscene))]
|
||||
@@ -124,10 +131,23 @@ class GamePlayManager
|
||||
[HarmonyPatch(typeof(GameStartManager))]
|
||||
public class GameStartManagerPatch
|
||||
{
|
||||
public static float lobbyTimer = 600f;
|
||||
public static string lobbyTimerDisplay = "";
|
||||
[HarmonyPatch(nameof(GameStartManager.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start_Postfix(/*GameStartManager __instance*/)
|
||||
{
|
||||
lobbyTimer = 600f;
|
||||
}
|
||||
[HarmonyPatch(nameof(GameStartManager.Update))]
|
||||
[HarmonyPrefix]
|
||||
private static void Update_Prefix(GameStartManager __instance)
|
||||
{
|
||||
lobbyTimer = Mathf.Max(0f, lobbyTimer -= Time.deltaTime);
|
||||
int minutes = (int)lobbyTimer / 60;
|
||||
int seconds = (int)lobbyTimer % 60;
|
||||
lobbyTimerDisplay = $"{minutes:00}:{seconds:00}";
|
||||
|
||||
__instance.MinPlayers = 1;
|
||||
}
|
||||
[HarmonyPatch(nameof(GameStartManager.Update))]
|
||||
|
||||
@@ -16,10 +16,20 @@ class BetterGameSettings
|
||||
public static BetterOptionItem? DetectedLevelAbove;
|
||||
public static BetterOptionItem? DetectCheatClients;
|
||||
public static BetterOptionItem? DetectInvalidRPCs;
|
||||
public static BetterOptionItem? RoleRandomizer;
|
||||
public static BetterOptionItem? DesyncRoles;
|
||||
|
||||
public static BetterOptionItem? ExperimentalDetectInvalidSabotage;
|
||||
}
|
||||
|
||||
class BetterGameSettingsTemp
|
||||
{
|
||||
public static BetterOptionItem? HideAndSeekImp2;
|
||||
public static BetterOptionItem? HideAndSeekImp3;
|
||||
public static BetterOptionItem? HideAndSeekImp4;
|
||||
public static BetterOptionItem? HideAndSeekImp5;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameSettingMenu))]
|
||||
static class GameSettingMenuPatch
|
||||
{
|
||||
@@ -29,8 +39,8 @@ static class GameSettingMenuPatch
|
||||
|
||||
public static void SetupSettings(bool IsPreload = false)
|
||||
{
|
||||
BetterOptionItem.SpacingNum = 0;
|
||||
BetterOptionItem.BetterOptionItems.Clear();
|
||||
BetterOptionItem.TempPlayerOptionDataNum = 0;
|
||||
TitleList.Clear();
|
||||
|
||||
// Anti-Cheat Settings
|
||||
@@ -40,8 +50,8 @@ static class GameSettingMenuPatch
|
||||
if (IsPreload || GameStates.IsHost)
|
||||
{
|
||||
TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Host Only</color>"));
|
||||
BetterGameSettings.WhenCheating = new BetterOptionStringItem().Create(100, BetterSettingsTab, "When a player is caught cheating", ["Do Nothing", "Kick", "Ban"], 2);
|
||||
BetterGameSettings.InvalidFriendCode = new BetterOptionCheckboxItem().Create(200, BetterSettingsTab, "Allow invalid friendCodes", true);
|
||||
BetterGameSettings.WhenCheating = new BetterOptionStringItem().Create(100, BetterSettingsTab, "When a player is caught cheating", ["Notify", "Kick", "Ban"], 2);
|
||||
BetterGameSettings.InvalidFriendCode = new BetterOptionCheckboxItem().Create(200, BetterSettingsTab, "Detected invalid FriendCodes", true);
|
||||
BetterGameSettings.UseBanPlayerList = new BetterOptionCheckboxItem().Create(300, BetterSettingsTab, "Use Ban Player List", true);
|
||||
BetterGameSettings.UseBanNameList = new BetterOptionCheckboxItem().Create(400, BetterSettingsTab, "Use Ban Name List", true);
|
||||
BetterGameSettings.UseBanWordList = new BetterOptionCheckboxItem().Create(500, BetterSettingsTab, "Use Ban Word List", true);
|
||||
@@ -49,7 +59,7 @@ static class GameSettingMenuPatch
|
||||
}
|
||||
|
||||
TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Detections</color>"));
|
||||
BetterGameSettings.DetectedLevelAbove = new BetterOptionIntItem().Create(600, BetterSettingsTab, "Detected player level = or >", [100, 5000, 5], 200, "Lv ", "");
|
||||
BetterGameSettings.DetectedLevelAbove = new BetterOptionIntItem().Create(600, BetterSettingsTab, "Detected player levels >", [100, 5000, 5], 200, "Lv ", "");
|
||||
BetterGameSettings.DetectCheatClients = new BetterOptionCheckboxItem().Create(700, BetterSettingsTab, "Detect Cheat Clients", true);
|
||||
BetterGameSettings.DetectInvalidRPCs = new BetterOptionCheckboxItem().Create(800, BetterSettingsTab, "Detect Invalid RPCs", true);
|
||||
|
||||
@@ -58,6 +68,13 @@ static class GameSettingMenuPatch
|
||||
BetterGameSettings.ExperimentalDetectInvalidSabotage = new BetterOptionCheckboxItem().Create(100000, BetterSettingsTab, "Detect Invalid Sabotages", false);
|
||||
}
|
||||
|
||||
if (IsPreload || GameStates.IsHost)
|
||||
{
|
||||
TitleList.Add(new BetterOptionHeaderItem().Create(BetterSettingsTab, "<color=#4f92ff>Role Algorithm Settings</color>"));
|
||||
BetterGameSettings.RoleRandomizer = new BetterOptionStringItem().Create(1100, BetterSettingsTab, "Randomizer", ["System.Random", "UnityEngine.Random"], 0);
|
||||
BetterGameSettings.DesyncRoles = new BetterOptionCheckboxItem().Create(1200, BetterSettingsTab, "Desync Roles To Other Clients", true);
|
||||
}
|
||||
|
||||
// Gameplay Settings
|
||||
{
|
||||
if (IsPreload || GameStates.IsHost)
|
||||
@@ -69,28 +86,41 @@ static class GameSettingMenuPatch
|
||||
else if (IsPreload || GameStates.IsHideNSeek)
|
||||
{
|
||||
new BetterOptionHeaderItem().Create(BetterSettingsTab, "<color=#d7d700>Hide & Seek Settings</color>");
|
||||
|
||||
if (IsPreload || Main.BetterRoleAlgorithma.Value)
|
||||
new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color={Utils.GetRoleColor(RoleTypes.Impostor)}>Imposter</color>");
|
||||
BetterGameSettings.HideAndSeekImpNum = new BetterOptionIntItem().Create(1000, BetterSettingsTab, "# Seekers", [1, 5, 1], 1, "", "");
|
||||
BetterGameSettingsTemp.HideAndSeekImp2 = new BetterOptionPlayerItem().Create(BetterSettingsTab, "Seeker", BetterGameSettings.HideAndSeekImpNum, new Func<bool>(() =>
|
||||
{
|
||||
new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Better Role Algorithma</color>");
|
||||
BetterOptionItem.SpacingNum += 0.2f;
|
||||
new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color={Utils.GetRoleColor(RoleTypes.Impostor)}>Imposter</color>");
|
||||
BetterGameSettings.HideAndSeekImpNum = new BetterOptionIntItem().Create(1000, BetterSettingsTab, "# Seekers", [1, 5, 1], 1, "", "");
|
||||
}
|
||||
return BetterGameSettings.HideAndSeekImpNum is BetterOptionIntItem betterOption && betterOption.CurrentValue > 1;
|
||||
}));
|
||||
BetterGameSettingsTemp.HideAndSeekImp3 = new BetterOptionPlayerItem().Create(BetterSettingsTab, "Seeker", BetterGameSettings.HideAndSeekImpNum, new Func<bool>(() =>
|
||||
{
|
||||
return BetterGameSettings.HideAndSeekImpNum is BetterOptionIntItem betterOption && betterOption.CurrentValue > 2
|
||||
&& BetterGameSettingsTemp.HideAndSeekImp2 is BetterOptionPlayerItem betterOption2 && betterOption2.CurrentIndex > -1;
|
||||
}));
|
||||
BetterGameSettingsTemp.HideAndSeekImp4 = new BetterOptionPlayerItem().Create(BetterSettingsTab, "Seeker", BetterGameSettings.HideAndSeekImpNum, new Func<bool>(() =>
|
||||
{
|
||||
return BetterGameSettings.HideAndSeekImpNum is BetterOptionIntItem betterOption && betterOption.CurrentValue > 3
|
||||
&& BetterGameSettingsTemp.HideAndSeekImp2 is BetterOptionPlayerItem betterOption2 && betterOption2.CurrentIndex > -1
|
||||
&& BetterGameSettingsTemp.HideAndSeekImp3 is BetterOptionPlayerItem betterOption3 && betterOption3.CurrentIndex > -1;
|
||||
}));
|
||||
BetterGameSettingsTemp.HideAndSeekImp5 = new BetterOptionPlayerItem().Create(BetterSettingsTab, "Seeker", BetterGameSettings.HideAndSeekImpNum, new Func<bool>(() =>
|
||||
{
|
||||
return BetterGameSettings.HideAndSeekImpNum is BetterOptionIntItem betterOption && betterOption.CurrentValue > 4
|
||||
&& BetterGameSettingsTemp.HideAndSeekImp2 is BetterOptionPlayerItem betterOption2 && betterOption2.CurrentIndex > -1
|
||||
&& BetterGameSettingsTemp.HideAndSeekImp3 is BetterOptionPlayerItem betterOption3 && betterOption3.CurrentIndex > -1
|
||||
&& BetterGameSettingsTemp.HideAndSeekImp4 is BetterOptionPlayerItem betterOption4 && betterOption4.CurrentIndex > -1;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
new BetterOptionCheckboxItem().Create(0, BetterSettingsTab, "CheckBox Test", true);
|
||||
new BetterOptionStringItem().Create(1, BetterSettingsTab, "String Test", ["Test 1", "Test 2", "Test 3"]);
|
||||
new BetterOptionFloatItem().Create(2, BetterSettingsTab, "Float Test 1", [0f, 180f, 2.5f], 0f, "");
|
||||
new BetterOptionIntItem().Create(5, BetterSettingsTab, "Int Test", [0, 5, 1], 0, "");
|
||||
new BetterOptionCheckboxItem().Create(10000, BetterSettingsTab, "CheckBox Test", true);
|
||||
new BetterOptionStringItem().Create(10001, BetterSettingsTab, "String Test", ["Test 1", "Test 2", "Test 3"], 0);
|
||||
new BetterOptionFloatItem().Create(10002, BetterSettingsTab, "Float Test 1", [0f, 180f, 2.5f], 0f, "", "");
|
||||
new BetterOptionIntItem().Create(10003, BetterSettingsTab, "Int Test", [0, 5, 1], 0, "", "");
|
||||
new BetterOptionHeaderItem().Create(BetterSettingsTab, "<color=#4f92ff>Test Settings 2</color>");
|
||||
*/
|
||||
|
||||
if (BetterSettingsTab != null)
|
||||
BetterSettingsTab.scrollBar.SetYBoundsMax(1.25f * BetterOptionItem.SpacingNum / 2);
|
||||
}
|
||||
|
||||
private static void Initialize()
|
||||
@@ -101,12 +131,16 @@ static class GameSettingMenuPatch
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
item.obj.SetActive(true);
|
||||
|
||||
if (item.TitleText != null)
|
||||
{
|
||||
item.TitleText.text = item.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BetterOptionItem.UpdatePositions();
|
||||
}, 0.005f, shoudLog: false);
|
||||
}
|
||||
|
||||
@@ -159,6 +193,7 @@ static class GameSettingMenuPatch
|
||||
BetterSettingsButton.OnClick.AddListener(new Action(() =>
|
||||
{
|
||||
__instance.ChangeTab(3, false);
|
||||
BetterOptionItem.UpdatePositions();
|
||||
}));
|
||||
|
||||
BetterSettingsTab = UnityEngine.Object.Instantiate(__instance.GameSettingsTab, __instance.GameSettingsTab.transform.parent);
|
||||
@@ -275,8 +310,17 @@ static class NumberOptionPatch
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
times = 10;
|
||||
|
||||
__instance.Value += __instance.Increment * times;
|
||||
if (__instance.Value + __instance.Increment * times > __instance.ValidRange.max)
|
||||
{
|
||||
__instance.Value = __instance.ValidRange.max;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.Value = __instance.ValidRange.Clamp(__instance.Value + __instance.Increment * times);
|
||||
}
|
||||
__instance.UpdateValue();
|
||||
__instance.OnValueChanged.Invoke(__instance);
|
||||
__instance.AdjustButtonsActiveState();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -290,56 +334,17 @@ static class NumberOptionPatch
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
times = 10;
|
||||
|
||||
__instance.Value -= __instance.Increment * times;
|
||||
if (__instance.Value - __instance.Increment * times < __instance.ValidRange.min)
|
||||
{
|
||||
__instance.Value = __instance.ValidRange.min;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.Value = __instance.ValidRange.Clamp(__instance.Value - __instance.Increment * times);
|
||||
}
|
||||
__instance.UpdateValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(NumberOption.UpdateValue))]
|
||||
[HarmonyPrefix]
|
||||
public static bool UpdateValue_Prefix(NumberOption __instance)
|
||||
{
|
||||
if (__instance.floatOptionName != FloatOptionNames.Invalid)
|
||||
{
|
||||
GameOptionsManager.Instance.CurrentGameOptions.SetFloat(__instance.floatOptionName, __instance.GetFloat());
|
||||
return false;
|
||||
}
|
||||
if (__instance.intOptionName != Int32OptionNames.Invalid)
|
||||
{
|
||||
GameOptionsManager.Instance.CurrentGameOptions.SetInt(__instance.intOptionName, __instance.GetInt());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(NumberOption.FixedUpdate))]
|
||||
[HarmonyPrefix]
|
||||
public static bool FixedUpdate_Prefix(NumberOption __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (__instance.MinusBtn != null && __instance.PlusBtn != null)
|
||||
{
|
||||
__instance.MinusBtn.SetInteractable(true);
|
||||
__instance.PlusBtn.SetInteractable(true);
|
||||
}
|
||||
|
||||
if (__instance.oldValue != __instance.Value)
|
||||
{
|
||||
__instance.oldValue = __instance.Value;
|
||||
|
||||
if (__instance.Value > __instance.ValidRange.max || __instance.Value < __instance.ValidRange.min)
|
||||
{
|
||||
__instance.ValueText.text = $"<color=#f20>{__instance.data.GetValueString(__instance.Value)}</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.ValueText.text = __instance.data.GetValueString(__instance.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
__instance.OnValueChanged.Invoke(__instance);
|
||||
__instance.AdjustButtonsActiveState();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using InnerNet;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
[HarmonyPatch(typeof(MatchMakerGameButton))]
|
||||
class MatchMakerGameButtonPatch
|
||||
{
|
||||
[HarmonyPatch(nameof(MatchMakerGameButton.SetGame))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetGame_Postfix(MatchMakerGameButton __instance)
|
||||
{
|
||||
__instance.NameText.text = $"<b><color=#f4f400>{__instance.myListing.HostName}</color></b>\n";
|
||||
__instance.NameText.text += $"<size=65%><voffset=0.4m><color=#9c9c9c>{Utils.GetPlatformName(__instance.myListing.Platform)} - {GameCode.IntToGameName(__instance.myListing.GameId)}</color></voffset></size>";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using HarmonyLib;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using static BetterAmongUs.Patches.GamePlayManager;
|
||||
|
||||
namespace BetterAmongUs.Patches;
|
||||
|
||||
@@ -23,6 +24,12 @@ public class PingTrackerPatch
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendFormat("PING: <b>{0}</b>\n", GetPingColor(AmongUsClient.Instance.Ping));
|
||||
|
||||
if (GameStates.IsLobby && GameStates.IsHost && GameStates.IsVanillaServer && !GameStates.IsLocalGame)
|
||||
{
|
||||
sb.AppendFormat("Timer: <b>{0}</b>\n", GetTimeColor(GameStartManagerPatch.lobbyTimer));
|
||||
}
|
||||
|
||||
sb.Append($"<color=#00dbdb><size=75%>BetterAmongUs {Main.GetVersionText(true)}</size></color>\n");
|
||||
sb.AppendFormat("<color=#b0b0b0><size=50%>{0}</size></color>\n", Main.Github);
|
||||
|
||||
@@ -76,4 +83,30 @@ public class PingTrackerPatch
|
||||
|
||||
return newPing;
|
||||
}
|
||||
|
||||
private static string GetTimeColor(float time)
|
||||
{
|
||||
float minutes = (int)time / 60 + 1f;
|
||||
|
||||
string color;
|
||||
switch (minutes)
|
||||
{
|
||||
case float n when n <= 1:
|
||||
color = "#ff0000";
|
||||
break;
|
||||
case float n when n <= 3.5f:
|
||||
color = "#ffa200";
|
||||
break;
|
||||
case float n when n <= 5f:
|
||||
color = "#ffff00";
|
||||
break;
|
||||
default:
|
||||
color = "#00f04c";
|
||||
break;
|
||||
}
|
||||
|
||||
string newTime = $"<color={color}>{GameStartManagerPatch.lobbyTimerDisplay}</color>";
|
||||
|
||||
return newTime;
|
||||
}
|
||||
}
|
||||
@@ -128,11 +128,8 @@ class PlayerControlPatch
|
||||
}
|
||||
|
||||
var sbTag = new StringBuilder();
|
||||
var sbInfo = new StringBuilder();
|
||||
var sbTagTop = new StringBuilder();
|
||||
var sbInfoTop = new StringBuilder();
|
||||
var sbTagBottom = new StringBuilder();
|
||||
var sbInfoBottom = new StringBuilder();
|
||||
|
||||
// Put +++ at the end of each tag
|
||||
if (!player.isDummy)
|
||||
@@ -182,6 +179,20 @@ class PlayerControlPatch
|
||||
sbTagTop.Append($"{Role}+++");
|
||||
}
|
||||
}
|
||||
else if (GameStates.IsInGame || GameStates.IsFreePlay)
|
||||
{
|
||||
if (player == PlayerControl.LocalPlayer)
|
||||
{
|
||||
if (player.IsImpostorTeam())
|
||||
{
|
||||
sbTagTop.Append($"<color={Utils.GetTeamHexColor(RoleTeamTypes.Impostor)}>Seeker</color>+++");
|
||||
}
|
||||
else
|
||||
{
|
||||
sbTagTop.Append($"<color={Utils.GetTeamHexColor(RoleTeamTypes.Crewmate)}>Hider</color>+++");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player.IsImpostorTeammate() && player != PlayerControl.LocalPlayer)
|
||||
{
|
||||
@@ -194,8 +205,9 @@ class PlayerControlPatch
|
||||
}
|
||||
|
||||
// Put +++ at the end of each tag
|
||||
void AppendTagInfo(StringBuilder source, StringBuilder destination)
|
||||
static StringBuilder FormatInfo(StringBuilder source)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (source.Length > 0)
|
||||
{
|
||||
string text = source.ToString();
|
||||
@@ -204,23 +216,25 @@ class PlayerControlPatch
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Utils.RemoveHtmlText(parts[i])))
|
||||
{
|
||||
destination.Append(parts[i]);
|
||||
sb.Append(parts[i]);
|
||||
if (i != parts.Length - 2)
|
||||
{
|
||||
destination.Append(" - ");
|
||||
sb.Append(" - ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
AppendTagInfo(sbTag, sbInfo);
|
||||
AppendTagInfo(sbTagTop, sbInfoTop);
|
||||
AppendTagInfo(sbTagBottom, sbInfoBottom);
|
||||
sbTag = FormatInfo(sbTag);
|
||||
sbTagTop = FormatInfo(sbTagTop);
|
||||
sbTagBottom = FormatInfo(sbTagBottom);
|
||||
|
||||
player.SetPlayerTextInfo(sbInfoTop.ToString());
|
||||
player.SetPlayerTextInfo(sbInfoBottom.ToString(), isBottom: true);
|
||||
player.SetPlayerTextInfo(sbInfo.ToString(), isInfo: true);
|
||||
player.SetPlayerTextInfo(sbTagTop.ToString());
|
||||
player.SetPlayerTextInfo(sbTagBottom.ToString(), isBottom: true);
|
||||
player.SetPlayerTextInfo(sbTag.ToString(), isInfo: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -52,9 +52,6 @@ public static class OnPlayerJoinedPatch
|
||||
|
||||
RPC.SyncAllNames(force: true);
|
||||
|
||||
if (Main.BetterHost.Value)
|
||||
client.Character.RpcSendHostChat(HudManagerPatch.WelcomeMessage, sendToBetterUser: false);
|
||||
|
||||
// Auto ban player on ban list
|
||||
if (BetterGameSettings.UseBanPlayerList.GetBool())
|
||||
{
|
||||
|
||||
+87
-31
@@ -21,8 +21,6 @@ public class RoleManagerPatch
|
||||
[HarmonyPrefix]
|
||||
public static bool RoleManager_Prefix(/*RoleManager __instance*/)
|
||||
{
|
||||
if (!Main.BetterRoleAlgorithma.Value) return true;
|
||||
|
||||
if (!GameStates.IsHideNSeek)
|
||||
{
|
||||
RegularBetterRoleAssignment();
|
||||
@@ -140,19 +138,22 @@ public class RoleManagerPatch
|
||||
player.RpcSetRole(role);
|
||||
|
||||
// Desync role to other clients to prevent revealing the true role
|
||||
if (IsImpostorRole(role) && role is not RoleTypes.Phantom)
|
||||
if (BetterGameSettings.DesyncRoles.GetBool())
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(player.NetId, (byte)RpcCalls.SetRole, SendOption.None, player.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Impostor));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
}
|
||||
else if (role is not RoleTypes.Noisemaker)
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(player.NetId, (byte)RpcCalls.SetRole, SendOption.None, player.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Crewmate));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
if (IsImpostorRole(role) && role is not RoleTypes.Phantom)
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(player.NetId, (byte)RpcCalls.SetRole, SendOption.None, player.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Impostor));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
}
|
||||
else if (role is not RoleTypes.Noisemaker)
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(player.NetId, (byte)RpcCalls.SetRole, SendOption.None, player.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Crewmate));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
}
|
||||
}
|
||||
|
||||
player.roleAssigned = true;
|
||||
@@ -192,14 +193,19 @@ public class RoleManagerPatch
|
||||
ImpostorRoles[kvp.Key]--;
|
||||
Impostors.Add(pc);
|
||||
pc.RpcSetRole(kvp.Key);
|
||||
|
||||
// Desync role to other clients to prevent revealing the true role
|
||||
if (kvp.Key is not RoleTypes.Phantom)
|
||||
if (BetterGameSettings.DesyncRoles.GetBool())
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(pc.NetId, (byte)RpcCalls.SetRole, SendOption.None, pc.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Impostor));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
if (kvp.Key is not RoleTypes.Phantom)
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(pc.NetId, (byte)RpcCalls.SetRole, SendOption.None, pc.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Impostor));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
}
|
||||
}
|
||||
|
||||
pc.roleAssigned = true;
|
||||
Logger.Log($"Assigned {Utils.GetRoleName(kvp.Key)} role to {pc.Data.PlayerName}", "RoleManager");
|
||||
break;
|
||||
@@ -226,14 +232,19 @@ public class RoleManagerPatch
|
||||
CrewmateRoles[kvp.Key]--;
|
||||
Crewmates.Add(pc);
|
||||
pc.RpcSetRole(kvp.Key);
|
||||
|
||||
// Desync role to other clients to prevent revealing the true role
|
||||
if (kvp.Key is not RoleTypes.Noisemaker)
|
||||
if (BetterGameSettings.DesyncRoles.GetBool())
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(pc.NetId, (byte)RpcCalls.SetRole, SendOption.None, pc.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Crewmate));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
if (kvp.Key is not RoleTypes.Noisemaker)
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(pc.NetId, (byte)RpcCalls.SetRole, SendOption.None, pc.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Crewmate));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
}
|
||||
}
|
||||
|
||||
pc.roleAssigned = true;
|
||||
Logger.Log($"Assigned {Utils.GetRoleName(kvp.Key)} role to {pc.Data.PlayerName}", "RoleManager");
|
||||
break;
|
||||
@@ -286,10 +297,41 @@ public class RoleManagerPatch
|
||||
Impostors.Add(player);
|
||||
player.RpcSetRole(RoleTypes.Impostor);
|
||||
player.roleAssigned = true;
|
||||
NumImpostors--;
|
||||
Logger.Log($"Settings Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {player.Data.PlayerName}", "RoleManager");
|
||||
}
|
||||
}
|
||||
|
||||
var betterImpostorSettings = new int[]
|
||||
{
|
||||
-1,
|
||||
BetterGameSettingsTemp.HideAndSeekImp2.GetValue(),
|
||||
BetterGameSettingsTemp.HideAndSeekImp3.GetValue(),
|
||||
BetterGameSettingsTemp.HideAndSeekImp4.GetValue(),
|
||||
BetterGameSettingsTemp.HideAndSeekImp5.GetValue()
|
||||
};
|
||||
|
||||
for (int i = 1; i < BetterGameSettings.HideAndSeekImpNum.GetInt(); i++)
|
||||
{
|
||||
int tempSetImpostor = betterImpostorSettings[i];
|
||||
|
||||
if (tempSetImpostor >= 0)
|
||||
{
|
||||
var player = Utils.PlayerFromId(tempSetImpostor);
|
||||
if (player != null)
|
||||
{
|
||||
if (NumImpostors > 0 && !Impostors.Contains(player))
|
||||
{
|
||||
Impostors.Add(player);
|
||||
player.RpcSetRole(RoleTypes.Impostor);
|
||||
player.roleAssigned = true;
|
||||
NumImpostors--;
|
||||
Logger.Log($"Settings Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {player.Data.PlayerName}", "RoleManager");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Override player role assignment
|
||||
if (SetPlayerRole.Keys.Any())
|
||||
{
|
||||
@@ -377,8 +419,6 @@ public class RoleManagerPatch
|
||||
[HarmonyPrefix]
|
||||
public static bool AssignRoleOnDeath_Prefix(/*RoleManager __instance*/ [HarmonyArgument(0)] PlayerControl player)
|
||||
{
|
||||
if (!Main.BetterRoleAlgorithma.Value) return true;
|
||||
|
||||
Dictionary<RoleTypes, int> GhostRoles = new() // Role, Amount
|
||||
{
|
||||
{ RoleTypes.GuardianAngel, 0 },
|
||||
@@ -411,11 +451,16 @@ public class RoleManagerPatch
|
||||
if (kvp.Value > 0 && RNG() <= GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(kvp.Key))
|
||||
{
|
||||
player.RpcSetRole(kvp.Key);
|
||||
|
||||
// Desync role to other clients to prevent revealing the true role
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(player.NetId, (byte)RpcCalls.SetRole, SendOption.None, player.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)player.Data.Role.DefaultGhostRole));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
if (BetterGameSettings.DesyncRoles.GetBool())
|
||||
{
|
||||
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(player.NetId, (byte)RpcCalls.SetRole, SendOption.None, player.GetClientId(), clientCheck);
|
||||
messageWriter.ForEach(mW => mW.Write((ushort)player.Data.Role.DefaultGhostRole));
|
||||
messageWriter.ForEach(mW => mW.Write(false));
|
||||
AmongUsClient.Instance.FinishRpcDesync(messageWriter);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -450,5 +495,16 @@ public class RoleManagerPatch
|
||||
return shuffledDictionary;
|
||||
}
|
||||
|
||||
private static int RNG() => random.Next(0, 100);
|
||||
public static int RNG()
|
||||
{
|
||||
switch (BetterGameSettings.RoleRandomizer.GetValue())
|
||||
{
|
||||
case 1:
|
||||
return UnityEngine.Random.Range(0, 100);
|
||||
|
||||
default:
|
||||
Random Random = new Random();
|
||||
return Random.Next(0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,6 @@ public class VersionShowerPatch
|
||||
[HarmonyPostfix]
|
||||
public static void Postfix(VersionShower __instance)
|
||||
{
|
||||
__instance.text.text = $"<color=#0dff00>♻BetterAmongUs♻ {Main.GetVersionText()}</color> - " + __instance.text.text;
|
||||
__instance.text.text = $"<color=#0dff00>♻BetterAmongUs♻ {Main.GetVersionText()}</color> <color=#ababab>~</color> {Utils.GetPlatformName(Main.PlatformData.Platform)} v{Main.AmongUsVersion}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#Number:110002
|
||||
#Title:Better Among Us v1.1.0
|
||||
#SubTitle:<color=#4d4d4d>Settings Galore!</color>
|
||||
#ShortTitle:BAU v1.1.0
|
||||
#Date:2024-8-24T00:00:00Z
|
||||
#-----------------------------
|
||||
We are thrilled to announce the release of <b>BetterAmongUs</b> v1.1.0
|
||||
#
|
||||
BetterAmongUs comes packed with a variety of features designed to improve your gameplay experience:
|
||||
#
|
||||
<size=150%>Change Log</size>
|
||||
#
|
||||
<b>Client</b>
|
||||
New: Added new intro on boot up
|
||||
New: Added ability to skip intro by clicking the left or right Mouse button
|
||||
New: Added Better Option to have chat always visible
|
||||
Fixed: All players appearing in the role intro
|
||||
#
|
||||
<b>Lobby Settings</b>
|
||||
New: Added the ability to bypass number restrictions in lobby settings
|
||||
New: Added Better Settings tab with new settings
|
||||
New: Game Settings is now the default tab when opening lobby settings panel
|
||||
New: Lobby Settings panel is now available for Non-Host but only Better Settings is editable
|
||||
Hide And Seek
|
||||
New: Added Better Setting to set imposter amount
|
||||
Requires Better Role Algorithm
|
||||
#
|
||||
<b>Anti-Cheat</b>
|
||||
Added list of Better Settings
|
||||
1. When a player is caught cheating
|
||||
2. Allow invalid friendCodes
|
||||
3. Use Ban Player List
|
||||
4. Use Ban Name List
|
||||
5. Use Ban Word List
|
||||
6. Detected player level = or >
|
||||
7. Detect Cheat Clients
|
||||
8. Detect Invalid RPCs
|
||||
9. Detect Invalid Sabotages // Needs testing!
|
||||
#
|
||||
#
|
||||
<size=150%>Issues & Bugs</size>
|
||||
#
|
||||
- If you encounter any issues or have feedback, please report them on our <nobr><link="https://github.com/D1GQ/BetterAmongUs-Public/issues">Github Issues Page</nobr></link> or Bug Reports channel in the <nobr><link="https://discord.gg/a3eVJHp9p5">BAU Discord Server</nobr></link>.
|
||||
#
|
||||
Thank you for your support, and we hope you enjoy the new features of <b>BetterAmongUs</b>!
|
||||
#
|
||||
<size=150%><nobr><link="https://discord.gg/vjYrXpzNAn">Discord</nobr></link> </size> <size=150%><nobr><link="https://github.com/D1GQ/BetterAmongUs-Public">Github</nobr></link> </size>
|
||||
@@ -27,8 +27,8 @@ public class Main : BasePlugin
|
||||
public const string HotfixNum = "0";
|
||||
public const bool IsHotFix = false;
|
||||
public const string PluginGuid = "com.d1gq.betteramongus";
|
||||
public const string PluginVersion = "1.1.0";
|
||||
public const string ReleaseDate = "08.24.2024"; // mm/dd/yyyy
|
||||
public const string PluginVersion = "1.1.1";
|
||||
public const string ReleaseDate = "08.25.2024"; // mm/dd/yyyy
|
||||
public const string Github = "https://github.com/D1GQ/BetterAmongUs-Public";
|
||||
public const string Discord = "https://discord.gg/vjYrXpzNAn";
|
||||
|
||||
@@ -84,6 +84,8 @@ public class Main : BasePlugin
|
||||
public static string BetterAmongUsVersion => PluginVersion;
|
||||
public static string AmongUsVersion => Application.version;
|
||||
|
||||
public static PlatformSpecificData PlatformData => Constants.GetPlatformData();
|
||||
|
||||
public static List<string> SupportedAmongUsVersions =
|
||||
[
|
||||
"2024.8.13",
|
||||
@@ -143,7 +145,7 @@ public class Main : BasePlugin
|
||||
BetterDataManager.LoadData();
|
||||
LoadOptions();
|
||||
|
||||
if (File.Exists(Path.Combine($"{Environment.CurrentDirectory}/Among Us_Data/Plugins/x86", "steam_api.dll")))
|
||||
if (PlatformData.Platform == Platforms.StandaloneSteamPC)
|
||||
File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "steam_appid.txt"), "945360");
|
||||
|
||||
if (File.Exists(Path.Combine(BetterDataManager.filePathFolder, "better-log.txt")))
|
||||
@@ -164,7 +166,7 @@ public class Main : BasePlugin
|
||||
string SupportedVersions = string.Empty;
|
||||
foreach (string text in SupportedAmongUsVersions.ToArray())
|
||||
SupportedVersions += $"{text} ";
|
||||
BetterAmongUs.Logger.Log($"BetterAmongUs {BetterAmongUsVersion}-{ReleaseDate} - [{AmongUsVersion} --> {SupportedVersions.Substring(0, SupportedVersions.Length - 1)}]");
|
||||
BetterAmongUs.Logger.Log($"BetterAmongUs {BetterAmongUsVersion}-{ReleaseDate} - [{AmongUsVersion} --> {SupportedVersions.Substring(0, SupportedVersions.Length - 1)}] {Utils.GetPlatformName(PlatformData.Platform)}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -174,7 +176,6 @@ public class Main : BasePlugin
|
||||
|
||||
public static ConfigEntry<bool> AntiCheat { get; private set; }
|
||||
public static ConfigEntry<bool> BetterHost { get; private set; }
|
||||
public static ConfigEntry<bool> BetterRoleAlgorithma { get; private set; }
|
||||
public static ConfigEntry<bool> BetterNotifications { get; private set; }
|
||||
public static ConfigEntry<bool> ChatInGameplay { get; private set; }
|
||||
public static ConfigEntry<bool> LobbyPlayerInfo { get; private set; }
|
||||
@@ -186,7 +187,6 @@ public class Main : BasePlugin
|
||||
{
|
||||
AntiCheat = Config.Bind("Better Options", "AntiCheat", true);
|
||||
BetterHost = Config.Bind("Better Options", "BetterHost", false);
|
||||
BetterRoleAlgorithma = Config.Bind("Better Options", "BetterRoleAlgorithma", true);
|
||||
BetterNotifications = Config.Bind("Better Options", "BetterNotifications", true);
|
||||
ChatInGameplay = Config.Bind("Better Options", "ChatInGameplay", true);
|
||||
LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true);
|
||||
|
||||
Reference in new issue
Block a user