﻿/// ------------------------------- ///
/// Juan Francisco Mora Palomino    ///
///                                 ///
/// Twitter: @JfranMora             ///
/// Contact: jfranmp@outlook.com    ///
/// ------------------------------- ///

using System;
using UnityEngine;

public static class InputUtils
{

    private static void CheckAndExecute(Func<bool> function, Action action)
    {
        if (function())
        {
            action();
        }
    }

    public static void GetKeyUpAndExecute(KeyCode key, Action action)
    {
        CheckAndExecute(() => Input.GetKeyUp(key), action);
    }

    public static void GetKeyDownAndExecute(KeyCode key, Action action)
    {
        CheckAndExecute(() => Input.GetKeyDown(key), action);
    }

    public static void GetKeyAndExecute(KeyCode key, Action action)
    {
        CheckAndExecute(() => Input.GetKey(key), action);
    }

}