mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
fix inlined patch
This commit is contained in:
1 parent
f0afd36b96
commit
afbfd24806
5 files changed
+25
-31
No files matched your search
@@ -2359,6 +2359,12 @@ internal static class EnterVentPatch
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.CompleteTask))]
|
||||
internal static class GameDataCompleteTaskPatch
|
||||
{
|
||||
public static void Prefix(PlayerControl pc)
|
||||
{
|
||||
Workhorse.OnCompleteTask(pc);
|
||||
Capitalist.AddTaskForPlayer(pc);
|
||||
}
|
||||
|
||||
public static void Postfix(PlayerControl pc, uint taskId)
|
||||
{
|
||||
if (MeetingHud.Instance && MeetingHud.Instance.state != MeetingHud.VoteStates.Animating) return;
|
||||
@@ -2368,6 +2374,16 @@ internal static class GameDataCompleteTaskPatch
|
||||
var task = pc.myTasks.Find((Il2CppSystem.Predicate<PlayerTask>)(x => taskId == x.Id));
|
||||
Hider.OnSpecificTaskComplete(pc, task);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (pc.IsAlive())
|
||||
{
|
||||
var task = pc.myTasks.Find((Il2CppSystem.Predicate<PlayerTask>)(x => taskId == x.Id));
|
||||
Benefactor.OnTaskComplete(pc, task);
|
||||
}
|
||||
}
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
|
||||
Logger.Info($"TaskComplete: {pc.GetNameWithRole().RemoveHtmlTags()}", "CompleteTask");
|
||||
Main.PlayerStates[pc.PlayerId].UpdateTask(pc);
|
||||
@@ -2375,30 +2391,6 @@ internal static class GameDataCompleteTaskPatch
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CompleteTask))]
|
||||
internal static class PlayerControlCompleteTaskPatch
|
||||
{
|
||||
public static bool Prefix(PlayerControl __instance)
|
||||
{
|
||||
if (MeetingHud.Instance && MeetingHud.Instance.state != MeetingHud.VoteStates.Animating) return false;
|
||||
return !Workhorse.OnCompleteTask(__instance) && Capitalist.AddTaskForPlayer(__instance); // Cancel task win
|
||||
}
|
||||
|
||||
public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] uint idx)
|
||||
{
|
||||
if (GameStates.IsMeeting || !__instance || !__instance.IsAlive()) return;
|
||||
|
||||
Snitch.OnCompleteTask(__instance);
|
||||
|
||||
try
|
||||
{
|
||||
var task = __instance.myTasks.Find((Il2CppSystem.Predicate<PlayerTask>)(x => idx == x.Id));
|
||||
Benefactor.OnTaskComplete(__instance, task);
|
||||
}
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameManager), nameof(GameManager.OnPlayerDeath))]
|
||||
static class GameManagerOnPlayerDeathPatch
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ internal class CustomTaskCountsPatch
|
||||
|
||||
foreach (NetworkedPlayerInfo p in __instance.AllPlayers)
|
||||
{
|
||||
if (p == null) continue;
|
||||
if (!p) continue;
|
||||
|
||||
bool hasTasks = Utils.HasTasks(p) && Main.PlayerStates[p.PlayerId].TaskState.AllTasksCount > 0;
|
||||
|
||||
|
||||
@@ -99,8 +99,9 @@ public class Workhorse : IAddon
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
Add(pc.PlayerId);
|
||||
pc.RpcResetTasks();
|
||||
pc.RpcResetTasks(false);
|
||||
pc.SyncSettings();
|
||||
Main.PlayerStates[pc.PlayerId].TaskState.AllTasksCount = pc.Data.Tasks.Count;
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class Snitch : RoleBase
|
||||
|
||||
public static string GetWarningArrow(PlayerControl seer, PlayerControl target = null)
|
||||
{
|
||||
if (GameStates.IsMeeting || !IsSnitchTarget(seer) || (target != null && seer.PlayerId != target.PlayerId)) return string.Empty;
|
||||
if (GameStates.IsMeeting || !IsSnitchTarget(seer) || (target && seer.PlayerId != target.PlayerId)) return string.Empty;
|
||||
|
||||
IEnumerable<byte> exposedSnitch = PlayerIdList.Where(s => !Main.PlayerStates[s].IsDead && IsExposed[s]);
|
||||
byte[] snitch = exposedSnitch as byte[] ?? exposedSnitch.ToArray();
|
||||
@@ -168,7 +168,7 @@ public class Snitch : RoleBase
|
||||
|
||||
public override string GetSuffix(PlayerControl seer, PlayerControl target, bool hud = false, bool meeting = false)
|
||||
{
|
||||
if (seer.Is(CustomRoles.Madmate) || !EnableTargetArrow || GameStates.IsMeeting || seer.PlayerId != SnitchId || (target != null && seer.PlayerId != target.PlayerId) || hud) return string.Empty;
|
||||
if (seer.Is(CustomRoles.Madmate) || !EnableTargetArrow || GameStates.IsMeeting || seer.PlayerId != SnitchId || seer.PlayerId != target.PlayerId || hud) return string.Empty;
|
||||
|
||||
var arrows = string.Empty;
|
||||
|
||||
@@ -181,10 +181,10 @@ public class Snitch : RoleBase
|
||||
return arrows;
|
||||
}
|
||||
|
||||
public static void OnCompleteTask(PlayerControl player)
|
||||
public override void OnTaskComplete(PlayerControl pc, int completedTaskCount, int totalTaskCount)
|
||||
{
|
||||
if (!IsSnitch(player.PlayerId) || player.Is(CustomRoles.Madmate)) return;
|
||||
if (!IsSnitch(pc.PlayerId) || pc.Is(CustomRoles.Madmate)) return;
|
||||
|
||||
CheckTask(player);
|
||||
CheckTask(pc);
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ internal class Capitalist : RoleBase
|
||||
taskState.CompletedTasksCount++;
|
||||
player.RpcResetTasks(false);
|
||||
player.SyncSettings();
|
||||
Main.PlayerStates[player.PlayerId].TaskState.AllTasksCount = player.Data.Tasks.Count;
|
||||
Utils.NotifyRoles(SpecifySeer: player, SpecifyTarget: player);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user