<commit_before>using System;
using System.Collections.Generic;

namespace FlatRedBall.Input
{
	public interface IPressableInput
	{
        /// <summary>
        /// Returns whether the input is down (such as if a key is held or a mouse button is down)
        /// </summary>
		bool IsDown { get; }
        /// <summary>
        /// Returns whether the input was pressed this frame (not down last frame, is down this frame)
        /// </summary>
		bool WasJustPressed { get; }
		bool WasJustReleased { get; }
	}

    public class DelegateBasedPressableInput : IPressableInput
    {
        Func<bool> isDown;
        Func<bool> wasJustPressed;
        Func<bool> wasJustReleased;

        public DelegateBasedPressableInput(Func<bool> isDown, Func<bool> wasJustPressed, Func<bool> wasJustReleased)
        {
            this.isDown = isDown;
            this.wasJustPressed = wasJustPressed;
            this.wasJustReleased = wasJustReleased;
        }

        public bool IsDown
        {
            get { return this.isDown(); }
        }

        public bool WasJustPressed
        {
            get { return this.wasJustPressed(); }
        }

        public bool WasJustReleased
        {
            get { return this.wasJustReleased(); }
        }
    }

    public static class IPressableInputExtensions
    {
        public static MultiplePressableInputs Or(this IPressableInput thisInput, IPressableInput input)
        {
            MultiplePressableInputs toReturn;
            if(thisInput is MultiplePressableInputs)
            {
                toReturn = (MultiplePressableInputs)thisInput;
            }
            else
            {
                toReturn = new MultiplePressableInputs();
            }

            toReturn.Inputs.Add(input);

            return toReturn;
        }

    }

    /// <summary>
    /// An IPressableInput interface which can contain multiple IPressableInputs. This is useful if a particular action can be
    /// performed with multiple inputs, such as both the space bar and a game pad's A button being used to make a character jump.
    /// </summary>
    public class MultiplePressableInputs : IPressableInput
    {
        /// <summary>
        /// The list of inputs to be used for an action.
        /// </summary>
        /// <example>
        /// // The following shows how to add the space bar and the enter key:
        /// var jumpInput = new MultiplePressableInputs();
        /// jumpInput.Inputs.Add(InputManager.Keyboard.GetKey(Keys.Space));
        /// jumpInput.Inputs.Add(InputManager.Keyboard.GetKey(Keys.Enter));
        /// </example><commit_msg>[Engine] Fixing logic in new "or" method.<commit_after>using System;
using System.Collections.Generic;

namespace FlatRedBall.Input
{
	public interface IPressableInput
	{
        /// <summary>
        /// Returns whether the input is down (such as if a key is held or a mouse button is down)
        /// </summary>
		bool IsDown { get; }
        /// <summary>
        /// Returns whether the input was pressed this frame (not down last frame, is down this frame)
        /// </summary>
		bool WasJustPressed { get; }
		bool WasJustReleased { get; }
	}

    public class DelegateBasedPressableInput : IPressableInput
    {
        Func<bool> isDown;
        Func<bool> wasJustPressed;
        Func<bool> wasJustReleased;

        public DelegateBasedPressableInput(Func<bool> isDown, Func<bool> wasJustPressed, Func<bool> wasJustReleased)
        {
            this.isDown = isDown;
            this.wasJustPressed = wasJustPressed;
            this.wasJustReleased = wasJustReleased;
        }

        public bool IsDown
        {
            get { return this.isDown(); }
        }

        public bool WasJustPressed
        {
            get { return this.wasJustPressed(); }
        }

        public bool WasJustReleased
        {
            get { return this.wasJustReleased(); }
        }
    }

    public static class IPressableInputExtensions
    {
        public static MultiplePressableInputs Or(this IPressableInput thisInput, IPressableInput input)
        {
            MultiplePressableInputs toReturn;
            if(thisInput is MultiplePressableInputs)
            {
                toReturn = (MultiplePressableInputs)thisInput;
            }
            else
            {
                toReturn = new MultiplePressableInputs();
                toReturn.Inputs.Add(thisInput);
            }

            toReturn.Inputs.Add(input);

            return toReturn;
        }

    }

    /// <summary>
    /// An IPressableInput interface which can contain multiple IPressableInputs. This is useful if a particular action can be
    /// performed with multiple inputs, such as both the space bar and a game pad's A button being used to make a character jump.
    /// </summary>
    public class MultiplePressableInputs : IPressableInput
    {
        /// <summary>
        /// The list of inputs to be used for an action.
        /// </summary>
        /// <example>
        /// // The following shows how to add the space bar and the enter key:
        /// var jumpInput = new MultiplePressableInputs();
        /// jumpInput.Inputs.Add(InputManager.Keyboard.GetKey(Keys.Space));
        /// jumpInput.Inputs.Add(InputManager.Keyboard.GetKey(Keys.Enter));
        /// </example>
{'fraction_non_alphanumeric': 0.08677685950413223, 'fraction_numerical': 0.0, 'mean_word_length': 1.9274326553051127, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3630580', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1398, 'n_words': 412}