Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work/merge5.1.6 #49

Merged
merged 11 commits into from
Mar 23, 2024
2 changes: 1 addition & 1 deletion Modules/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public bool CanUseMovingPlatform
}
public (DateTime, byte) RealKiller;
public PlainShipRoom LastRoom;
/// <summary>会議等の後に湧いた後かどうか</summary>
/// <summary>会議等の後に湧いた後かどうか<br/>ホスト以外は正しい値にならないので注意</summary>
public bool HasSpawned { get; set; } = false;
public Dictionary<byte, string> TargetColorData;
public PlayerState(byte playerId)
Expand Down
67 changes: 34 additions & 33 deletions Patches/PlayerContorolPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,52 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC
__instance.RpcRejectShapeshift();
return false;
}
var shapeshifter = __instance;
var shapeshifting = shapeshifter.PlayerId != target.PlayerId;
// 変身したとき一番近い人をマッドメイトにする処理
if (shapeshifter.CanMakeMadmate() && shapeshifting)
{
var sidekickable = shapeshifter.GetRoleClass() as ISidekickable;
var targetRole = sidekickable?.SidekickTargetRole ?? CustomRoles.SKMadmate;

Vector2 shapeshifterPosition = shapeshifter.transform.position;//変身者の位置
Dictionary<PlayerControl, float> mpdistance = new();
float dis;
foreach (var p in Main.AllAlivePlayerControls)
{
if (p.Data.Role.Role != RoleTypes.Shapeshifter && !p.Is(CustomRoleTypes.Impostor) && !p.Is(targetRole))
{
dis = Vector2.Distance(shapeshifterPosition, p.transform.position);
mpdistance.Add(p, dis);
}
}
if (mpdistance.Count != 0)
{
var min = mpdistance.OrderBy(c => c.Value).FirstOrDefault();//一番値が小さい
PlayerControl targetm = min.Key;
targetm.RpcSetCustomRole(targetRole);
Logger.Info($"Make SKMadmate:{targetm.name}", "Shapeshift");
Main.SKMadmateNowCount++;
Utils.MarkEveryoneDirtySettings();
Utils.NotifyRoles();
}
}
// 役職の処理
var role = __instance.GetRoleClass();
var role = shapeshifter.GetRoleClass();
if (role?.OnCheckShapeshift(target, ref shouldAnimate) == false)
{
if (role.CanDesyncShapeshift)
{
__instance.RpcSpecificRejectShapeshift(target, shouldAnimate);
shapeshifter.RpcSpecificRejectShapeshift(target, shouldAnimate);
}
else
{
__instance.RpcRejectShapeshift();
shapeshifter.RpcRejectShapeshift();
}
return false;
}

__instance.RpcShapeshift(target, shouldAnimate);
shapeshifter.RpcShapeshift(target, shouldAnimate);
return false;
}
private static bool CheckInvalidShapeshifting(PlayerControl instance, PlayerControl target, bool animate)
Expand Down Expand Up @@ -289,35 +319,6 @@ public static void Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC

if (!shapeshifting) Camouflage.RpcSetSkin(__instance);

// 変身したとき一番近い人をマッドメイトにする処理
if (shapeshifter.CanMakeMadmate() && shapeshifting)
{
var sidekickable = shapeshifter.GetRoleClass() as ISidekickable;
var targetRole = sidekickable?.SidekickTargetRole ?? CustomRoles.SKMadmate;

Vector2 shapeshifterPosition = shapeshifter.transform.position;//変身者の位置
Dictionary<PlayerControl, float> mpdistance = new();
float dis;
foreach (var p in Main.AllAlivePlayerControls)
{
if (p.Data.Role.Role != RoleTypes.Shapeshifter && !p.Is(CustomRoleTypes.Impostor) && !p.Is(targetRole))
{
dis = Vector2.Distance(shapeshifterPosition, p.transform.position);
mpdistance.Add(p, dis);
}
}
if (mpdistance.Count != 0)
{
var min = mpdistance.OrderBy(c => c.Value).FirstOrDefault();//一番値が小さい
PlayerControl targetm = min.Key;
targetm.RpcSetCustomRole(targetRole);
Logger.Info($"Make SKMadmate:{targetm.name}", "Shapeshift");
Main.SKMadmateNowCount++;
Utils.MarkEveryoneDirtySettings();
Utils.NotifyRoles();
}
}

//変身解除のタイミングがずれて名前が直せなかった時のために強制書き換え
if (!shapeshifting)
{
Expand Down
4 changes: 2 additions & 2 deletions main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public class Main : BasePlugin
public static readonly Version ParsedForkVersion = Version.Parse(ForkVersion);

public const string PluginGuid = "com.emptybottle.townofhost";
public const string PluginVersion = "5.1.5";
public const string PluginVersion = "5.1.6";
// サポートされている最低のAmongUsバージョン
public static readonly string LowestSupportedVersion = "2023.10.24";
public static readonly string LowestSupportedVersion = "2024.3.5";
// このバージョンのみで公開ルームを無効にする場合
public static readonly bool IsPublicAvailableOnThisVersion = false;
public Harmony Harmony { get; } = new Harmony(PluginGuid);
Expand Down