private void OnDragEnd() { UIManager.IsMouseInteractionDisabled = false; Destroy(shadowObject); shadowObject = null; if (lightingSystem.enabled && !lightingSystem.IsScreenPointVisible(CommonInput.mousePosition)) { //do nothing, the point is not visible. return; } //check what we dropped on, which may or may not have mousedrop interaction components //can only drop on things that have a RegisterTile var dropTargets = MouseUtils.GetOrderedObjectsUnderMouse(); //go through the stack of objects and call any drop components we find foreach (GameObject dropTarget in dropTargets) { MouseDrop info = MouseDrop.ByLocalPlayer(gameObject, dropTarget.gameObject); //call this object's mousedrop interaction methods if it has any, for each object we are dropping on if (InteractionUtils.ClientCheckAndTrigger(mouseDrops, info) != null) { return; } var targetComps = dropTarget.GetComponents <IBaseInteractable <MouseDrop> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); if (InteractionUtils.ClientCheckAndTrigger(targetComps, info) != null) { return; } } }
private bool CheckAimApply(MouseButtonState buttonState) { ChangeDirection(); //currently there is nothing for ghosts to interact with, they only can change facing if (PlayerManager.LocalPlayerScript.IsGhost) { return(false); } //can't do anything if we have no item in hand var handObj = UIManager.Hands.CurrentSlot.Item; if (handObj == null) { triggeredAimApply = null; secondsSinceLastAimApplyTrigger = 0; return(false); } var aimApplyInfo = AimApply.ByLocalPlayer(buttonState); if (buttonState == MouseButtonState.PRESS) { //it's being clicked down triggeredAimApply = null; //Checks for aim apply interactions which can trigger var comps = handObj.GetComponents <IBaseInteractable <AimApply> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); var triggered = InteractionUtils.ClientCheckAndTrigger(comps, aimApplyInfo); if (triggered != null) { triggeredAimApply = triggered; secondsSinceLastAimApplyTrigger = 0; return(true); } } else { //it's being held //if we are already triggering an AimApply, keep triggering it based on the AimApplyInterval if (triggeredAimApply != null) { secondsSinceLastAimApplyTrigger += Time.deltaTime; if (secondsSinceLastAimApplyTrigger > AimApplyInterval) { if (triggeredAimApply.CheckInteract(aimApplyInfo, NetworkSide.Client)) { //only reset timer if it was actually triggered secondsSinceLastAimApplyTrigger = 0; InteractionUtils.RequestInteract(aimApplyInfo, triggeredAimApply); } } //no matter what the result, we keep trying to trigger it until mouse is released. return(true); } } return(false); }
private bool TryIF2InventoryApply() { //check IF2 InventoryApply interaction - apply the active hand item with this (only if //target slot is occupied, but it's okay if active hand slot is not occupied) if (Item != null) { var combine = InventoryApply.ByLocalPlayer(itemSlot, UIManager.Hands.CurrentSlot.itemSlot); //check interactables in the active hand (if active hand occupied) if (UIManager.Hands.CurrentSlot.Item != null) { var handInteractables = UIManager.Hands.CurrentSlot.Item.GetComponents <IBaseInteractable <InventoryApply> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); if (InteractionUtils.ClientCheckAndTrigger(handInteractables, combine) != null) { return(true); } } //check interactables in the target var targetInteractables = Item.GetComponents <IBaseInteractable <InventoryApply> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); if (InteractionUtils.ClientCheckAndTrigger(targetInteractables, combine) != null) { return(true); } } return(false); }
/// <summary> /// Check if item has an interaction with a an item in a slot /// If not or if bool returned is true, swap items /// </summary> public void TryItemInteract(bool swapIfEmpty = true) { var slotName = itemSlot.SlotIdentifier.NamedSlot; // Clicked on another slot other than our own hands if (itemSlot != UIManager.Hands.LeftHand.ItemSlot && itemSlot != UIManager.Hands.RightHand.itemSlot) { // If full, attempt to interact the two, otherwise swap if (Item != null) { //check IF2 InventoryApply interaction - combine the active hand item with this (only if //both are occupied) if (TryIF2InventoryApply()) { return; } if (swapIfEmpty) { UIManager.Hands.SwapItem(this); } return; } else { if (swapIfEmpty) { UIManager.Hands.SwapItem(this); } return; } } // If there is an item and the hand is interacting in the same slot if (Item != null && UIManager.Hands.CurrentSlot.ItemSlot == itemSlot) { //check IF2 logic first var interactables = Item.GetComponents <IBaseInteractable <HandActivate> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); var activate = HandActivate.ByLocalPlayer(); InteractionUtils.ClientCheckAndTrigger(interactables, activate); } else { if (UIManager.Hands.CurrentSlot.ItemSlot != itemSlot) { //Clicked on item with otherslot selected if (UIManager.Hands.OtherSlot.Item != null) { if (TryIF2InventoryApply()) { return; } if (swapIfEmpty) { UIManager.Hands.SwapItem(this); } } } } }
private void CheckForInteractions(AiActivate.ClickTypes clickType) { var handApplyTargets = MouseUtils.GetOrderedObjectsUnderMouse(); //go through the stack of objects and call AiActivate interaction components we find foreach (GameObject applyTarget in handApplyTargets) { var behaviours = applyTarget.GetComponents <IBaseInteractable <AiActivate> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); var aiActivate = new AiActivate(gameObject, null, applyTarget, Intent.Help, clickType); InteractionUtils.ClientCheckAndTrigger(behaviours, aiActivate); } }
/// <summary> /// Check if item has an interaction with a an item in a slot /// If not or if bool returned is true, swap items /// </summary> public void TryItemInteract() { // Clicked on another slot other than hands if (equipSlot != EquipSlot.leftHand && equipSlot != EquipSlot.rightHand) { // If full, attempt to interact the two, otherwise swap if (Item != null) { //check IF2 InventoryApply interaction - combine the active hand item with this (only if //both are occupied) if (TryIF2InventoryApply()) { return; } UIManager.Hands.SwapItem(this); return; } else { UIManager.Hands.SwapItem(this); return; } } // If there is an item and the hand is interacting in the same slot if (Item != null && UIManager.Hands.CurrentSlot.equipSlot == equipSlot) { //check IF2 logic first var interactables = Item.GetComponents <IBaseInteractable <HandActivate> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); var activate = HandActivate.ByLocalPlayer(); InteractionUtils.ClientCheckAndTrigger(interactables, activate); } else { if (UIManager.Hands.CurrentSlot.equipSlot != equipSlot) { //Clicked on item with otherslot selected if (UIManager.Hands.OtherSlot.Item != null) { if (TryIF2InventoryApply()) { return; } UIManager.Hands.SwapItem(this); } } } }
public void OnDrop(PointerEventData data) { // something was dropped onto this slot if (UIManager.UiDragAndDrop.FromSlotCache != null && UIManager.UiDragAndDrop.DraggedItem != null) { var fromSlot = UIManager.UiDragAndDrop.DraggedItem.GetComponent <Pickupable>().ItemSlot; var targetItem = itemSlot.ItemSlot.ItemObject; if (fromSlot.ItemObject == null || fromSlot.ItemObject == targetItem) { return; } // if there's an item in the target slot, try inventory apply interaction if (targetItem != null) { var invApply = InventoryApply.ByLocalPlayer(itemSlot.ItemSlot, fromSlot); // check interactables in the fromSlot (if it's occupied) var fromInteractables = fromSlot.ItemObject.GetComponents <IBaseInteractable <InventoryApply> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); if (InteractionUtils.ClientCheckAndTrigger(fromInteractables, invApply) != null) { UIManager.UiDragAndDrop.DropInteracted = true; UIManager.UiDragAndDrop.StopDrag(); return; } // check interactables in the target var targetInteractables = targetItem.GetComponents <IBaseInteractable <InventoryApply> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); if (InteractionUtils.ClientCheckAndTrigger(targetInteractables, invApply) != null) { UIManager.UiDragAndDrop.DropInteracted = true; UIManager.UiDragAndDrop.StopDrag(); return; } } else { UIManager.UiDragAndDrop.DropInteracted = true; UIManager.UiDragAndDrop.StopDrag(); Inventory.ClientRequestTransfer(fromSlot, itemSlot.ItemSlot); } } UIManager.UiDragAndDrop.StopDrag(); }
public void StopDrag() { if (!DropInteracted && DraggedItem != null) { var mouseDrops = DraggedItem.GetComponents <IBaseInteractable <MouseDrop> >(); // check for MouseDrop interactions in the world if we didn't drop on a UI slot // check what we dropped on, which may or may not have mousedrop interaction components var dropTargets = MouseUtils.GetOrderedObjectsUnderMouse(); // go through the stack of objects and call any drop components we find foreach (GameObject dropTarget in dropTargets) { MouseDrop info = MouseDrop.ByLocalPlayer(DraggedItem, dropTarget.gameObject); // call this object's mousedrop interaction methods if it has any, for each object we are dropping on if (InteractionUtils.ClientCheckAndTrigger(mouseDrops, info) != null) { break; } var targetComps = dropTarget.GetComponents <IBaseInteractable <MouseDrop> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); if (InteractionUtils.ClientCheckAndTrigger(targetComps, info) != null) { break; } } } DropInteracted = false; isDragging = false; dragDummy.enabled = false; if (FromSlotCache != null) { if (FromSlotCache.Item != null) { FromSlotCache.RefreshImage(); } } FromSlotCache = null; DraggedItem = null; ResetInteractable(); }
private bool CheckClick() { ChangeDirection(); //currently there is nothing for ghosts to interact with, they only can change facing if (PlayerManager.LocalPlayerScript.IsGhost) { return(false); } bool ctrlClick = KeyboardInputManager.IsControlPressed(); if (!ctrlClick) { var handApplyTargets = MouseUtils.GetOrderedObjectsUnderMouse(); //go through the stack of objects and call any interaction components we find foreach (GameObject applyTarget in handApplyTargets) { if (CheckHandApply(applyTarget)) { return(true); } } //check empty space positional hand apply var posHandApply = PositionalHandApply.ByLocalPlayer(null); if (posHandApply.HandObject != null) { var handAppliables = posHandApply.HandObject.GetComponents <IBaseInteractable <PositionalHandApply> >() .Where(c => c != null && (c as MonoBehaviour).enabled); if (InteractionUtils.ClientCheckAndTrigger(handAppliables, posHandApply) != null) { return(true); } } } return(false); }
/// <summary> /// Check if item has an interaction with a an item in a slot /// If not or if bool returned is true, swap items /// </summary> public void TryItemInteract(bool swapIfEmpty = true) { // Clicked on another slot other than our own hands bool IsHandSlots = false; foreach (var HadnitemSlot in PlayerManager.LocalPlayerScript.DynamicItemStorage.GetHandSlots()) { if (HadnitemSlot == itemSlot) { IsHandSlots = true; } } if (IsHandSlots == false) { // If full, attempt to interact the two, otherwise swap if (Item != null) { //check IF2 InventoryApply interaction - combine the active hand item with this (only if //both are occupied) if (TryIF2InventoryApply()) { return; } if (swapIfEmpty) { SwapItem(this); } return; } else { if (swapIfEmpty) { SwapItem(this); } return; } } // If there is an item and the hand is interacting in the same slot if (Item != null && PlayerManager.LocalPlayerScript.DynamicItemStorage.GetActiveHandSlot() == itemSlot) { //check IF2 logic first var interactables = Item.GetComponents <IBaseInteractable <HandActivate> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); var activate = HandActivate.ByLocalPlayer(); InteractionUtils.ClientCheckAndTrigger(interactables, activate); } else { if (PlayerManager.LocalPlayerScript.DynamicItemStorage.GetActiveHandSlot() != itemSlot) { if (TryIF2InventoryApply()) { return; } if (swapIfEmpty) { SwapItem(this); } } } }