/*--------------------------------------------------------------------------------------------*/ private void FillCursorLists() { for (int i = 0; i < vItems.Count; i++) { HoverItemData data = vItems[i].Data; IItemDataSelectable selData = (IItemDataSelectable)data; HoverItemHighlightState highState = data.GetComponent <HoverItemHighlightState>(); ICursorData cursorData = highState.NearestHighlight.Value.Cursor; if (cursorData.Idle.Progress >= 1) { selData.DeselectStickySelections(); continue; } HoverItemSelectionState selState = data.GetComponent <HoverItemSelectionState>(); HoverRenderer rend = data.GetComponent <HoverItemRendererUpdater>().ActiveRenderer; var info = new StickySelectionInfo { ItemWorldPosition = rend.GetCenterWorldPosition(), SelectionProgress = selState.SelectionProgress }; cursorData.ActiveStickySelections.Add(info); } }
/*--------------------------------------------------------------------------------------------*/ private bool UpdateState() { HoverItemData itemData = GetComponent <HoverItem>().Data; IItemDataSelectable selData = (itemData as IItemDataSelectable); WasSelectedThisFrame = false; if (selData == null) { return(false); } //// HoverItemHighlightState highState = GetComponent <HoverItemHighlightState>(); bool canSelect = ( !highState.IsHighlightPrevented && highState.IsNearestAcrossAllItemsForAnyCursor && selData.AllowSelection ); if (SelectionProgress <= 0 || !canSelect) { selData.DeselectStickySelections(); } if (!canSelect || highState.MaxHighlightProgress < 1) { IsSelectionPrevented = false; vSelectionStart = null; return(false); } //// if (IsSelectionPrevented) { vSelectionStart = null; return(false); } if (vSelectionStart == null) { vSelectionStart = DateTime.UtcNow; return(false); } if (SelectionProgress < 1) { return(false); } vSelectionStart = null; IsSelectionPrevented = true; WasSelectedThisFrame = true; vDistanceUponSelection = highState.NearestHighlight.Value.Distance; selData.Select(); return(true); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void TryResetSelection(HoverItemHighlightState pHighState, IItemDataSelectable pSelData) { if (!pHighState.IsHighlightPrevented) { return; } vSelectionStart = null; pSelData?.DeselectStickySelections(); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void TryResetSelection() { if (!GetComponent <HoverItemHighlightState>().IsHighlightPrevented) { return; } HoverItemData itemData = GetComponent <HoverItem>().Data; IItemDataSelectable selData = (itemData as IItemDataSelectable); vSelectionStart = null; if (selData != null) { selData.DeselectStickySelections(); } }
/*--------------------------------------------------------------------------------------------*/ private bool UpdateState() { HoverItemData itemData = GetComponent <HoverItem>().Data; IItemDataSelectable selData = (itemData as IItemDataSelectable); WasSelectedThisFrame = false; if (selData == null || selData.IgnoreSelection) { return(false); } //// HoverItemHighlightState highState = GetComponent <HoverItemHighlightState>(); bool hasNearestCursorWithFullHigh = false; bool canDeselect = ( highState.IsHighlightPrevented || !highState.IsNearestAcrossAllItemsForAnyCursor || !selData.IsEnabled ); for (int i = 0; i < highState.Highlights.Count; i++) { HoverItemHighlightState.Highlight high = highState.Highlights[i]; if (high.IsNearestAcrossAllItems && high.Progress >= 1) { hasNearestCursorWithFullHigh = true; break; } } if (SelectionProgress <= 0 || canDeselect) { selData.DeselectStickySelections(); } if (canDeselect || !hasNearestCursorWithFullHigh) { IsSelectionPrevented = false; vSelectionStart = null; return(false); } //// if (IsSelectionPrevented) { vSelectionStart = null; return(false); } if (vSelectionStart == null) { vSelectionStart = DateTime.UtcNow; return(false); } if (SelectionProgress < 1) { return(false); } vSelectionStart = null; IsSelectionPrevented = true; WasSelectedThisFrame = true; vDistanceUponSelection = highState.NearestHighlight.Value.Distance; selData.Select(); return(true); }