Example #1
0
            public static bool Prefix(Vent __instance)
            {
                if (!VentMap.ContainsKey(__instance.Id))
                {
                    return(true);
                }
                var Custom = VentMap[__instance.Id];

                __instance.CanUse(PlayerControl.LocalPlayer.Data, out var canUse, out _);
                if (!canUse)
                {
                    return(false);
                }

                var localPlayer = PlayerControl.LocalPlayer;

                if (localPlayer.inVent)
                {
                    localPlayer.MyPhysics.RpcExitVent(Custom.Id);
                    Custom.SetButtons(false);
                }
                else
                {
                    localPlayer.MyPhysics.RpcEnterVent(Custom.Id);
                    Custom.SetButtons(true);
                }

                return(false);
            }
Example #2
0
        public static bool Prefix(Vent __instance)
        {
            bool flag;
            bool flag2;

            __instance.CanUse(PlayerControl.LocalPlayer.PPMOEEPBHJO, out flag, out flag2);

            if (!flag)
            {
                return(true);        // Continue with default method
            }
            bool isEnter = !PlayerControl.LocalPlayer.inVent;

            if (isEnter)
            {
                localVentEnterTimePoint = DateTime.UtcNow;
            }

            if (!__instance.name.StartsWith("JackInTheBoxVent_"))
            {
                return(true);                                                  // Continue with default method
            }
            __instance.SetButtons(isEnter);
            MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UseUncheckedVent, Hazel.SendOption.Reliable);

            writer.WritePacked(__instance.Id);
            writer.Write(PlayerControl.LocalPlayer.PlayerId);
            writer.Write(isEnter ? byte.MaxValue : (byte)0);
            writer.EndMessage();
            RPCProcedure.useUncheckedVent(__instance.Id, PlayerControl.LocalPlayer.PlayerId, isEnter ? byte.MaxValue : (byte)0);

            return(false);
        }
Example #3
0
        public static void Prefix(Vent __instance)
        {
            bool flag;
            bool flag2;

            __instance.CanUse(PlayerControl.LocalPlayer.IDOFAMCIJKE, out flag, out flag2);
            if (flag && !PlayerControl.LocalPlayer.inVent)
            {
                localVentEnterTimePoint = DateTime.UtcNow;
            }
        }
Example #4
0
            public static bool Prefix(Vent __instance)
            {
                bool canUse;
                bool couldUse;

                __instance.CanUse(PlayerControl.LocalPlayer.Data, out canUse, out couldUse);
                bool canMoveInVents = PlayerControl.LocalPlayer != Spy.spy && !PlayerControl.LocalPlayer.hasModifier(ModifierType.Madmate) && !PlayerControl.LocalPlayer.hasModifier(ModifierType.CreatedMadmate);

                if (!canUse)
                {
                    return(false);         // No need to execute the native method as using is disallowed anyways
                }
                bool isEnter = !PlayerControl.LocalPlayer.inVent;

                if (__instance.name.StartsWith("JackInTheBoxVent_"))
                {
                    __instance.SetButtons(isEnter && canMoveInVents);
                    MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UseUncheckedVent, Hazel.SendOption.Reliable);
                    writer.WritePacked(__instance.Id);
                    writer.Write(PlayerControl.LocalPlayer.PlayerId);
                    writer.Write(isEnter ? byte.MaxValue : (byte)0);
                    writer.EndMessage();
                    RPCProcedure.useUncheckedVent(__instance.Id, PlayerControl.LocalPlayer.PlayerId, isEnter ? byte.MaxValue : (byte)0);
                    return(false);
                }

                if (isEnter)
                {
                    PlayerControl.LocalPlayer.MyPhysics.RpcEnterVent(__instance.Id);
                }
                else
                {
                    PlayerControl.LocalPlayer.MyPhysics.RpcExitVent(__instance.Id);
                }
                __instance.SetButtons(isEnter && canMoveInVents);
                return(false);
            }