Skip to content

Commit

Permalink
Arrow optimization & Madmate fixed role
Browse files Browse the repository at this point in the history
  • Loading branch information
dabao40 committed Nov 29, 2024
1 parent cefc82d commit b2227bc
Show file tree
Hide file tree
Showing 15 changed files with 401 additions and 241 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
46 changes: 8 additions & 38 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ public static void createButtonsPostfix(HudManager __instance) {
Helpers.checkMurderAttemptAndKill(Veteran.veteran, Eraser.eraser);
return;
}
eraserButton.MaxTimer += 10;
eraserButton.MaxTimer += Eraser.cooldownIncrease;
eraserButton.Timer = eraserButton.MaxTimer;

_ = new StaticAchievementToken("eraser.common1");
Expand Down Expand Up @@ -1750,40 +1750,7 @@ public static void createButtonsPostfix(HudManager __instance) {
SoundEffectsManager.play("moriartyBrainwash");

// 洗脳終了までのカウントダウン
TMPro.TMP_Text text;
RoomTracker roomTracker = HudManager.Instance?.roomTracker;
GameObject gameObject = UnityEngine.Object.Instantiate(roomTracker.gameObject);
UnityEngine.Object.DestroyImmediate(gameObject.GetComponent<RoomTracker>());
gameObject.transform.SetParent(HudManager.Instance.transform);
gameObject.transform.localPosition = new Vector3(0, -1.3f, gameObject.transform.localPosition.z);
gameObject.transform.localScale = Vector3.one * 3f;
text = gameObject.GetComponent<TMPro.TMP_Text>();
PlayerControl tmpP = Moriarty.target;
bool done = false;
HudManager.Instance.StartCoroutine(Effects.Lerp(Moriarty.brainwashTime, new Action<float>((p) =>
{
if (done)
{
return;
}
if (Moriarty.target == null || MeetingHud.Instance != null || p == 1f)
{
if (text != null && text.gameObject) UnityEngine.Object.Destroy(text.gameObject);
if (Moriarty.target == tmpP) Moriarty.target = null;
done = true;
return;
}
else
{
string message = (Moriarty.brainwashTime - (p * Moriarty.brainwashTime)).ToString("0");
bool even = ((int)(p * Moriarty.brainwashTime / 0.25f)) % 2 == 0; // Bool flips every 0.25 seconds
// string prefix = even ? "<color=#555555FF>" : "<color=#FFFFFFFF>";
string prefix = "<color=#555555FF>";
text.text = prefix + message + "</color>";
if (text != null) text.color = even ? Color.yellow : Color.red;

}
})));
Moriarty.generateBrainwashText();
}
Moriarty.tmpTarget = null;
moriartyBrainwashButton.Timer = moriartyBrainwashButton.MaxTimer;
Expand Down Expand Up @@ -1823,6 +1790,7 @@ public static void createButtonsPostfix(HudManager __instance) {
{
moriartyKillCounterText.text = $"{Moriarty.counter}/{Moriarty.numberToWin}";
}
moriartyKillButton.buttonText = Moriarty.killTarget ? Moriarty.killTarget.Data.PlayerName : ModTranslation.getString("moriartyTargetNone");
return Moriarty.killTarget != null && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
},
// OnMeetingEnds
Expand All @@ -1836,7 +1804,8 @@ public static void createButtonsPostfix(HudManager __instance) {
CustomButton.ButtonPositions.upperRowRight,
__instance,
KeyCode.Q,
actionName: FastDestroyableSingleton<TranslationController>.Instance.GetString(StringNames.KillLabel).camelString()
actionName: FastDestroyableSingleton<TranslationController>.Instance.GetString(StringNames.KillLabel).camelString(),
buttonText: ModTranslation.getString("moriartyTargetNone")
);
moriartyKillCounterText = GameObject.Instantiate(moriartyKillButton.actionButton.cooldownTimerText, moriartyKillButton.actionButton.cooldownTimerText.transform.parent);
moriartyKillCounterText.text = "";
Expand Down Expand Up @@ -3049,7 +3018,8 @@ public static void createButtonsPostfix(HudManager __instance) {
KeyCode.H,
false,
FastDestroyableSingleton<TranslationController>.Instance.GetString(StringNames.Admin),
actionName: FastDestroyableSingleton<TranslationController>.Instance.GetString(StringNames.Admin).camelString()
actionName: FastDestroyableSingleton<TranslationController>.Instance.GetString(StringNames.Admin).camelString(),
abilityTexture: CustomButton.ButtonLabelType.AdminButton
);

