Esempio n. 1
0
        private void GasStation_PlayerKeyStateChange(object sender, KeyStateChangedEventArgs e)
        {
            if (!(sender is Player player))
            {
                return;
            }

            if (!KeyUtils.HasPressed(e.NewKeys, e.OldKeys, Keys.Crouch))
            {
                return;
            }

            if (!player.IsDriving())
            {
                return;
            }

            if (!GasStations.Any(gasStation => player.IsInRangeOfPoint(2.5f, gasStation.Position)))
            {
                return;
            }

            player.GameText("~g~Refuelling...", 3000, 4);
            player.ToggleControllable(false);

            var refuelTimer = new Timer(TimeSpan.FromSeconds(5), false);

            refuelTimer.Tick += (senderObject, ev) => RefuelVehicle(senderObject, ev, player);
        }
        /// <summary>
        ///     Handles a change in PlayerKeyState.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Object containing information about the event.</param>
        public void Handle(object sender, KeyStateChangedEventArgs e)
        {
            var args = new CancelableEventArgs();

            OnHighPriority(sender, args);

            if (!args.IsCanceled)
            {
                OnNormalPriority(sender, args);
            }

            if (!args.IsCanceled)
            {
                OnLowPriority(sender, args);
            }
        }
Esempio n. 3
0
    protected override void OnPlayerKeyStateChanged(BasePlayer sender, KeyStateChangedEventArgs e)
    {
        base.OnPlayerKeyStateChanged(sender, e);
        var player = sender as Player;

        if (Pressed(e, Keys.Walk, Keys.Crouch))
        {
            if (player.SpecialAction == SpecialAction.Duck)
            {
                player.ToggleControllable(true);
            }
            CmdPublic.PacketWeapons(player);
        }
        else if (Pressed(e, Keys.Walk, Keys.CtrlBack))
        {
            CmdPublic.ListCommands(player);
        }
        else if (HasPressed(e, Keys.Yes))
        {
            CmdPublic.Weapons(player);
        }
        else if (HasPressed(e, Keys.No))
        {
            CmdPublic.UsersList(player);
        }
        else if (HasPressed(e, Keys.CtrlBack))
        {
            CmdPublic.Combos(player);
        }
        else if (HasPressed(e, Keys.AnalogLeft))
        {
            CmdPublic.TopTen(player);
        }
        else if (HasPressed(e, Keys.AnalogRight))
        {
            CmdPublic.Help(player);
        }

        if (!player.IsCapturedFlag() && (player.JumpOn || player.IsEnableJump()) && HasPressed(e, Keys.Jump))
        {
            player.Velocity = new Vector3(player.Velocity.X, player.Velocity.Y, 0.24);
        }
        if (player.IsEnableSpeed() && HasPressed(e, Keys.Sprint))
        {
            player.ApplyAnimation("PED", "sprint_civi", 100, true, true, true, true, 500);
        }
    }
 /// <summary>
 ///     Handles a change in PlayerKeyState.
 /// </summary>
 /// <param name="sender">Sender of the event.</param>
 /// <param name="e">Object containing information about the event.</param>
 public void Handle(object sender, KeyStateChangedEventArgs e)
 {
     if (Action != null && _check(e, Keys.Action))
     {
         Action.Handle(sender, e);
     }
     if (Crouch != null && _check(e, Keys.Crouch))
     {
         Crouch.Handle(sender, e);
     }
     if (Fire != null && _check(e, Keys.Fire))
     {
         Fire.Handle(sender, e);
     }
     if (Sprint != null && _check(e, Keys.Sprint))
     {
         Sprint.Handle(sender, e);
     }
     if (SecondaryAttack != null && _check(e, Keys.SecondaryAttack))
     {
         SecondaryAttack.Handle(sender, e);
     }
     if (Jump != null && _check(e, Keys.Jump))
     {
         Jump.Handle(sender, e);
     }
     if (LookRight != null && _check(e, Keys.LookRight))
     {
         LookRight.Handle(sender, e);
     }
     if (Handbrake != null && _check(e, Keys.Handbrake))
     {
         Handbrake.Handle(sender, e);
     }
     if (Aim != null && _check(e, Keys.Aim))
     {
         Aim.Handle(sender, e);
     }
     if (LookLeft != null && _check(e, Keys.LookLeft))
     {
         LookLeft.Handle(sender, e);
     }
     if (Submission != null && _check(e, Keys.Submission))
     {
         Submission.Handle(sender, e);
     }
     if (Walk != null && _check(e, Keys.Walk))
     {
         Walk.Handle(sender, e);
     }
     if (AnalogUp != null && _check(e, Keys.AnalogUp))
     {
         AnalogUp.Handle(sender, e);
     }
     if (AnalogDown != null && _check(e, Keys.AnalogDown))
     {
         AnalogDown.Handle(sender, e);
     }
     if (AnalogLeft != null && _check(e, Keys.AnalogLeft))
     {
         AnalogLeft.Handle(sender, e);
     }
     if (AnalogRight != null && _check(e, Keys.AnalogRight))
     {
         AnalogRight.Handle(sender, e);
     }
     if (Yes != null && _check(e, Keys.Yes))
     {
         Yes.Handle(sender, e);
     }
     if (No != null && _check(e, Keys.No))
     {
         No.Handle(sender, e);
     }
     if (CtrlBack != null && _check(e, Keys.CtrlBack))
     {
         CtrlBack.Handle(sender, e);
     }
 }
 /// <summary>
 ///     Handles a change in PlayerKeyState.
 /// </summary>
 /// <param name="sender">Sender of the event.</param>
 /// <param name="e">Object containing information about the event.</param>
 public void Handle(object sender, KeyStateChangedEventArgs e)
 {
     Pressed.Handle(sender, e);
     Released.Handle(sender, e);
 }
Esempio n. 6
0
        public override void OnKeyStateChanged(KeyStateChangedEventArgs e)
        {
            base.OnKeyStateChanged(e);

            // TODO: Tow vehicle with tow truck
        }
Esempio n. 7
0
 /// <summary>
 ///     Checks if <see cref="Keys" /> are being hold.
 /// </summary>
 /// <param name="e">The <see cref="KeyStateChangedEventArgs" />.</param>
 /// <param name="keys">The <see cref="Keys" /> to check for.</param>
 /// <returns>Whether the <see cref="Keys" /> are being hold.</returns>
 public static bool IsHolding(KeyStateChangedEventArgs e, Keys keys)
 {
     return(IsHolding(e.NewKeys, e.OldKeys, keys));
 }
Esempio n. 8
0
 /// <summary>
 ///     Checks if <see cref="Keys" /> have been released.
 /// </summary>
 /// <param name="e">The <see cref="KeyStateChangedEventArgs" />.</param>
 /// <param name="keys">The <see cref="Keys" /> to check for.</param>
 /// <returns>Whether the <see cref="Keys" /> have been released.</returns>
 public static bool HasReleased(KeyStateChangedEventArgs e, Keys keys)
 {
     return(HasReleased(e.NewKeys, e.OldKeys, keys));
 }
Esempio n. 9
0
 private void Processor_KeyStateChanged(object sender, KeyStateChangedEventArgs e)
 {
     ProcessOneKey(e.Handle, e.KeyInfo);
 }
Esempio n. 10
0
 private bool Pressed(KeyStateChangedEventArgs e, Keys key1, Keys key2)
 => (((e.OldKeys & key1) != 0) && ((e.NewKeys & key2) != 0)) && !HasReleased(e, key1);