public void OnClick() { if (!PlayerList.Instance.IsClientAdmin) { return; } //If shift is pressed, don't check anything, just send Examine on contained item if any. if (KeyboardInputManager.IsShiftPressed() && ui_itemSlot.Item != null) { RequestExamineMessage.Send(ui_itemSlot.Item.GetComponent <NetworkIdentity>().netId); return; } var adminHand = AdminManager.Instance.LocalAdminGhostStorage.GetNamedItemSlot(NamedSlot.ghostStorage01); if (ui_itemSlot.ItemSlot != adminHand) { if (ui_itemSlot.Item == null) { if (adminHand.Item) { AdminInventoryTransferMessage.Send(adminHand, ui_itemSlot.ItemSlot); } } else { if (adminHand.Item == null) { AdminInventoryTransferMessage.Send(ui_itemSlot.ItemSlot, adminHand); } } } }
/// <summary> /// Called when clicking other player's slot /// </summary> /// <param name="slot">clicket slot</param> public void TryInteract(PlayerExaminationWindowSlot slot) { var targetSlot = CurrentOpenStorage.GetNamedItemSlot(slot.UI_ItemSlot.NamedSlot); if (slot.IsObscured || slot.IsPocket) { // when player clicks on obscured slot/pocket second time if (slot.IsQuestionMarkActive) { InteractWithOtherPlayersSlot(targetSlot); } // when player clicks on obscured slot/pocket first time else { slot.SetQuestionMarkActive(targetSlot.IsOccupied); } } else { if (KeyboardInputManager.IsShiftPressed() && targetSlot.Item != null) { RequestExamineMessage.Send(targetSlot.Item.GetComponent <NetworkIdentity>().netId); return; } InteractWithOtherPlayersSlot(targetSlot); } }
public void OnClick() { //If shift is pressed, don't check anything, just send Examine on contained item if any. if (KeyboardInputManager.IsShiftPressed() && itemSlot.Item != null) { RequestExamineMessage.Send(itemSlot.Item.GetComponent<NetworkIdentity>().netId); return; } SoundManager.Play(SingletonSOSounds.Instance.Click01); //if there is an item in this slot, try interacting. if (itemSlot.Item != null) { itemSlot.TryItemInteract(); } //otherwise, try switching hands to this hand if this is our own hand slot and not already active else if (itemSlot == UIManager.Hands.LeftHand && UIManager.Hands.CurrentSlot != itemSlot) { UIManager.Hands.SetHand(false); } else if (itemSlot == UIManager.Hands.RightHand && UIManager.Hands.CurrentSlot != itemSlot) { UIManager.Hands.SetHand(true); } else { //otherwise, try just interacting with the blank slot (which will transfer the item itemSlot.TryItemInteract(); } }
public void OnClick() { // If shift is pressed, don't check anything, just send Examine on contained item if any. if (KeyboardInputManager.IsShiftPressed() && itemSlot.Item != null) { RequestExamineMessage.Send(itemSlot.Item.GetComponent <NetworkIdentity>().netId); return; } _ = SoundManager.Play(CommonSounds.Instance.Click01); // if there is an item in this slot, try interacting. itemSlot.TryItemInteract(); }
public override void CheckMouseInput() { if (EventSystem.current.IsPointerOverGameObject()) { //don't do any game world interactions if we are over the UI return; } if (UIManager.IsMouseInteractionDisabled) { //still allow tooltips CheckHover(); return; } if (CommonInput.GetMouseButtonDown(0)) { if (ClicksFromBlobHud()) { return; } //check ctrl+click for dragging if (KeyboardInputManager.IsControlPressed()) { //Place strong blob / reflective if strong blob already blobPlayer.CmdTryPlaceStrongReflective(Camera.main.ScreenToWorldPoint(CommonInput.mousePosition).RoundToInt()); return; } if (KeyboardInputManager.IsShiftPressed()) { //like above, send shift-click request, then do nothing else. Inspect(); return; } if (KeyboardInputManager.IsAltPressed()) { //Remove blob blobPlayer.CmdRemoveBlob(Camera.main.ScreenToWorldPoint(CommonInput.mousePosition).RoundToInt()); return; } blobPlayer.CmdTryPlaceBlobOrAttack(Camera.main.ScreenToWorldPoint(CommonInput.mousePosition).RoundToInt()); } else { CheckHover(); } }
public override void CheckMouseInput() { if (EventSystem.current.IsPointerOverGameObject()) { //don't do any game world interactions if we are over the UI return; } if (UIManager.IsMouseInteractionDisabled) { //still allow tooltips CheckHover(); return; } if (CommonInput.GetMouseButtonDown(0)) { if (KeyboardInputManager.IsControlPressed() && KeyboardInputManager.IsShiftPressed()) { CheckForInteractions(AiActivate.ClickTypes.CtrlShiftClick); return; } //check ctrl+click for dragging if (KeyboardInputManager.IsControlPressed()) { CheckForInteractions(AiActivate.ClickTypes.CtrlClick); return; } if (KeyboardInputManager.IsShiftPressed()) { //like above, send shift-click request, then do nothing else. //Inspect(); CheckForInteractions(AiActivate.ClickTypes.ShiftClick); return; } if (KeyboardInputManager.IsAltPressed()) { CheckForInteractions(AiActivate.ClickTypes.AltClick); return; } CheckForInteractions(AiActivate.ClickTypes.NormalClick); } else { CheckHover(); } }
private void OnClickItem(PointerEventData eventData, RightClickRadialButton button) { var subItems = Items[button.Index]?.SubMenus; if (subItems == null) { return; } // Copern: Not a preferable method of doing this but the original RightClickMenuItem wasn't really // designed for this. Also need to switch this to use keybinds. if (KeyboardInputManager.IsShiftPressed()) { DoAction(examineOption); } else if (KeyboardInputManager.IsControlPressed()) { DoAction(pullOption); } else { DoAction(pickUpOption); } void DoAction(RightClickOption option) { foreach (var item in subItems) { if (item.Label != option.label) { continue; } item.Action(); this.SetActive(option.keepMenuOpen); return; } } }
private void CheckMouseInput() { if (EventSystem.current.IsPointerOverGameObject()) { //don't do any game world interactions if we are over the UI return; } if (UIManager.IsMouseInteractionDisabled) { //still allow tooltips CheckHover(); return; } //do we have a loaded gun var loadedGun = GetLoadedGunInActiveHand(); if (CommonInput.GetMouseButtonDown(0)) { //check ctrl+click for dragging if (KeyboardInputManager.IsControlPressed()) { //even if we didn't drag anything, nothing else should happen CheckInitiatePull(); return; } if (KeyboardInputManager.IsShiftPressed()) { //like above, send shift-click request, then do nothing else. Inspect(); return; } //check alt click and throw, which doesn't have any special logic. For alt clicks, continue normally. CheckAltClick(); if (CheckThrow()) { return; } if (loadedGun != null) { //if we are on harm intent with loaded gun, //don't do anything else, just shoot (trigger the AimApply). if (UIManager.CurrentIntent == Intent.Harm) { CheckAimApply(MouseButtonState.PRESS); } else { //proceed to normal click interaction CheckClickInteractions(true); } } else { //we don't have a loaded gun //Are we over something draggable? var draggable = GetDraggable(); if (draggable != null) { //We are over a draggable. We need to wait to see if the user //tries to drag the object or lifts the mouse. potentialDraggable = draggable; dragStartOffset = MouseWorldPosition - potentialDraggable.transform.position; clickDuration = 0; } else { //no possibility of dragging something, proceed to normal click logic CheckClickInteractions(true); } } } else if (CommonInput.GetMouseButton(0)) { //mouse button being held down. //increment the time since they initially clicked the mouse clickDuration += Time.deltaTime; //If we are possibly dragging and have exceeded the drag distance, initiate the drag if (potentialDraggable != null) { if (!(UIManager.CurrentIntent == Intent.Harm) && !(UIManager.CurrentIntent == Intent.Disarm)) { var currentOffset = MouseWorldPosition - potentialDraggable.transform.position; if (((Vector2)currentOffset - dragStartOffset).magnitude > MouseDragDeadzone) { potentialDraggable.BeginDrag(); potentialDraggable = null; } } } //continue to trigger the aim apply if it was initially triggered CheckAimApply(MouseButtonState.HOLD); } else if (CommonInput.GetMouseButtonUp(0)) { //mouse button is lifted. //If we were waiting for mouseup to trigger a click, trigger it if we're still within //the duration threshold if (potentialDraggable != null) { if (clickDuration < MaxClickDuration) { //we are lifting the mouse, so AimApply should not be performed but other //clicks can. CheckClickInteractions(false); } clickDuration = 0; potentialDraggable = null; } //no more triggering of the current aim apply triggeredAimApply = null; secondsSinceLastAimApplyTrigger = 0; } else { CheckHover(); } }