// Ninja Stealth
Expand Down Expand Up @@ -3701,7 +3671,7 @@ Func<bool> fortuneTellerCouldUse(byte index)
int adjustedIndex = index < CachedPlayer.LocalPlayer.PlayerId ? index : index - 1;
// 占い師以外の場合、リソースがない場合はボタンを表示しない
if (!TORMapOptions.playerIcons.ContainsKey(index) ||
!CachedPlayer.LocalPlayer.PlayerControl == FortuneTeller.fortuneTeller ||
CachedPlayer.LocalPlayer.PlayerControl != FortuneTeller.fortuneTeller ||
CachedPlayer.LocalPlayer.PlayerControl.Data.IsDead ||
CachedPlayer.LocalPlayer.PlayerControl.PlayerId == index ||
!FortuneTeller.isCompletedNumTasks(FortuneTeller.fortuneTeller) ||
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/CustomGameModes/FreePlayGM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ void SetWidget(int tab)
} else if (formerRole.roleId is RoleId.Fox or RoleId.JekyllAndHyde or RoleId.TaskMaster) {
var options = GameOptionsManager.Instance.currentNormalGameOptions;
PlayerControl.LocalPlayer.generateAndAssignTasks(options.NumCommonTasks, options.NumShortTasks, options.NumLongTasks);
} else if (r.roleId == RoleId.FortuneTeller) {
FortuneTeller.meetingFlag = false;
}
RPCProcedure.resetAchievement();
roleScreen.CloseScreen();
Expand Down
14 changes: 11 additions & 3 deletions TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Epic.OnlineServices.RTCAudio;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static TheOtherRoles.TheOtherRoles;
using Types = TheOtherRoles.CustomOption.CustomOptionType;
Expand Down Expand Up @@ -44,7 +45,9 @@ public class CustomOptionHolder {

public static CustomOption eraserSpawnRate;
public static CustomOption eraserCooldown;
public static CustomOption eraserCooldownIncrease;
public static CustomOption eraserCanEraseAnyone;

public static CustomOption guesserSpawnRate;
public static CustomOption guesserIsImpGuesserRate;
public static CustomOption guesserNumberOfShots;
Expand Down Expand Up @@ -518,7 +521,9 @@ public class CustomOptionHolder {
public static CustomOption modifierChameleonMinVisibility;

public static CustomOption madmateSpawnRate;
public static CustomOption madmateQuantity;
public static CustomOption madmateQuantity;
public static CustomOption madmateFixedRole;
public static CustomOption madmateFixedRoleGuesserGamemode;
public static CustomOption madmateCanDieToSheriff;
public static CustomOption madmateCanEnterVents;
public static CustomOption madmateCanSabotage;
Expand Down Expand Up @@ -660,6 +665,7 @@ public static void Load() {

eraserSpawnRate = CustomOption.Create(230, Types.Impostor, cs(Eraser.color, "eraser"), rates, null, true);
eraserCooldown = CustomOption.Create(231, Types.Impostor, "eraserCooldown", 30f, 10f, 120f, 5f, eraserSpawnRate, false, "unitSeconds");
eraserCooldownIncrease = CustomOption.Create(233, Types.Impostor, "eraserCooldownIncrease", 10f, 0f, 120f, 2.5f, eraserSpawnRate, format: "unitSeconds");
eraserCanEraseAnyone = CustomOption.Create(232, Types.Impostor, "eraserCanEraseAnyone", false, eraserSpawnRate);

tricksterSpawnRate = CustomOption.Create(250, Types.Impostor, cs(Trickster.color, "trickster"), rates, null, true);
Expand Down Expand Up @@ -1136,6 +1142,8 @@ public static void Load() {

madmateSpawnRate = CustomOption.Create(4041, Types.Modifier, cs(Color.yellow, "madmate"), rates, null, true);
madmateQuantity = CustomOption.Create(7005, Types.Modifier, cs(Color.yellow, "madmateQuantity"), ratesModifier, madmateSpawnRate);
madmateFixedRole = CustomOption.Create(7006, Types.Modifier, "madmateFixedRole", Madmate.validRoles, madmateSpawnRate);
madmateFixedRoleGuesserGamemode = CustomOption.Create(7007, Types.Modifier, "madmateFixedRole", Madmate.validRoles.Where(x => x != RoleId.NiceGuesser).ToList(), madmateSpawnRate);
madmateAbility = CustomOption.Create(4047, Types.Modifier, "madmateAbility", true, madmateSpawnRate);
madmateCommonTasks = CustomOption.Create(4049, Types.Modifier, "madmateCommonTasks", 1f, 0f, 3f, 1f, madmateAbility, false, "unitScrews");
madmateShortTasks = CustomOption.Create(4048, Types.Modifier, "madmateShortTasks", 3f, 0f, 4f, 1f, madmateAbility, false, "unitScrews");
Expand Down Expand Up @@ -1214,10 +1222,10 @@ public static void Load() {
fungleElectrical = CustomOption.Create(6074, Types.General, "fungleElectrical", false);
randomGameStartPosition = CustomOption.Create(6071, Types.General, "randomGameStartPosition", false);
activateProps = CustomOption.Create(6083, Types.General, "activateProps", false, null, true, heading: "headingPropSetting");
numAccelTraps = CustomOption.Create(6084, Types.General, "numAccelTraps", 1f, 1f, 5f, 1f, activateProps, false, "unitScrews");
numAccelTraps = CustomOption.Create(6084, Types.General, "numAccelTraps", 1f, 0f, 5f, 1f, activateProps, false, "unitScrews");
accelerationDuration = CustomOption.Create(6085, Types.General, "accelerationDuration", 5f, 1f, 20f, 1f, activateProps, false, "unitSeconds");
speedAcceleration = CustomOption.Create(6086, Types.General, "speedAcceleration", 1.25f, 0.5f, 2f, 0.25f, activateProps, false, "unitTimes");
numDecelTraps = CustomOption.Create(6087, Types.General, "numDecelTraps", 1f, 1f, 3f, 1f, activateProps, false, "unitScrews");
numDecelTraps = CustomOption.Create(6087, Types.General, "numDecelTraps", 1f, 0f, 3f, 1f, activateProps, false, "unitScrews");
decelerationDuration = CustomOption.Create(6091, Types.General, "decelerationDuration", 5f, 1f, 20f, 1f, activateProps, false, "unitSeconds");
speedDeceleration = CustomOption.Create(6089, Types.General, "speedDeceleration", -0.5f, -0.8f, -0.1f, 0.1f, activateProps, false, "unitTimes");
decelUpdateInterval = CustomOption.Create(6090, Types.General, "decelUpdateInterval", 10f, 5f, 60f, 2.5f, activateProps, false, "unitSeconds");
Expand Down
27 changes: 13 additions & 14 deletions TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static string GradientColorText(string startColorHex, string endColorHex,
public static Color HexToColor(string hex)
{
Color color = new();
ColorUtility.TryParseHtmlString("#" + hex, out color);
_ = ColorUtility.TryParseHtmlString("#" + hex, out color);
return color;
}

Expand Down Expand Up @@ -330,7 +330,7 @@ public static bool isLighterColor(int colorId) {
public static bool isCustomServer() {
if (FastDestroyableSingleton<ServerManager>.Instance == null) return false;
StringNames n = FastDestroyableSingleton<ServerManager>.Instance.CurrentRegion.TranslateName;
return n != StringNames.ServerNA && n != StringNames.ServerEU && n != StringNames.ServerAS;
return n is not StringNames.ServerNA and not StringNames.ServerEU and not StringNames.ServerAS;
}

static public int[] Sequential(int length)
Expand Down Expand Up @@ -372,17 +372,17 @@ public static int GetDisplayType(int players)
}

public static bool hasFakeTasks(this PlayerControl player) {
return (player == Jester.jester || player == Jackal.jackal || player == Sidekick.sidekick || player == Arsonist.arsonist || player == Opportunist.opportunist || player == Vulture.vulture || Jackal.formerJackals.Any(x => x == player) || player == Moriarty.moriarty || player == Moriarty.formerMoriarty
return player == Jester.jester || player == Jackal.jackal || player == Sidekick.sidekick || player == Arsonist.arsonist || player == Opportunist.opportunist || player == Vulture.vulture || Jackal.formerJackals.Any(x => x == player) || player == Moriarty.moriarty || player == Moriarty.formerMoriarty
|| (Madmate.madmate.Any(x => x.PlayerId == player.PlayerId) && !Madmate.hasTasks) ||
(player == CreatedMadmate.createdMadmate && !CreatedMadmate.hasTasks) || player == Akujo.akujo || player == Kataomoi.kataomoi || player == PlagueDoctor.plagueDoctor || player == JekyllAndHyde.formerJekyllAndHyde || player == Cupid.cupid || (player == SchrodingersCat.schrodingersCat && !SchrodingersCat.hideRole));
(player == CreatedMadmate.createdMadmate && !CreatedMadmate.hasTasks) || player == Akujo.akujo || player == Kataomoi.kataomoi || player == PlagueDoctor.plagueDoctor || player == JekyllAndHyde.formerJekyllAndHyde || player == Cupid.cupid || (player == SchrodingersCat.schrodingersCat && !SchrodingersCat.hideRole);
}

public static bool canBeErased(this PlayerControl player) {
return (player != Jackal.jackal && player != Sidekick.sidekick && !Jackal.formerJackals.Any(x => x == player));
return player != Jackal.jackal && player != Sidekick.sidekick && !Jackal.formerJackals.Any(x => x == player);
}

public static bool shouldShowGhostInfo() {
return CachedPlayer.LocalPlayer.PlayerControl != null && CachedPlayer.LocalPlayer.PlayerControl.Data.IsDead && !(CachedPlayer.LocalPlayer.PlayerControl == Busker.busker && Busker.pseudocideFlag) && TORMapOptions.ghostsSeeInformation || AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Ended;
return (CachedPlayer.LocalPlayer.PlayerControl != null && CachedPlayer.LocalPlayer.PlayerControl.Data.IsDead && !(CachedPlayer.LocalPlayer.PlayerControl == Busker.busker && Busker.pseudocideFlag) && TORMapOptions.ghostsSeeInformation) || AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Ended;
}

public static void clearAllTasks(this PlayerControl player) {
Expand Down Expand Up @@ -447,8 +447,8 @@ public static string camelString(this string input)
if (string.IsNullOrEmpty(input))
return input;

string firstLetter = input.Substring(0, 1).ToUpper();
string remainingLetters = input.Substring(1).ToLower();
string firstLetter = input[..1].ToUpper();
string remainingLetters = input[1..].ToLower();
return firstLetter + remainingLetters;
}

Expand Down Expand Up @@ -600,7 +600,7 @@ private static IEnumerator AnimateCoroutine(HideAndSeekDeathPopup __instance)
while (true)
{
AnimatorStateInfo animatorStateInfo = andSeekDeathPopup.animator.GetCurrentAnimatorStateInfo(0);
if ((animatorStateInfo).IsName("Show"))
if (animatorStateInfo.IsName("Show"))
{
if (doNeedReduceSpeed && DateTime.UtcNow.Subtract(startTime).TotalSeconds >= 0.5)
{
Expand Down Expand Up @@ -836,9 +836,8 @@ public static float sabotageTimer()
public static bool canUseSabotage()
{
var sabSystem = ShipStatus.Instance.Systems[SystemTypes.Sabotage].CastFast<SabotageSystemType>();
ISystemType systemType;
IActivatable doors = null;
if (ShipStatus.Instance.Systems.TryGetValue(SystemTypes.Doors, out systemType))
if (ShipStatus.Instance.Systems.TryGetValue(SystemTypes.Doors, out ISystemType systemType))
{
doors = systemType.CastFast<IActivatable>();
}
Expand Down Expand Up @@ -950,7 +949,7 @@ public static bool hidePlayerName(PlayerControl source, PlayerControl target) {
else if (!TORMapOptions.hidePlayerNames) return false; // All names are visible
else if (source == null || target == null) return true;
else if (source == target) return false; // Player sees his own name
else if (source.Data.Role.IsImpostor && (target.Data.Role.IsImpostor || target == Spy.spy || target == Sidekick.sidekick && Sidekick.wasTeamRed || target == Jackal.jackal && Jackal.wasTeamRed)) return false; // Members of team Impostors see the names of Impostors/Spies
else if (source.Data.Role.IsImpostor && (target.Data.Role.IsImpostor || target == Spy.spy || (target == Sidekick.sidekick && Sidekick.wasTeamRed) || (target == Jackal.jackal && Jackal.wasTeamRed))) return false; // Members of team Impostors see the names of Impostors/Spies
else if ((source == Lovers.lover1 || source == Lovers.lover2) && (target == Lovers.lover1 || target == Lovers.lover2)) return false; // Members of team Lovers see the names of each other
else if ((source == Jackal.jackal || source == Sidekick.sidekick) && (target == Jackal.jackal || target == Sidekick.sidekick || target == Jackal.fakeSidekick)) return false; // Members of team Jackal see the names of each other
else if (Deputy.knowsSheriff && (source == Sheriff.sheriff || source == Deputy.deputy) && (target == Sheriff.sheriff || target == Deputy.deputy)) return false; // Sheriff & Deputy see the names of each other
Expand Down Expand Up @@ -1197,7 +1196,7 @@ public static PlainShipRoom getPlainShipRoom(PlayerControl p)
{
PlainShipRoom[] array = null;
Il2CppReferenceArray<Collider2D> buffer = new Collider2D[10];
ContactFilter2D filter = default(ContactFilter2D);
ContactFilter2D filter = default;
filter.layerMask = Constants.PlayersOnlyMask;
filter.useLayerMask = true;
filter.useTriggers = false;
Expand Down Expand Up @@ -1537,7 +1536,7 @@ public static async Task checkBeta() {

public static bool hasImpVision(NetworkedPlayerInfo player) {
return player.Role.IsImpostor
|| ((Jackal.jackal != null && Jackal.jackal.PlayerId == player.PlayerId || Jackal.formerJackals.Any(x => x.PlayerId == player.PlayerId)) && Jackal.hasImpostorVision)
|| (((Jackal.jackal != null && Jackal.jackal.PlayerId == player.PlayerId) || Jackal.formerJackals.Any(x => x.PlayerId == player.PlayerId)) && Jackal.hasImpostorVision)
|| (Sidekick.sidekick != null && Sidekick.sidekick.PlayerId == player.PlayerId && Sidekick.hasImpostorVision)
|| (Spy.spy != null && Spy.spy.PlayerId == player.PlayerId && Spy.hasImpostorVision)
|| (Jester.jester != null && Jester.jester.PlayerId == player.PlayerId && Jester.hasImpostorVision)
Expand Down
6 changes: 6 additions & 0 deletions TheOtherRoles/MapOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,11 @@ public static void reloadPluginOptions() {
ShowChatNotifications = TheOtherRolesPlugin.ShowChatNotifications.Value;
//Patches.ShouldAlwaysHorseAround.isHorseMode = TheOtherRolesPlugin.EnableHorseMode.Value;
}

public static void resetPoolables() {
foreach (PoolablePlayer p in playerIcons.Values) {
if (p != null && p.gameObject != null) p.gameObject.SetActive(false);
}
}
}
}
Loading

0 comments on commit b2227bc

Please sign in to comment.