Skip to content

Commit

Permalink
Update v1.1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Feb 6, 2025
1 parent b42d696 commit 75ba66f
Show file tree
Hide file tree
Showing 33 changed files with 532 additions and 383 deletions.
15 changes: 11 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
v1.1.2.1更新日志
v1.1.2.2更新日志

* 修复掷弹兵使用技能时可能会导致所有玩家游戏卡死的问题
* 怨灵: 新增选项 "拾取尸体后本轮会议结束才可复活"
* 还有其它一些小优化
* 优化游戏选项中常规选项的页面排版显示
* 律师的目标如果掉线则律师会变成起诉人

问题修复:

* 炸弹狂、纵火狂技能无法寻到目标
* 怨灵会被分配到豺狼阵营
* 非红狼阵营的职业无法使用键盘进入通风口
* 污点证人在部分情况下无法得分
* 鹈鹕被击杀时会卡在原地
Binary file modified Strings.xlsx
Binary file not shown.
15 changes: 8 additions & 7 deletions TheOtherRoles/Buttons/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static void resetTimeMasterButton()
SoundEffectsManager.stop("timemasterShield");
}

public static PlayerControl SetTarget(IEnumerable<PlayerControl> untarget = null, bool onlyCrewmates = false,
public static PlayerControl SetTarget(List<PlayerControl> untarget = null, bool onlyCrewmates = false,
bool targetInVents = false, float distances = 0f, PlayerControl targetingPlayer = null)
{
return PlayerControlFixedUpdatePatch.SetTarget(onlyCrewmates, targetInVents, untarget, KillDistances: distances, targetingPlayer: targetingPlayer);
Expand Down Expand Up @@ -586,33 +586,33 @@ public static void createButtonsPostfix(HudManager __instance)
if (murderAttemptResult == MurderAttemptResult.PerformKill)
{
byte targetId = 0;

var DeathReason = CustomDeathReason.SheriffKill;
if (Sheriff.sheriffCanKillNeutral(target))
{
targetId = target.PlayerId;
GameHistory.RpcOverrideDeathReasonAndKiller(target, CustomDeathReason.SheriffKill, PlayerControl.LocalPlayer);
}
else
{
switch (Sheriff.misfireKills)
{
case 0:
targetId = PlayerControl.LocalPlayer.PlayerId;
GameHistory.RpcOverrideDeathReasonAndKiller(PlayerControl.LocalPlayer, CustomDeathReason.SheriffMisfire, PlayerControl.LocalPlayer);
DeathReason = CustomDeathReason.SheriffMisfire;
break;
case 1:
targetId = target.PlayerId;
GameHistory.RpcOverrideDeathReasonAndKiller(target, CustomDeathReason.SheriffMisadventure, PlayerControl.LocalPlayer);
DeathReason = CustomDeathReason.SheriffMisadventure;
break;
case 2:
targetId = target.PlayerId;
DeathReason = CustomDeathReason.SheriffMisadventure;

var killWriter2 = StartRPC(PlayerControl.LocalPlayer.NetId, CustomRPC.UncheckedMurderPlayer);
killWriter2.Write(PlayerControl.LocalPlayer.PlayerId);
killWriter2.Write(PlayerControl.LocalPlayer.PlayerId);
killWriter2.Write(byte.MaxValue);
killWriter2.EndRPC();
RPCProcedure.uncheckedMurderPlayer(PlayerControl.LocalPlayer.PlayerId, PlayerControl.LocalPlayer.PlayerId, byte.MaxValue);
GameHistory.RpcOverrideDeathReasonAndKiller(target, CustomDeathReason.SheriffMisadventure, PlayerControl.LocalPlayer);
GameHistory.RpcOverrideDeathReasonAndKiller(PlayerControl.LocalPlayer, CustomDeathReason.SheriffMisfire, PlayerControl.LocalPlayer);
break;
}
Expand All @@ -624,6 +624,7 @@ public static void createButtonsPostfix(HudManager __instance)
killWriter.Write(byte.MaxValue);
killWriter.EndRPC();
RPCProcedure.uncheckedMurderPlayer(PlayerControl.LocalPlayer.PlayerId, targetId, byte.MaxValue);
GameHistory.RpcOverrideDeathReasonAndKiller(target, DeathReason, PlayerControl.LocalPlayer);
}

if (murderAttemptResult == MurderAttemptResult.BodyGuardKill) checkMurderAttemptAndKill(PlayerControl.LocalPlayer, target);
Expand Down Expand Up @@ -2264,7 +2265,7 @@ public static void createButtonsPostfix(HudManager __instance)
() =>
{
/* On Click */
Bomber.currentBombTarget = SetTarget();
Bomber.currentTarget = SetTarget();
if (Bomber.hasBombPlayer == null) SetPlayerOutline(Bomber.currentTarget, Bomber.color);
return Bomber.currentTarget && PlayerControl.LocalPlayer.CanMove;
},
Expand Down
6 changes: 3 additions & 3 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public static bool checkAndDoVetKill(PlayerControl target)
return shouldVetKill;
}

public static bool isNeutral(PlayerControl player)
public static bool isNeutral(this PlayerControl player)
{
var roleInfo = RoleInfo.getRoleInfoForPlayer(player, false).FirstOrDefault();
return roleInfo != null && roleInfo.roleType == RoleType.Neutral;
Expand All @@ -257,8 +257,8 @@ public static bool isKillerNeutral(PlayerControl player)
player == Pelican.Player ||
player == Jackal.Sidekick ||
player == Pavlovsdogs.pavlovsowner ||
Jackal.jackal.Contains(player) ||
Pavlovsdogs.pavlovsdogs.Contains(player));
Jackal.jackal.Any(x => x.PlayerId == player.PlayerId) ||
Pavlovsdogs.pavlovsdogs.Any(x => x.PlayerId == player.PlayerId));
}

