예제 #1
0
        public static bool Prefix(KillButtonManager __instance)
        {
            if (!PlayerControl.LocalPlayer.Is(RoleEnum.Concealer))
            {
                return(true);
            }

            if (
                !PlayerControl.LocalPlayer.CanMove ||
                PlayerControl.LocalPlayer.Data.IsDead
                )
            {
                return(false);
            }

            Concealer role = Role.GetRole <Concealer>(PlayerControl.LocalPlayer);

            if (__instance != role.ConcealButton)
            {
                return(true);
            }

            if (
                __instance.isCoolingDown ||
                !__instance.isActiveAndEnabled ||
                role.CooldownTimer() != 0 ||
                role.Target == null ||
                role.Target.Data.IsImpostor
                )
            {
                return(false);
            }

            if (role.Target.isShielded())
            {
                Utils.BreakShield(role.Target);

                if (CustomGameOptions.ShieldBreaks)
                {
                    role.ResetCooldownTimer();
                }

                return(false);
            }

            // Sets concealed player
            role.StartConceal(role.Target);

            MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                              (byte)CustomRPC.Conceal,
                                                                              SendOption.Reliable, -1);

            writer.Write(PlayerControl.LocalPlayer.PlayerId);
            writer.Write(role.Concealed.PlayerId);
            AmongUsClient.Instance.FinishRpcImmediately(writer);

            return(false);
        }
예제 #2
0
        public static void Postfix(HudManager __instance)
        {
            if (
                PlayerControl.AllPlayerControls.Count <= 1 ||
                PlayerControl.LocalPlayer == null ||
                PlayerControl.LocalPlayer.Data == null ||
                !PlayerControl.LocalPlayer.Is(RoleEnum.Concealer)
                )
            {
                return;
            }

            Concealer role = Role.GetRole <Concealer>(PlayerControl.LocalPlayer);

            if (role.ConcealButton == null)
            {
                role.ConcealButton = Object.Instantiate(__instance.KillButton, HudManager.Instance.transform);
                role.ConcealButton.renderer.enabled = true;
            }

            role.ConcealButton.renderer.sprite = TownOfUs.SwoopSprite;

            role.ConcealButton.gameObject.SetActive(!PlayerControl.LocalPlayer.Data.IsDead && !MeetingHud.Instance);
            var position = __instance.KillButton.transform.localPosition;

            role.ConcealButton.transform.localPosition = new Vector3(position.x,
                                                                     __instance.ReportButton.transform.localPosition.y, position.z);

            if (role.Concealed != null)
            {
                // TODO: This will kind of lie to them about how long the conceal lasts, can we change the experience?
                role.ConcealButton.SetCoolDown(role.TimeBeforeConcealed + role.ConcealTimeRemaining, CustomGameOptions.ConcealDuration);
                return;
            }

            Utils.SetTarget(ref role.Target, role.ConcealButton);

            role.ConcealButton.SetCoolDown(role.CooldownTimer(), CustomGameOptions.ConcealCooldown);
            role.ConcealButton.renderer.color = Palette.EnabledColor;
        }