Skip to content

Commit

Permalink
Update v1.1.3.0 Pre
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Feb 24, 2025
1 parent 3e8168a commit 38f52d3
Show file tree
Hide file tree
Showing 37 changed files with 929 additions and 223 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
8 changes: 4 additions & 4 deletions TheOtherRoles/Buttons/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2150,7 +2150,7 @@ public static void createButtonsPostfix(HudManager __instance)
ButtonPositions.upperRowCenter,
__instance,
modKillInput.keyCode,
buttonText: GetString("killButtonText")
buttonText: GetString("killButtonText")
);
PavlovsdogKillSelfText = Object.Instantiate(pavlovsdogsKillButton.actionButton.cooldownTimerText,
pavlovsdogsKillButton.actionButton.cooldownTimerText.transform.parent);
Expand Down Expand Up @@ -3629,7 +3629,7 @@ public static void createButtonsPostfix(HudManager __instance)
},
() =>
{
return Pursuer.Player != null && Pursuer.Player.Contains(PlayerControl.LocalPlayer) &&
return Pursuer.Player != null && Pursuer.Player.MContains(PlayerControl.LocalPlayer) &&
PlayerControl.LocalPlayer.IsAlive()/* && Pursuer.blanks < Pursuer.blanksNumber*/;
},
() =>
Expand Down Expand Up @@ -3672,7 +3672,7 @@ public static void createButtonsPostfix(HudManager __instance)
},
() =>
{
return Survivor.Player != null && Survivor.Player.Contains(PlayerControl.LocalPlayer) &&
return Survivor.Player != null && Survivor.Player.MContains(PlayerControl.LocalPlayer) &&
PlayerControl.LocalPlayer.IsAlive() && Survivor.vestEnable/* && Survivor.remainingVests > 0*/;
},
() =>
Expand Down Expand Up @@ -3727,7 +3727,7 @@ public static void createButtonsPostfix(HudManager __instance)
},
() =>
{
return Survivor.Player != null && Survivor.Player.Contains(PlayerControl.LocalPlayer) &&
return Survivor.Player != null && Survivor.Player.MContains(PlayerControl.LocalPlayer) &&
PlayerControl.LocalPlayer.IsAlive() && Survivor.blanksEnable/* && Survivor.remainingBlanks > 0*/;
},
() =>
Expand Down
40 changes: 38 additions & 2 deletions TheOtherRoles/Buttons/CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class CustomButton
public Func<bool> HasButton;
public bool HasEffect;
public KeyCode? hotkey;
//public KeyCode? originalHotkey;
//public static KeyCode Action2Keycode = KeyCode.G;
//public static KeyCode Action3Keycode = KeyCode.H;
public HudManager hudManager;
public bool isEffectActive;
public bool isHandcuffed;
Expand Down Expand Up @@ -68,6 +71,7 @@ public CustomButton(Action OnClick, Func<bool> HasButton, Func<bool> CouldUse, A
showButtonText = actionButtonRenderer.sprite == Sprite || buttonText != "";
button.OnClick = new Button.ButtonClickedEvent();
button.OnClick.AddListener((UnityAction)onClickEvent);
//originalHotkey = hotkey;

Timer = 10.5f;
SetHotKeyGuide();
Expand Down Expand Up @@ -148,7 +152,7 @@ public static void ResetAllCooldowns(float Time = -1)
Error($"NullReferenceException from ResetAllCooldowns(), if theres only one warning its fine\n{e}", "CustomButton");
}
}
PlayerControl.LocalPlayer.killTimer = time;
PlayerControl.LocalPlayer.SetKillTimer(time);
}

public static void resetKillButton(PlayerControl p, float time = -1)
Expand All @@ -157,7 +161,7 @@ public static void resetKillButton(PlayerControl p, float time = -1)
if (p.Data.Role.IsImpostor)
{
if (time == -1) time = ModOption.KillCooddown;
p.killTimer = time;
p.SetKillTimer(time);
}

pelicanKillButton.Timer = time == -1 ? pelicanKillButton.MaxTimer : time;
Expand Down Expand Up @@ -281,6 +285,37 @@ public void Update()
OnClick = InitialOnClick;
}

// Reload the rebound hotkeys from the among us settings.
/*public static void ReloadHotkeys()
{
foreach (var button in buttons)
{
// Q button is used only for killing! This rebinds every button that would use Q to use the currently set killing button in among us.
if (button.originalHotkey == KeyCode.Q)
{
Player player = ReInput.players.GetPlayer(0);
string keycode = player.controllers.maps.GetFirstButtonMapWithAction(8, true).elementIdentifierName;
button.hotkey = (KeyCode)Enum.Parse(typeof(KeyCode), keycode);
}
// F is the default ability button. All buttons that would use F now use the ability button.
if (button.originalHotkey == KeyCode.F)
{
Player player = ReInput.players.GetPlayer(0);
string keycode = player.controllers.maps.GetFirstButtonMapWithAction(49, true).elementIdentifierName;
button.hotkey = (KeyCode)Enum.Parse(typeof(KeyCode), keycode);
}
if (button.originalHotkey == KeyCode.G)
{
button.hotkey = Action2Keycode;
}
if (button.originalHotkey == KeyCode.H)
{
button.hotkey = Action3Keycode;
}
}
}*/