public static bool isEvilNeutral(PlayerControl player)
Expand Down
25 changes: 25 additions & 0 deletions TheOtherRoles/Helper/ObjectHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using TMPro;
using UnityEngine;

namespace TheOtherRoles.Helper;

public static class ObjectHelper
{
/// <summary>
/// オブジェクトの<see cref="TextTranslatorTMP"/>コンポーネントを破棄します
/// </summary>
public static void DestroyTranslator(this GameObject obj)
{
if (obj == null) return;
obj.ForEachChild((Il2CppSystem.Action<GameObject>)DestroyTranslator);
TextTranslatorTMP[] translator = obj.GetComponentsInChildren<TextTranslatorTMP>(true);
translator?.Do(Object.Destroy);
}
/// <summary>
/// オブジェクトの<see cref="TextTranslatorTMP"/>コンポーネントを破棄します
/// </summary>
public static void DestroyTranslatorL(this MonoBehaviour obj) => obj?.gameObject?.DestroyTranslator();

public static void SetActive(this Transform tf, bool b) => tf.gameObject.SetActive(b);
public static void SetActive(this TextMeshPro tf, bool b) => tf.gameObject.SetActive(b);
}
3 changes: 1 addition & 2 deletions TheOtherRoles/Modules/Debugger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static TheOtherRoles.Options.ModOption;
using static TheOtherRoles.Options.ModOption;

namespace TheOtherRoles.Modules;

Expand Down Expand Up @@ -34,5 +34,4 @@ public static void Postfix(EndGameNavigation __instance)
__instance.NextGame();
}
}

}
7 changes: 7 additions & 0 deletions TheOtherRoles/Modules/KeyboardHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ 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
95 changes: 95 additions & 0 deletions TheOtherRoles/Modules/SimpleButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using TMPro;
using UnityEngine;
using Object = UnityEngine.Object;

namespace TheOtherRoles.Modules;

