forked from slushiegoose/Town-Of-Us
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into HEAD
- Loading branch information
Showing
18 changed files
with
281 additions
and
14 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
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,18 @@ | ||
using HarmonyLib; | ||
using TownOfUs.Roles; | ||
|
||
namespace TownOfUs.Patches.CrewmateRoles.LighterMod | ||
{ | ||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] | ||
public class LighterUpdate | ||
{ | ||
public static void Postfix(HudManager __instance) | ||
{ | ||
foreach (var role in Role.GetRoles(RoleEnum.Lighter)) | ||
{ | ||
Lighter lighter = (Lighter) role; | ||
lighter.LightTick(); | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
source/Patches/CrewmateRoles/LighterMod/ManageLighterButton.cs
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 TownOfUs.Roles; | ||
using UnityEngine; | ||
|
||
namespace TownOfUs.Patches.CrewmateRoles.LighterMod | ||
{ | ||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] | ||
public class ManageLighterButton | ||
{ | ||
private static Sprite Sprite => TownOfUs.LighterSprite; | ||
|
||
public static void Postfix(HudManager __instance) | ||
{ | ||
if ( | ||
PlayerControl.AllPlayerControls.Count <= 1 | ||
|| PlayerControl.LocalPlayer == null | ||
|| PlayerControl.LocalPlayer.Data == null | ||
|| !PlayerControl.LocalPlayer.Is(RoleEnum.Lighter) | ||
) | ||
{ | ||
return; | ||
} | ||
|
||
Lighter role = Role.GetRole<Lighter>(PlayerControl.LocalPlayer); | ||
|
||
if (role.LighterButton == null) | ||
{ | ||
role.LighterButton = Object.Instantiate(__instance.KillButton, HudManager.Instance.transform); | ||
role.LighterButton.graphic.enabled = true; | ||
} | ||
|
||
role.LighterButton.graphic.sprite = Sprite; | ||
role.LighterButton.gameObject.SetActive(!PlayerControl.LocalPlayer.Data.IsDead && !MeetingHud.Instance); | ||
|
||
if (role.IsLighting) | ||
{ | ||
role.LighterButton.SetCoolDown(role.LighterTimeRemaining, CustomGameOptions.LighterDuration); | ||
return; | ||
} | ||
|
||
role.LighterButton.SetCoolDown(role.CooldownTimer(), CustomGameOptions.LighterCooldown); | ||
role.LighterButton.graphic.color = Palette.EnabledColor; | ||
role.LighterButton.graphic.material.SetFloat("_Desat", 0f); | ||
} | ||
} | ||
} |
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,49 @@ | ||
using HarmonyLib; | ||
using Hazel; | ||
using TownOfUs.Roles; | ||
|
||
namespace TownOfUs.Patches.CrewmateRoles.LighterMod | ||
{ | ||
[HarmonyPatch(typeof(KillButton), nameof(KillButton.DoClick))] | ||
public class PerformKill | ||
{ | ||
public static bool Prefix(KillButton __instance) | ||
{ | ||
if (!PlayerControl.LocalPlayer.Is(RoleEnum.Lighter)) | ||
{ | ||
return true; | ||
} | ||
|
||
if ( | ||
!PlayerControl.LocalPlayer.CanMove | ||
|| PlayerControl.LocalPlayer.Data.IsDead | ||
) | ||
{ | ||
return false; | ||
} | ||
|
||
Lighter role = Role.GetRole<Lighter>(PlayerControl.LocalPlayer); | ||
if (__instance != role.LighterButton) | ||
{ | ||
return true; | ||
} | ||
|
||
if ( | ||
__instance.isCoolingDown | ||
|| !__instance.isActiveAndEnabled | ||
|| role.CooldownTimer() != 0 | ||
) | ||
{ | ||
return false; | ||
} | ||
|
||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, | ||
(byte) CustomRPC.LighterOn, SendOption.Reliable, -1); | ||
writer.Write(PlayerControl.LocalPlayer.PlayerId); | ||
AmongUsClient.Instance.FinishRpcImmediately(writer); | ||
|
||
role.LightOn(); | ||
return false; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using HarmonyLib; | ||
using Hazel; | ||
using Reactor; | ||
using TownOfUs.Extensions; | ||
using TownOfUs.Roles; | ||
|
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
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.