Ejemplo n.º 1
0
        public static void MakeButtons(HudManager hm)
        {
            // Ninja stealth
            ninjaButton = new CustomButton(
                () => {
                if (ninjaButton.isEffectActive)
                {
                    ninjaButton.Timer = 0;
                    return;
                }

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.NinjaStealth, Hazel.SendOption.Reliable, -1);
                writer.Write(PlayerControl.LocalPlayer.PlayerId);
                writer.Write(true);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.ninjaStealth(PlayerControl.LocalPlayer.PlayerId, true);
            },
                () => { return(PlayerControl.LocalPlayer.isRole(RoleType.Ninja) && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => {
                if (ninjaButton.isEffectActive)
                {
                    ninjaButton.buttonText = ModTranslation.getString("NinjaUnstealthText");
                }
                else
                {
                    ninjaButton.buttonText = ModTranslation.getString("NinjaText");
                }
                return(PlayerControl.LocalPlayer.CanMove);
            },
                () => {
                ninjaButton.Timer = ninjaButton.MaxTimer = Ninja.stealthCooldown;
            },
                Ninja.getButtonSprite(),
                new Vector3(-1.8f, -0.06f, 0),
                hm,
                hm.KillButton,
                KeyCode.F,
                true,
                Ninja.stealthDuration,
                () => {
                ninjaButton.Timer = ninjaButton.MaxTimer = Ninja.stealthCooldown;

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.NinjaStealth, Hazel.SendOption.Reliable, -1);
                writer.Write(PlayerControl.LocalPlayer.PlayerId);
                writer.Write(false);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.ninjaStealth(PlayerControl.LocalPlayer.PlayerId, false);

                PlayerControl.LocalPlayer.SetKillTimerUnchecked(Math.Max(PlayerControl.LocalPlayer.killTimer, Ninja.killPenalty));
            }
                );
            ninjaButton.buttonText        = ModTranslation.getString("NinjaText");
            ninjaButton.effectCancellable = true;
        }