public void ReleasedEvent(CBaseController pController) { for (int i = 0; i < m_pReleasedEvents.Count; i++) { m_pReleasedEvents[i].Invoke(pController); } }
/**************************************************************************************** * 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); } } }
void Drop(CBaseController pController) { if (HasParent() && GetParent() == pController && !pController.ButtonsPressed().HasButton(g.IN_TRIGGER)) { ForceDrop(pController); } }
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)); }
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(); } }
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); } }
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); } }
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); }
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; } } }
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); } } } }
public virtual void OnDropped(CBaseController pController) { }
private void Hook_ToggleMusic(CBaseController pController) { HookInputFunction(pController, g.IN_A, false, false, ToggleMusic); }
public bool ToggleMusic(CBaseEntity pEnt, CBaseController pController) { m_bMuteStatus = !m_bMuteStatus; m_pMusicSource.mute = !m_pMusicSource.mute; return(true); }
public override void OnDropped(CBaseController pController) { base.OnDropped(pController); g.TowerBuilderRules().OnBlockDropped(this); EmitSound(m_pDroppedSound); }
public virtual void OnPickedUp(CBaseController pController) { }
public bool ToggleBlockDrop(CBaseEntity pEnt, CBaseController pController) { m_bDropBlocks = !m_bDropBlocks; return(true); }
private void Hook_ToggleBlockDrop(CBaseController pController) { HookInputFunction(pController, g.IN_B, false, false, ToggleBlockDrop); }
public void Invoke(CBaseController pController) { m_pFunction(m_pEnt, pController); }