/// <summary> /// Whether the given data is valid. /// </summary> /// <param name="data">The data to check.</param> /// <param name="checkIfHovered">Whether to check if the hover state is active.</param> /// <returns>Whether the data is valid.</returns> protected virtual bool IsValidData(SurfaceData data, bool checkIfHovered = false) { return(data.Transform != null && data.Transform.gameObject != null && SourceValidity.Accepts(data.Transform.gameObject) && (!checkIfHovered || HoveringElements.Any(element => element.Transform.Equals(data.Transform)))); }
public virtual void Exit(SurfaceData data) { if (data.Transform == null || !SourceValidity.Accepts(data.Transform) || !HoveringElements.Contains(data)) { return; } IsHovered = false; HoveringElements.Remove(data); Exited?.Invoke(CreateHoverPayload(data)); if (HoveringElements.Count == 0) { HoverDeactivated?.Invoke(); } }
public virtual void Enter(SurfaceData data) { if (data.Transform == null || !SourceValidity.Accepts(data.Transform)) { return; } IsHovered = true; HoveringElements.Add(data); if (HoveringElements.Count == 1) { HoverActivated?.Invoke(); } Entered?.Invoke(CreateHoverPayload(data)); }
public virtual void Select(SurfaceData data) { if (data.Transform == null || !SourceValidity.Accepts(data.Transform) || !HoveringElements.Contains(data)) { return; } IsActivated = true; Activated?.Invoke(CreateSelectedPayload(data)); if (!EmitExitOnSelect) { return; } foreach (SurfaceData element in HoveringElements.ToArray()) { Exit(element); } HoveringElements.Clear(); }
/// <inheritdoc /> protected override bool IsSourceValid(GameObject source) { return(base.IsSourceValid(source) && SourceValidity.Accepts(source)); }
private SourceValidationResult(SourceValidity validity, string source, SourceRepository sourceRepository) { Validity = validity; Source = source; SourceRepository = sourceRepository; }