/****************************************************************************************
         * Call this function to hook a function to a given button input on the given controller
         * @param iButton can have multiple buttons
         * Call this from an overriden InitControllerInputs() function
         ***************************************************************************************/
        public void HookInputFunction(CBaseController pController, ulong iButton, bool bTouchInput, bool bActivateOnRelease, EntityControllerInputDelegate pFunction)
        {
            //Find our button object to register with
            CButtonSet bs = bTouchInput ? pController.ButtonsTouched() : pController.ButtonsPressed();

            List <CButton> bl = new List <CButton>();

            for (int i = 0; i < bs.m_pButtons.Count; i++)
            {
                if ((bs.m_pButtons[i].m_iFlag & iButton) > 0)
                {
                    bl.Add(bs.m_pButtons[i]);
                }
            }

            EntityControllerInputEvent ecie;

            ecie.m_pEnt      = this;
            ecie.m_pFunction = pFunction;

            for (int i = 0; i < bl.Count; i++)
            {
                CButton b = bl[i];
                if (bActivateOnRelease)
                {
                    b.m_pReleasedEvents.Add(ecie);
                }
                else
                {
                    b.m_pPressedEvents.Add(ecie);
                }
            }
        }
            public void Start(CBaseController pController, CBaseEntity pEnt)
            {
                //builds flags from our booleans
                ulong pressPressedFlags  = m_pPressPressed.GetFlags();
                ulong pressReleasedFlags = m_pPressReleased.GetFlags();
                ulong touchPressedFlags  = m_pTouchPressed.GetFlags();
                ulong touchReleasedFlags = m_pTouchReleased.GetFlags();

                CButtonSet touch = pController.ButtonsTouched();
                CButtonSet press = pController.ButtonsPressed();

                //iterate through all the buttons
                if (pEnt.m_bInputEventsTriggersUse)
                {
                    EntityControllerInputEvent input = new EntityControllerInputEvent();
                    input.m_pEnt      = pEnt;
                    input.m_pFunction = CBaseEntity.Hook_Use;

                    for (int i = 0; i < g.IN_NUM_BUTTONS; i++)
                    {
                        CButton b = press.m_pButtons[i];
                        if ((pressPressedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pPressedEvents.Add(input);
                        }
                        if ((pressReleasedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pReleasedEvents.Add(input);
                        }
                    }
                    for (int i = 0; i < g.IN_NUM_BUTTONS; i++)
                    {
                        CButton b = touch.m_pButtons[i];
                        if ((touchPressedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pPressedEvents.Add(input);
                        }
                        if ((touchReleasedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pReleasedEvents.Add(input);
                        }
                    }
                }
            }
Esempio n. 3
0
 public void RemoveAllLinkedEntityInputs()
 {
     //Initialize buttons sets
     m_bsPress = new CButtonSet(this);
     m_bsTouch = new CButtonSet(this);
 }