public static GameObject SetKeyGuide(GameObject button, KeyCode key, Vector2 pos)
{
Sprite numSprite = null;
Expand Down Expand Up @@ -364,5 +399,6 @@ public static class ButtonPositions
public static readonly Vector3 upperRowCenter = new(-1f, 1f, 0f); // Not usable for imps beacuse of new button positions!
public static readonly Vector3 upperRowLeft = new(-2f, 1f, 0f);
public static readonly Vector3 upperRowFarLeft = new(-3f, 1f, 0f);
public static readonly Vector3 highRowRight = new(0f, 2.06f, 0f);
}
}
20 changes: 15 additions & 5 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static class Helpers
public static bool isAirship => GameOptionsManager.Instance.CurrentGameOptions.MapId == 4;
public static bool isFungle => GameOptionsManager.Instance.CurrentGameOptions.MapId == 5;

public static string previousEndGameSummary = "";
public static System.Random rnd => new(Guid.NewGuid().GetHashCode());

public static bool isUsingTransportation(this PlayerControl pc) => pc.inMovingPlat || pc.onLadder;
Expand Down Expand Up @@ -263,15 +264,15 @@ public static bool isEvilNeutral(PlayerControl player)

public static bool isKiller(this PlayerControl player)
{
return player != null && (player.isImpostor() || isKillerNeutral(player));
return player != null && (player.IsImpostor() || isKillerNeutral(player));
}

public static bool isCrew(this PlayerControl player)
{
return player != null && !player.Data.Role.IsImpostor && !isNeutral(player);
}

public static bool isImpostor(this PlayerControl player, bool Spy = false)
public static bool IsImpostor(this PlayerControl player, bool Spy = false)
{
if (Spy && Roles.Crewmate.Spy.spy != null && Roles.Crewmate.Spy.spy == player) return true;
return player != null && player.Data.Role.IsImpostor;
Expand All @@ -281,7 +282,7 @@ public static string teamString(PlayerControl player)
{
var killerTeam = "";
if (isNeutral(player)) killerTeam = "NeutralRolesText".Translate();
else if (player.isImpostor()) killerTeam = "ImpostorRolesText".Translate();
else if (player.IsImpostor()) killerTeam = "ImpostorRolesText".Translate();
else if (player.isCrew()) killerTeam = "CrewmateRolesText".Translate();
return killerTeam;
}
Expand Down Expand Up @@ -599,10 +600,19 @@ public static int Count<T>(this Il2CppSystem.Collections.Generic.List<T> list, F
{
int count = 0;
foreach (T obj in list)
if (func == null || func(obj))
count++;
if (func == null || func(obj)) count++;
return count;
}

public static bool MContains<T>(this IEnumerable<T> source, T item) where T : class
{
if (source == null)
return false;
foreach (var i in source)
if (i == item) return true;
return false;
}

public static Color HexToColor(string hex)
{
_ = ColorUtility.TryParseHtmlString("#" + hex, out var color);
Expand Down
7 changes: 5 additions & 2 deletions TheOtherRoles/Helper/LogHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Text;
using BepInEx;
using BepInEx.Logging;
Expand All @@ -24,9 +25,11 @@ internal static void SetLogSource(ManualLogSource Source)

public static void SendLog(string text, string tag = "", LogLevel logLevel = LogLevel.Info)
{
StackFrame stack = new(2);
string time = DateTime.Now.ToString("HH:mm:ss");
if (!string.IsNullOrWhiteSpace(tag)) text = $"[{time}] [{tag}] {text}";
else text = $"[{time}] {text}";
string className = stack.GetMethod().ReflectedType.Name;
if (!string.IsNullOrWhiteSpace(tag)) text = $"[{time}] [{className}] [{tag}] {text}";
else text = $"[{time}] [{className}] {text}";

switch (logLevel)
{
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace TheOtherRoles;
[ReactorModFlags(ModFlags.RequireOnAllClients)]
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "TheOtherUs.Options.v2"; // Config files name
public const string Id = "TheOtherUs.Options.v3"; // Config files name
public const string ModName = MyPluginInfo.PLUGIN_NAME;
public const string VersionString = MyPluginInfo.PLUGIN_VERSION;

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Modules/ChatCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public static void Postfix(ChatBubble __instance, [HarmonyArgument(0)] string pl
.FirstOrDefault(x => x.Data != null && x.Data.PlayerName.Equals(playerName, StringComparison.Ordinal));

if (PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.Data.Role.IsImpostor && __instance != null
&& (Spy.spy != null && sourcePlayer.PlayerId == Spy.spy.PlayerId))
&& Spy.spy != null && sourcePlayer.PlayerId == Spy.spy.PlayerId)
{
__instance.NameText.color = Palette.ImpostorRed;
}
Expand Down
7 changes: 0 additions & 7 deletions TheOtherRoles/Modules/KeyboardHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ private static void Postfix(KeyboardJoystick __instance)
GameStartManager.Instance.countDownTimer = 0;
}
}
if (PlayerControl.LocalPlayer.IsAlive() && !PlayerControl.LocalPlayer.isImpostor())
{
if (KeyboardJoystick.player.GetButtonDown(50))
{
DestroyableSingleton<HudManager>.Instance.ImpostorVentButton.DoClick();
}
}
}
public static string RandomString(int length)
{
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/Modules/PlayerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class PlayerData<T>
{
private Dictionary<byte, T> _data;
private Dictionary<PlayerControl, T> _playerdata;
private T defaultvalue = default;
private bool nonsetinit = false;
private T defaultvalue;
private bool nonsetinit;
public T Local
{
get => this[PlayerControl.LocalPlayer.PlayerId];
Expand Down
Loading

0 comments on commit 38f52d3

Please sign in to comment.