public void ReleasedEvent(CBaseController pController)
 {
     for (int i = 0; i < m_pReleasedEvents.Count; i++)
     {
         m_pReleasedEvents[i].Invoke(pController);
     }
 }
Пример #2
0
        /****************************************************************************************
         * 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);
                }
            }
        }
Пример #3
0
 void Drop(CBaseController pController)
 {
     if (HasParent() && GetParent() == pController &&
         !pController.ButtonsPressed().HasButton(g.IN_TRIGGER))
     {
         ForceDrop(pController);
     }
 }
Пример #4
0
 private static bool Hook_Use(CBaseEntity pEnt, CBaseController pController)
 {
     if (pEnt.GetOffsetTo(pController).magnitude < pEnt.m_flInputEventRadius)
     {
         return(pEnt.Use(pController));
     }
     return(false);
 }
 public CButtonSet(CBaseController pParent)
 {
     m_pParent  = pParent;
     m_pButtons = new List <CButton>();
     m_pButtons.Add(new CButton(g.IN_TRIGGER));
     m_pButtons.Add(new CButton(g.IN_GRIP));
     m_pButtons.Add(new CButton(g.IN_A));
     m_pButtons.Add(new CButton(g.IN_B));
     m_pButtons.Add(new CButton(g.IN_JOYSTICK));
 }
Пример #6
0
 public override void OnPickedUp(CBaseController pController)
 {
     base.OnPickedUp(pController);
     m_bMoveDown = false;
     EmitSound(m_pPickupSound);
     if (g.TowerBuilderRules().m_bDropBlocks&& !m_bHasGeneratedBlock)
     {
         m_bHasGeneratedBlock = true;
         g.TowerBuilderRules().CreateBlock();
     }
 }
Пример #7
0
 public void ForceDrop(CBaseController pController)
 {
     if (HasParent() && GetParent() == pController && m_bIsPickedUp)
     {
         m_bIsPickedUp = false;
         SetAbsVelocity(pController.GetAbsVelocityManualCalc());
         GetTransform().SetParent(null);
         SetGravityEnabled(m_bHasGravityEnabledByDefault);
         OnDropped(pController);
     }
 }
Пример #8
0
 void Pickup(CBaseController pController)
 {
     if (pController.m_pColliding.Contains(this) &&
         pController.ButtonsPressed().HasButton(g.IN_TRIGGER))
     {
         m_bIsPickedUp = true;
         SetAbsVelocity(Vector3.zero);
         SetAngVelocity(Vector3.zero);
         SetParent(pController);
         SetGravityEnabled(false);
         OnPickedUp(pController);
     }
 }
Пример #9
0
        public virtual void InitControllerInputs()
        {
            CBaseController left  = g.LeftController();
            CBaseController right = g.RightController();

            if (m_pLeftControllerInputs == null)
            {
                m_pLeftControllerInputs = new CButtonInputSet();
            }
            if (m_pRightControllerInputs == null)
            {
                m_pRightControllerInputs = new CButtonInputSet();
            }

            m_pLeftControllerInputs.Start(left, this);
            m_pRightControllerInputs.Start(right, this);
        }
Пример #10
0
        public override void OnUsed(CBaseEntity pUser)
        {
            base.OnUsed(pUser);
            CBaseController controller = pUser as CBaseController;

            if (controller != null)
            {
                if (controller.ButtonsPressed().HasButton(g.IN_TRIGGER))
                {
                    obj().GetComponent <MeshRenderer>().material = m_pToggledMaterial;
                }
                else
                {
                    obj().GetComponent <MeshRenderer>().material = m_pStartingMaterial;
                }
            }
        }
Пример #11
0
            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);
                        }
                    }
                }
            }
Пример #12
0
 public virtual void OnDropped(CBaseController pController)
 {
 }
Пример #13
0
 private void Hook_ToggleMusic(CBaseController pController)
 {
     HookInputFunction(pController, g.IN_A, false, false, ToggleMusic);
 }
Пример #14
0
 public bool ToggleMusic(CBaseEntity pEnt, CBaseController pController)
 {
     m_bMuteStatus       = !m_bMuteStatus;
     m_pMusicSource.mute = !m_pMusicSource.mute;
     return(true);
 }
Пример #15
0
 public override void OnDropped(CBaseController pController)
 {
     base.OnDropped(pController);
     g.TowerBuilderRules().OnBlockDropped(this);
     EmitSound(m_pDroppedSound);
 }
Пример #16
0
 public virtual void OnPickedUp(CBaseController pController)
 {
 }
Пример #17
0
 public bool ToggleBlockDrop(CBaseEntity pEnt, CBaseController pController)
 {
     m_bDropBlocks = !m_bDropBlocks;
     return(true);
 }
Пример #18
0
 private void Hook_ToggleBlockDrop(CBaseController pController)
 {
     HookInputFunction(pController, g.IN_B, false, false, ToggleBlockDrop);
 }
 public void Invoke(CBaseController pController)
 {
     m_pFunction(m_pEnt, pController);
 }