Esempio n. 1
0
    /// <summary>
    /// Caller can expect null results if the
    /// request for a type of ActionMap is
    /// made at an inappropriate time for the
    /// game or if a type other than an ActionMap
    /// is requested.
    /// </summary>
    /// <typeparam name="T">The type of action map requested</typeparam>
    /// <returns>The action map object requested, null when inaccessiable or not found.</returns>
    public T?RequestActionMap <T>() where T : struct
    {
        var result = new T?();

        if (_actionMapEnumDictionary.TryGetValue(typeof(T), out ActionMap actionMap))
        {
            if (TryResolveActionMap(ref result))
            {
                lock (_InputState_) {
                    if (InputState.AllowAddition(actionMap))
                    {
                        InputState |= actionMap;
                    }
                    else
                    {
                        Debug.LogWarning($"Attempting to activate Action Map '{actionMap}' while current state is '{InputState}'");
                        result = null;
                    }
                }
            }
            else
            {
                Debug.LogWarning($"'{typeof(T).Name}' not found in the Game Input Action Map Dictionary.");
            }
        }
        else
        {
            Debug.LogWarning($"'{typeof(T).Name}' not found in the InputControl Input Action Map Dictionary.");
        }

        return(result);
    }