private List <BoundaryNode> BestPath(BoundaryNode closestBoundaryNodeToStart, BoundaryNode closestBoundaryNodeToTargetDestination) { var pathA = GeneratePath(closestBoundaryNodeToTargetDestination, closestBoundaryNodeToStart, true); var pathB = GeneratePath(closestBoundaryNodeToTargetDestination, closestBoundaryNodeToStart, false); return(pathA.Count < pathB.Count ? pathA : pathB); }
private List <BoundaryNode> GeneratePath(BoundaryNode closestBoundaryNodeToTargetDestination, BoundaryNode closestBoundaryNodeToStart, bool nextNeighbor) { var path = new List <BoundaryNode> { closestBoundaryNodeToStart }; var currentNode = closestBoundaryNodeToStart; while (currentNode != closestBoundaryNodeToTargetDestination) { currentNode = nextNeighbor ? currentNode.NextNeighbor : currentNode.PreviousNeighbor; path.Add(currentNode); } return(path); }
private void BuildGrid() { var width = _size.x; var height = _size.y; var numberOfNodes = (int)(width * 2 + height * 2 + 4); _boundaryGrid = new BoundaryNode[numberOfNodes]; _bottomRight = (Vector2)transform.position + Vector2.right * width / 2 - Vector2.up * height / 2 - Vector2.right * _nodeRadius + Vector2.up * _nodeRadius; _topLeft = (Vector2)transform.position - Vector2.right * width / 2 + Vector2.up * height / 2 + Vector2.right * _nodeRadius - Vector2.up * _nodeRadius; _bottomLeft = (Vector2)transform.position - Vector2.right * width / 2 - Vector2.up * height / 2 + Vector2.right * _nodeRadius + Vector2.up * _nodeRadius; _topRight = (Vector2)transform.position + Vector2.right * width / 2 + Vector2.up * height / 2 - Vector2.right * _nodeRadius - Vector2.up * _nodeRadius; var nodeCountTracker = 0; for (var i = 0; i < 4; i++) { var isWidth = i == 0 || i % 2 == 0; var nodeCount = isWidth ? width : height; var startingPoint = Vector2.zero; var direction = Vector2.zero; switch (i) { case 0: startingPoint = _bottomRight - Vector2.up * _nodeDiameter; direction = Vector2.left; break; case 1: startingPoint = _bottomLeft - Vector2.right * _nodeDiameter; direction = Vector2.up; break; case 2: startingPoint = _topLeft + Vector2.up * _nodeDiameter; direction = Vector2.right; break; case 3: startingPoint = _topRight + Vector2.right * _nodeDiameter; direction = Vector2.down; break; } for (var j = 0; j <= nodeCount; j++) { var nodePosition = startingPoint + direction * _nodeDiameter * j; _positions.Add(nodePosition); _boundaryGrid[nodeCountTracker] = new BoundaryNode(nodePosition, nodeCountTracker); nodeCountTracker++; } } foreach (var node in _boundaryGrid) { var previousNeighbor = node.NodeIndex == 0 ? _boundaryGrid[_boundaryGrid.Length - 1] : _boundaryGrid[node.NodeIndex - 1]; var nextNeighbor = node.NodeIndex == _boundaryGrid.Length - 1 ? _boundaryGrid[0] : _boundaryGrid[node.NodeIndex + 1]; node.SetNeighbors(previousNeighbor, nextNeighbor); } }
public void SetNeighbors(BoundaryNode previousNeighbor, BoundaryNode nextNeighbor) { PreviousNeighbor = previousNeighbor; NextNeighbor = nextNeighbor; }
// Token: 0x060000BF RID: 191 RVA: 0x00004FEC File Offset: 0x000031EC protected override TreeNode ProcessScopeSubQueryTree(TreeNode scopeSubQueryTree) { if (scopeSubQueryTree == null) { throw new ArgumentNullException("scopeSubQueryTree"); } ScopeNode scopeNode = scopeSubQueryTree as ScopeNode; if (scopeNode == null || scopeNode.Scope == null) { ULS.SendTraceTag(5884049U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 20, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: argument={0}; Erroneously entered ProcessScopeSubQueryTree with an argument that is not a ScopeNode. This should not have happened because the scopes of the associated operator should prevent it.", new object[] { scopeSubQueryTree.ToString() }); return(base.ProcessScopeSubQueryTree(scopeSubQueryTree)); } if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100)) { ULS.SendTraceTag(5884050U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: scope={0}; Processing a tree (or subtree) for data loss prevention translation from a virtual property to the actual index property.", new object[] { scopeNode.Scope }); } string scope = scopeNode.Scope; if (string.Equals("SensitiveType", scope, StringComparison.OrdinalIgnoreCase)) { BoundaryNode boundaryNode = scopeNode.Node as BoundaryNode; StringNode stringNode; TokenNode tokenNode; if (boundaryNode != null) { if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100)) { ULS.SendTraceTag(6038296U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: Boundary operator mode:{0}; Processing a boundary node in the query tree." + boundaryNode.BoundaryMode); } if (boundaryNode.BoundaryMode != 2 && boundaryNode.BoundaryMode != null) { ULS.SendTraceTag(5884051U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 50, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: Unexpected boundary operator mode. For 'SensitiveType' queries, only equality is legal. Boundary operator mode: " + boundaryNode.BoundaryMode); return(base.ProcessScopeSubQueryTree(scopeSubQueryTree)); } stringNode = (boundaryNode.Node as StringNode); tokenNode = (boundaryNode.Node as TokenNode); } else { stringNode = (scopeNode.Node as StringNode); tokenNode = (scopeNode.Node as TokenNode); } string text; if (stringNode != null) { text = stringNode.Text; } else { if (tokenNode == null) { ULS.SendTraceTag(5884052U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 50, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: Unexpected node type. The query looks like it is a 'SensitiveType' style query, but the value portion is not a StringNode or a TokenNode. Node type: " + boundaryNode.Node.GetType()); return(base.ProcessScopeSubQueryTree(scopeSubQueryTree)); } text = tokenNode.Token; } if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100)) { ULS.SendTraceTag(5884053U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: encoding={0}; About to parse the encoding.", new object[] { text }); } SensitiveTypeWildcardExpander sensitiveTypeWildcardExpander = new SensitiveTypeWildcardExpander(text, DLPQuerySensitiveTypeTranslationOperator.Store); if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100)) { ULS.SendTraceTag(5884054U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: About to create the new subtree."); } return(sensitiveTypeWildcardExpander.CreateSubtree()); } if (string.Equals("SensitiveMatchConfidence", scope, StringComparison.OrdinalIgnoreCase) || string.Equals("SensitiveMatchCount", scope, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException(scope + " is illegal to use in a query. You may use it as a select property. In queries, use SensitiveType"); } ULS.SendTraceTag(5884055U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 20, "DLPQuerySensitiveTypeTranslationProducer.ProcessScopeSubQueryTree :: scope={0}; This is not a legal scope for this producer. There must be some error in which the operator has the wrong scopes or a code change is incorrect. Ignoring and continuing.", new object[] { scope }); return(base.ProcessScopeSubQueryTree(scopeSubQueryTree)); }