コード例 #1
0
ファイル: InputComponent.cs プロジェクト: jcoder58/Plugins
        public unsafe void BindAxis(Name AxisName, AxisDelegate Handler)
        {
            var func = Marshal.GetDelegateForFunctionPointer <BindAxisFunction>(Native->BindAxisFunction);

            func(Main.GameInstance, this, AxisName);
            AxisBindings.Add(AxisName, Handler);
        }
コード例 #2
0
ファイル: InputManager.cs プロジェクト: threeup/robolimb
 public static void Unbind(int axis, AxisDelegate handler)
 {
     if (HasInstance())
     {
         Instance.RemoveAxisBind(axis, handler);
     }
 }
コード例 #3
0
 public DelegatedAxleButtonInputSignature(string id, AxisDelegate del, AxleValueConsideration consideration = AxleValueConsideration.Positive, float axisButtnDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE)
     : base(id)
 {
     _delegate = del;
     this.AxisButtonDeadZone = axisButtnDeadZone;
     this.Consideration      = consideration;
 }
コード例 #4
0
 public static InputToken CreateCustom(AxisDelegate del)
 {
     return(new InputToken()
     {
         Type = InputType.Custom,
         _axisDelegate = del
     });
 }
コード例 #5
0
 public static InputToken CreateCustom(AxisDelegate axisDel, ButtonDelegate buttonDel)
 {
     return(new InputToken()
     {
         Type = InputType.Custom,
         _axisDelegate = axisDel,
         _buttonDelegate = buttonDel
     });
 }
コード例 #6
0
        /*
         * Profile Group Factory
         */

        /*
         * Merge
         */

        public static AxisDelegate Merge(this AxisDelegate d1, AxisDelegate d2)
        {
            if (d1 == null)
            {
                return(d2);
            }
            if (d2 == null)
            {
                return(d1);
            }
            return(() => UnityEngine.Mathf.Clamp(d1() + d2(), -1f, 1f));
        }
コード例 #7
0
ファイル: InputManager.cs プロジェクト: threeup/robolimb
        public void RemoveAxisBind(int axis, AxisDelegate handler)
        {
            AxisDelegate deleg;

            if (axisTable.TryGetValue(axis, out deleg))
            {
                deleg           = Delegate.Remove(deleg, handler) as AxisDelegate;
                axisTable[axis] = deleg;
                if (axisTable[axis] == null)
                {
                    axisTable.Remove(axis);
                }
            }
        }
コード例 #8
0
ファイル: InputManager.cs プロジェクト: threeup/robolimb
        public void AddAxisBind(int axis, AxisDelegate handler)
        {
            AxisDelegate deleg;

            if (axisTable.TryGetValue(axis, out deleg))
            {
                axisTable[axis] = Delegate.Combine(deleg, handler) as AxisDelegate;
                //UnityEngine.Debug.LogError(axis+" leaking invok list"+axisTable[axis].GetInvocationList().Length);
            }
            else
            {
                axisTable[axis] = handler;
            }
        }
コード例 #9
0
        public static AxisDelegate CreateTriggerDelegate(AxisDelegate del, AxleValueConsideration axisConsideration = AxleValueConsideration.Positive)
        {
            if (del == null)
            {
                return(null);
            }
            switch (axisConsideration)
            {
            case AxleValueConsideration.Positive:
                return(() => UnityEngine.Mathf.Clamp01(del()));

            case AxleValueConsideration.Negative:
                return(() => - UnityEngine.Mathf.Clamp(del(), -1f, 0f));

            case AxleValueConsideration.Absolute:
                return(() => Math.Abs(del()));

            default:
                return(null);
            }
        }
コード例 #10
0
    public static void AddAxisDelegate(string inputName, AxisDelegate axisDelegate)
    {
        if (isApplicationQuitting)
        {
            return;
        }

        if (instance == null)
        {
            InstantiateInstance();
        }

        if (!dictAxisDelegates.ContainsKey(inputName))
        {
            dictAxisDelegates.Add(inputName, axisDelegate);
        }
        else
        {
            dictAxisDelegates[inputName] += axisDelegate;
        }
    }
コード例 #11
0
        public static ButtonDelegate CreateAxleButtonDelegate(AxisDelegate axis, AxleValueConsideration consideration, float axleButtonDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE)
        {
            if (axis == null)
            {
                return(null);
            }

            switch (consideration)
            {
            case AxleValueConsideration.Positive:
                return(() => axis() > axleButtonDeadZone);

            case AxleValueConsideration.Negative:
                return(() => axis() < -axleButtonDeadZone);

            case AxleValueConsideration.Absolute:
                return(() => Math.Abs(axis()) > axleButtonDeadZone);

            default:
                return(null);
            }
        }
コード例 #12
0
    public static void RemoveAxisDelegate(string inputName, AxisDelegate axisDelegate)
    {
        if (isApplicationQuitting || (instance == null))
        {
            return;
        }

        if (dictAxisDelegates.ContainsKey(inputName))
        {
            AxisDelegate dictDelegate = dictAxisDelegates[inputName];
            dictDelegate -= axisDelegate;

            if (dictDelegate == null)
            {
                dictAxisDelegates.Remove(inputName);
            }
            else
            {
                dictAxisDelegates[inputName] = dictDelegate;
            }
        }
    }
コード例 #13
0
 public DelegatedDualAxleInputSignature(string id, AxisDelegate hor, AxisDelegate ver)
     : base(id)
 {
     _horizontal = hor;
     _vertical   = ver;
 }
コード例 #14
0
 public DelegatedAxleInputSignature(string id, AxisDelegate del)
     : base(id)
 {
     _delegate = del;
 }
コード例 #15
0
 public DelegatedDualAxleButtonInputSignature(string id, AxisDelegate hor, AxisDelegate ver, float axisButtnDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE)
     : base(id, hor, ver)
 {
     this.AxisButtonDeadZone = axisButtnDeadZone;
 }
コード例 #16
0
ファイル: InputManager.cs プロジェクト: threeup/robolimb
 public static void Bind(int axis, AxisDelegate handler)
 {
     Instance.AddAxisBind(axis, handler);
 }