forked from slushiegoose/Town-Of-Us
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1da29f6
commit 4528c3f
Showing
52 changed files
with
1,092 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using HarmonyLib; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using System; | ||
using Object = UnityEngine.Object; | ||
using TownOfUs.NeutralRoles.PhantomMod; | ||
using TownOfUs.CrewmateRoles.HaunterMod; | ||
|
||
namespace TownOfUs.Patches | ||
{ | ||
[HarmonyPatch(typeof(AirshipExileController), nameof(AirshipExileController.WrapUpAndSpawn))] | ||
public static class AirshipAddHauntPatch | ||
{ | ||
public static void Postfix(AirshipExileController __instance) => AddHauntPatch.ExileControllerPostfix(__instance); | ||
} | ||
|
||
[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))] | ||
[HarmonyPriority(Priority.First)] | ||
class AddHauntPatch | ||
{ | ||
public static List<PlayerControl> AssassinatedPlayers = new List<PlayerControl>(); | ||
|
||
public static void ExileControllerPostfix(ExileController __instance) | ||
{ | ||
foreach (var player in AssassinatedPlayers) | ||
{ | ||
try | ||
{ | ||
if (SetPhantom.WillBePhantom != player && SetHaunter.WillBeHaunter != player | ||
&& !player.Data.Disconnected) player.Exiled(); | ||
} | ||
catch { } | ||
} | ||
AssassinatedPlayers.Clear(); | ||
} | ||
|
||
public static void Postfix(ExileController __instance) => ExileControllerPostfix(__instance); | ||
|
||
[HarmonyPatch(typeof(Object), nameof(Object.Destroy), new Type[] { typeof(GameObject) })] | ||
public static void Prefix(GameObject obj) | ||
{ | ||
if (!SubmergedCompatibility.Loaded || GameOptionsManager.Instance.currentNormalGameOptions.MapId != 5) return; | ||
if (obj.name.Contains("ExileCutscene")) ExileControllerPostfix(ExileControllerPatch.lastExiled); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using HarmonyLib; | ||
using System.Linq; | ||
using Hazel; | ||
using UnityEngine; | ||
|
||
namespace TownOfUs.CrewmateRoles.HaunterMod | ||
{ | ||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] | ||
public class RepickHaunter | ||
{ | ||
private static void Postfix(HudManager __instance) | ||
{ | ||
if (PlayerControl.AllPlayerControls.Count <= 1) return; | ||
if (PlayerControl.LocalPlayer == null) return; | ||
if (PlayerControl.LocalPlayer.Data == null) return; | ||
if (PlayerControl.LocalPlayer != SetHaunter.WillBeHaunter) return; | ||
if (PlayerControl.LocalPlayer.Data.IsDead) return; | ||
var toChooseFrom = PlayerControl.AllPlayerControls.ToArray().Where(x => x.Is(Faction.Crewmates) && !x.Is(ModifierEnum.Lover) && x.Data.IsDead && !x.Data.Disconnected).ToList(); | ||
if (toChooseFrom.Count == 0) return; | ||
var rand = Random.RandomRangeInt(0, toChooseFrom.Count); | ||
var pc = toChooseFrom[rand]; | ||
|
||
SetHaunter.WillBeHaunter = pc; | ||
|
||
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, | ||
(byte)CustomRPC.SetHaunter, SendOption.Reliable, -1); | ||
writer.Write(pc.PlayerId); | ||
AmongUsClient.Instance.FinishRpcImmediately(writer); | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System; | ||
using HarmonyLib; | ||
using Hazel; | ||
using TownOfUs.Roles; | ||
using UnityEngine; | ||
using Object = UnityEngine.Object; | ||
using Random = UnityEngine.Random; | ||
using TownOfUs.Patches; | ||
|
||
namespace TownOfUs.CrewmateRoles.HaunterMod | ||
{ | ||
[HarmonyPatch(typeof(AirshipExileController), nameof(AirshipExileController.WrapUpAndSpawn))] | ||
public static class AirshipExileController_WrapUpAndSpawn | ||
{ | ||
public static void Postfix(AirshipExileController __instance) => SetHaunter.ExileControllerPostfix(__instance); | ||
} | ||
|
||
[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))] | ||
public class SetHaunter | ||
{ | ||
public static PlayerControl WillBeHaunter; | ||
public static Vector2 StartPosition; | ||
|
||
public static void ExileControllerPostfix(ExileController __instance) | ||
{ | ||
if (WillBeHaunter == null) return; | ||
var exiled = __instance.exiled?.Object; | ||
if (!WillBeHaunter.Data.IsDead && exiled.Is(Faction.Crewmates) && !exiled.IsLover()) WillBeHaunter = exiled; | ||
if (WillBeHaunter.Data.Disconnected) return; | ||
if (!WillBeHaunter.Data.IsDead && WillBeHaunter != exiled) return; | ||
|
||
if (!WillBeHaunter.Is(RoleEnum.Haunter)) | ||
{ | ||
var oldRole = Role.GetRole(WillBeHaunter); | ||
var killsList = (oldRole.CorrectKills, oldRole.IncorrectKills, oldRole.CorrectAssassinKills, oldRole.IncorrectAssassinKills); | ||
Role.RoleDictionary.Remove(WillBeHaunter.PlayerId); | ||
if (PlayerControl.LocalPlayer == WillBeHaunter) | ||
{ | ||
var role = new Haunter(PlayerControl.LocalPlayer); | ||
role.formerRole = oldRole.RoleType; | ||
role.CorrectKills = killsList.CorrectKills; | ||
role.IncorrectKills = killsList.IncorrectKills; | ||
role.CorrectAssassinKills = killsList.CorrectAssassinKills; | ||
role.IncorrectAssassinKills = killsList.IncorrectAssassinKills; | ||
role.RegenTask(); | ||
} | ||
else | ||
{ | ||
var role = new Haunter(WillBeHaunter); | ||
role.formerRole = oldRole.RoleType; | ||
role.CorrectKills = killsList.CorrectKills; | ||
role.IncorrectKills = killsList.IncorrectKills; | ||
role.CorrectAssassinKills = killsList.CorrectAssassinKills; | ||
role.IncorrectAssassinKills = killsList.IncorrectAssassinKills; | ||
} | ||
|
||
Utils.RemoveTasks(WillBeHaunter); | ||
if (!PlayerControl.LocalPlayer.Is(RoleEnum.Phantom)) WillBeHaunter.MyPhysics.ResetMoveState(); | ||
|
||
WillBeHaunter.gameObject.layer = LayerMask.NameToLayer("Players"); | ||
} | ||
|
||
if (PlayerControl.LocalPlayer != WillBeHaunter) return; | ||
|
||
if (Role.GetRole<Haunter>(PlayerControl.LocalPlayer).Caught) return; | ||
var startingVent = | ||
ShipStatus.Instance.AllVents[Random.RandomRangeInt(0, ShipStatus.Instance.AllVents.Count)]; | ||
|
||
var writer2 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, | ||
(byte)CustomRPC.SetPos, SendOption.Reliable, -1); | ||
writer2.Write(PlayerControl.LocalPlayer.PlayerId); | ||
writer2.Write(startingVent.transform.position.x); | ||
writer2.Write(startingVent.transform.position.y + 0.3636f); | ||
AmongUsClient.Instance.FinishRpcImmediately(writer2); | ||
|
||
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(new Vector2(startingVent.transform.position.x, startingVent.transform.position.y + 0.3636f)); | ||
PlayerControl.LocalPlayer.MyPhysics.RpcEnterVent(startingVent.Id); | ||
} | ||
|
||
public static void Postfix(ExileController __instance) => ExileControllerPostfix(__instance); | ||
|
||
[HarmonyPatch(typeof(Object), nameof(Object.Destroy), new Type[] { typeof(GameObject) })] | ||
public static void Prefix(GameObject obj) | ||
{ | ||
if (!SubmergedCompatibility.Loaded || GameOptionsManager.Instance.currentNormalGameOptions.MapId != 5) return; | ||
if (obj.name.Contains("ExileCutscene")) ExileControllerPostfix(ExileControllerPatch.lastExiled); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.