public class SimpleButton
{
/// <summary>新しいボタンを作成する</summary>
/// <param name="parent">親オブジェクト</param>
/// <param name="name">オブジェクト名</param>
/// <param name="normalColor">通常時の背景色</param>
/// <param name="hoverColor">マウスホバー時の背景色</param>
/// <param name="action">クリック時に発火するアクション</param>
/// <param name="label">ボタンのラベル</param>
/// <param name="scale">ボタンの大きさ</param>
/// <param name="isActive">初期状態でアクティブにするかどうか(デフォルトtrue)</param>
public SimpleButton(
Transform parent,
string name,
Vector3 localPosition,
Color32 normalColor,
Color32 hoverColor,
Action action,
string label,
bool isActive = true)
{
if (baseButton == null)
throw new InvalidOperationException("baseButtonが未設定");

Button = Object.Instantiate(baseButton, parent);
Label = Button.transform.Find("FontPlacer/Text_TMP").GetComponent<TextMeshPro>();
NormalSprite = Button.inactiveSprites.GetComponent<SpriteRenderer>();
HoverSprite = Button.activeSprites.GetComponent<SpriteRenderer>();
buttonCollider = Button.GetComponent<BoxCollider2D>();

// ラベルをセンタリング
var container = Label.transform.parent;
Object.Destroy(Label.GetComponent<AspectPosition>());
container.SetLocalX(0f);
Label.transform.SetLocalX(0f);
Label.horizontalAlignment = HorizontalAlignmentOptions.Center;

Button.name = name;
Button.transform.localPosition = localPosition;
NormalSprite.color = normalColor;
HoverSprite.color = hoverColor;
Button.OnClick.AddListener(action);
Label.text = label;
Button.gameObject.SetActive(isActive);
}
public PassiveButton Button { get; }
public TextMeshPro Label { get; }
public SpriteRenderer NormalSprite { get; }
public SpriteRenderer HoverSprite { get; }
private readonly BoxCollider2D buttonCollider;
private Vector2 _scale;
public Vector2 Scale
{
get => _scale;
set => _scale = NormalSprite.size = HoverSprite.size = buttonCollider.size = value;
}
private float _fontSize;
public float FontSize
{
get => _fontSize;
set => _fontSize = Label.fontSize = Label.fontSizeMin = Label.fontSizeMax = value;
}

private static PassiveButton baseButton;
public static void SetBase(PassiveButton passiveButton)
{
if (baseButton != null || passiveButton == null)
return;
// 複製
baseButton = Object.Instantiate(passiveButton);
var label = baseButton.transform.Find("FontPlacer/Text_TMP").GetComponent<TextMeshPro>();
baseButton.gameObject.SetActive(false);
// シーン切替時に破棄されないようにする
Object.DontDestroyOnLoad(baseButton);
baseButton.name = "YuET_SimpleButtonBase";
// 不要なコンポーネントを無効化
Object.Destroy(baseButton.GetComponent<AspectPosition>());
label.DestroyTranslatorL();
label.fontSize = label.fontSizeMax = label.fontSizeMin = 3.5f;
label.enableWordWrapping = false;
label.text = "YuET SIMPLE BUTTON BASE";
// 当たり判定がズレてるのを直す
var buttonCollider = baseButton.GetComponent<BoxCollider2D>();
buttonCollider.offset = new(0f, 0f);
baseButton.OnClick = new();
}
public static bool IsNullOrDestroyed(SimpleButton button) => button == null || button.Button == null;
}
3 changes: 1 addition & 2 deletions TheOtherRoles/Objects/Trap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static void Update()
target = trap;
}
}
if (target != null && player.PlayerId != Trapper.trapper.PlayerId && !player.Data.IsDead)
if (target?.revealed == false && player.PlayerId != Trapper.trapper.PlayerId && player.IsAlive())
{
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
(byte)CustomRPC.TriggerTrap, SendOption.Reliable, -1);
Expand All @@ -167,7 +167,6 @@ public static void Update()
RPCProcedure.triggerTrap(player.PlayerId, (byte)target.instanceId);
}


if (!player.Data.IsDead || player.PlayerId == Trapper.trapper.PlayerId) return;
foreach (var trap in traps.Where(trap => !trap.trap.active))
trap.trap.SetActive(true);
Expand Down
Loading

0 comments on commit 75ba66f

Please sign in to comment.