private void SendExitMessage(VirtualCursorSnapNode node) { if (node != null && !string.IsNullOrEmpty(this._onTargetExitMessage)) { node.SendMessage(this._onTargetExitMessage, SendMessageOptions.DontRequireReceiver); } }
public override void UnregisterNode(VirtualCursorSnapNode node) { if (node == this._currentNode) { base.CheckCurrentNode(); } if (node.MasterGroupNode) { node.MasterGroupNode.GroupedNodes.Remove(node); node.MasterGroupNode = null; return; } if (node.GroupedNodes != null && node.GroupedNodes.Count > 0) { VirtualCursorSnapNode virtualCursorSnapNode = node.GroupedNodes[0]; virtualCursorSnapNode.MasterGroupNode = null; node.GroupedNodes.RemoveAt(0); for (int i = 0; i < node.GroupedNodes.Count; i++) { virtualCursorSnapNode.GroupedNodes.Add(node); node.MasterGroupNode = virtualCursorSnapNode; } node.GroupedNodes.Clear(); this._nodes.Add(virtualCursorSnapNode); } this._nodes.Remove(node); }
public void NodeHovered(VirtualCursorSnapNode node, bool on) { if (this._actionIcon && !TheForest.Utils.Input.IsGamePad) { if (on) { if (this._hoveredNode != node) { this._hoveredNode = node; this._actionIcon.transform.position = node.Center; if (!this._actionIcon.gameObject.activeSelf) { this._actionIcon.gameObject.SetActive(true); } } } else if (this._hoveredNode == node) { this._hoveredNode = null; if (this._actionIcon.gameObject.activeSelf) { this._actionIcon.gameObject.SetActive(false); } } } }
private void OnEnable() { if (ForestVR.Prototype) { base.enabled = false; return; } VirtualCursorSnapNode component = base.GetComponent <VirtualCursorSnapNode>(); component._layer.SetCurrentNode(component); }
public override void RegisterNode(VirtualCursorSnapNode node) { VirtualCursorSnapNodeGrid virtualCursorSnapNodeGrid = node as VirtualCursorSnapNodeGrid; if (virtualCursorSnapNodeGrid) { int num = Mathf.RoundToInt(virtualCursorSnapNodeGrid._vpMin.x * (float)this._grid.GetLength(0)); int num2 = Mathf.RoundToInt(virtualCursorSnapNodeGrid._vpMax.x * (float)this._grid.GetLength(0)); int num3 = Mathf.RoundToInt(virtualCursorSnapNodeGrid._vpMin.y * (float)this._grid.GetLength(1)); int num4 = Mathf.RoundToInt(virtualCursorSnapNodeGrid._vpMax.y * (float)this._grid.GetLength(1)); this._nodes.Add(node); } }
public override VirtualCursorSnapNode GetNodeAtDir(Vector3 myDir) { Transform transform = base.transform; myDir.Normalize(); bool flag = Mathf.Abs(Mathf.Abs(myDir.y) - Mathf.Abs(myDir.z)) < 0.25f; bool flag2 = Mathf.Abs(myDir.y) < Mathf.Abs(myDir.z); float num = (!flag && !flag2) ? 2f : 1f; float num2 = (!flag && flag2) ? 2f : 1f; myDir = transform.TransformDirection(myDir); Vector3 b = (!(this._currentNode != null)) ? base.transform.position : base.FlattenPosition(this._currentNode.Center); float num3 = float.MaxValue; VirtualCursorSnapNode result = null; for (int i = 0; i < this._nodes.Count; i++) { VirtualCursorSnapNode virtualCursorSnapNode; if (this._nodes[i].GroupedNodes != null && this._nodes[i].GroupedNodes.Count > 0) { virtualCursorSnapNode = this._nodes[i].GroupedNodes[this._nodes[i].GroupedNodes.Count - 1]; } else { virtualCursorSnapNode = this._nodes[i]; } if (virtualCursorSnapNode.CanBeSnapedTo) { Vector3 direction = base.FlattenPosition(virtualCursorSnapNode.Center) - b; float num4 = Vector3.Dot(myDir, direction.normalized); if (num4 >= 0.5f) { direction = transform.InverseTransformDirection(direction); direction.x *= num + (1f - num4) * 2.5f; direction.y *= num2 + (1f - num4) * 2.5f; float sqrMagnitude = direction.sqrMagnitude; if (sqrMagnitude <= num3) { result = virtualCursorSnapNode; num3 = sqrMagnitude; } } } } return(result); }
public virtual void Navigate() { if (this._nextSnap < Time.realtimeSinceStartup) { float num = (!TheForest.Utils.Input.IsGamePad) ? (-TheForest.Utils.Input.GetAxis("Mouse X")) : (-TheForest.Utils.Input.GetAxis("Horizontal")); float num2 = (!TheForest.Utils.Input.IsGamePad) ? TheForest.Utils.Input.GetAxis("Mouse Y") : TheForest.Utils.Input.GetAxis("Vertical"); if (Mathf.Abs(num) < 0.1f) { num = 0f; } if (Mathf.Abs(num2) < 0.1f) { num2 = 0f; } if (!Mathf.Approximately(num, 0f) || !Mathf.Approximately(num2, 0f)) { VirtualCursorSnapNode nodeAtDir = this.GetNodeAtDir(new Vector3(0f, num2, num)); this.SetCurrentNode(nodeAtDir); if (nodeAtDir) { if (this._speedUp) { this._nextSnap = Time.realtimeSinceStartup + this._snapDelay / 2f; } else { this._nextSnap = Time.realtimeSinceStartup + this._snapDelay; if (this._canSpeedUp) { this._speedUp = true; } else { this._canSpeedUp = true; } } } } else { this._canSpeedUp = false; this._speedUp = false; } } }
public void SetCurrentNode(VirtualCursorSnapNode node) { if (node != null) { this.SendExitMessage(this._currentNode); this._currentNode = node; this.SendEnterMessage(this._currentNode); VirtualCursor.Instance.SetTargetWorldPosition(node.Center); if (this._actionIcon && TheForest.Utils.Input.IsGamePad) { this._actionIcon.transform.position = node.Center; if (!this._actionIcon.gameObject.activeSelf) { this._actionIcon.gameObject.SetActive(true); } } } }
public virtual void RegisterNode(VirtualCursorSnapNode node) { if (node.GroupTester != null) { for (int i = 0; i < this._nodes.Count; i++) { if (this._nodes[i].GroupTester != null && this._nodes[i] != node && node.GroupTester.BelongWith(this._nodes[i].GroupTester)) { this._nodes[i].GroupedNodes.Add(node); node.MasterGroupNode = this._nodes[i]; return; } } } this._nodes.Add(node); this._delayCurrentNodeRefresh = true; if (node == this._currentNode) { this.SetCurrentNode(this._currentNode); VirtualCursor.Instance.OverridingPosition = ((!this._currentNode) ? null : base.gameObject); } }
public override void Navigate() { if (this._nextSnap < Time.realtimeSinceStartup) { float num = -TheForest.Utils.Input.GetAxis("Mouse X"); float axis = TheForest.Utils.Input.GetAxis("Mouse Y"); if (!Mathf.Approximately(num, 0f) || !Mathf.Approximately(axis, 0f)) { VirtualCursorSnapNode nodeAtDir = this.GetNodeAtDir(new Vector3(0f, axis, num)); base.SetCurrentNode(nodeAtDir); if (nodeAtDir) { if (this._speedUp) { this._nextSnap = Time.realtimeSinceStartup + this._snapDelay / 2f; } else { this._nextSnap = Time.realtimeSinceStartup + this._snapDelay; if (this._canSpeedUp) { this._speedUp = true; } else { this._canSpeedUp = true; } } } } else { this._canSpeedUp = false; this._speedUp = false; } } }
public VirtualCursorSnapNode GetClosestNode(Vector3 pos) { Transform transform = base.transform; pos = transform.TransformDirection(pos); Vector3 b = (!(this._currentNode != null)) ? base.transform.position : this._currentNode.Center; float num = float.MaxValue; VirtualCursorSnapNode result = null; for (int i = 0; i < this._nodes.Count; i++) { VirtualCursorSnapNode virtualCursorSnapNode = this._nodes[i]; if (virtualCursorSnapNode.CanBeSnapedTo) { float num2 = Vector3.Distance(virtualCursorSnapNode.Center, b); if (num2 <= num) { result = virtualCursorSnapNode; num = num2; } } } return(result); }