public override bool GetPortal(GraphNode other, List <Vector3> left, List <Vector3> right, bool backwards) { if (backwards) { return(true); } GridGraph gridGraph = GridNode.GetGridGraph(base.GraphIndex); int[] neighbourOffsets = gridGraph.neighbourOffsets; GridNode[] nodes = gridGraph.nodes; for (int i = 0; i < 4; i++) { if (this.GetConnectionInternal(i) && other == nodes[this.nodeInGridIndex + neighbourOffsets[i]]) { Vector3 a = (Vector3)(this.position + other.position) * 0.5f; Vector3 vector = Vector3.Cross(gridGraph.collision.up, (Vector3)(other.position - this.position)); vector.Normalize(); vector *= gridGraph.nodeSize * 0.5f; left.Add(a - vector); right.Add(a + vector); return(true); } } for (int j = 4; j < 8; j++) { if (this.GetConnectionInternal(j) && other == nodes[this.nodeInGridIndex + neighbourOffsets[j]]) { bool flag = false; bool flag2 = false; if (this.GetConnectionInternal(j - 4)) { GridNode gridNode = nodes[this.nodeInGridIndex + neighbourOffsets[j - 4]]; if (gridNode.Walkable && gridNode.GetConnectionInternal((j - 4 + 1) % 4)) { flag = true; } } if (this.GetConnectionInternal((j - 4 + 1) % 4)) { GridNode gridNode2 = nodes[this.nodeInGridIndex + neighbourOffsets[(j - 4 + 1) % 4]]; if (gridNode2.Walkable && gridNode2.GetConnectionInternal(j - 4)) { flag2 = true; } } Vector3 a2 = (Vector3)(this.position + other.position) * 0.5f; Vector3 vector2 = Vector3.Cross(gridGraph.collision.up, (Vector3)(other.position - this.position)); vector2.Normalize(); vector2 *= gridGraph.nodeSize * 1.4142f; left.Add(a2 - ((!flag2) ? Vector3.zero : vector2)); right.Add(a2 + ((!flag) ? Vector3.zero : vector2)); return(true); } } return(false); }
public override bool GetPortal(GraphNode other, List <Vector3> left, List <Vector3> right, bool backwards) { if (backwards) { return(true); } GridGraph gridGraph = GetGridGraph(base.GraphIndex); int[] neighbourOffsets = gridGraph.neighbourOffsets; GridNode[] nodes = gridGraph.nodes; for (int i = 0; i < 4; i++) { if (this.GetConnectionInternal(i) && (other == nodes[base.nodeInGridIndex + neighbourOffsets[i]])) { Vector3 vector = (Vector3)(((Vector3)(base.position + other.position)) * 0.5f); Vector3 vector2 = Vector3.Cross(gridGraph.collision.up, (Vector3)(other.position - base.position)); vector2.Normalize(); vector2 = (Vector3)(vector2 * (gridGraph.nodeSize * 0.5f)); left.Add(vector - vector2); right.Add(vector + vector2); return(true); } } for (int j = 4; j < 8; j++) { if (this.GetConnectionInternal(j) && (other == nodes[base.nodeInGridIndex + neighbourOffsets[j]])) { bool flag = false; bool flag2 = false; if (this.GetConnectionInternal(j - 4)) { GridNode node = nodes[base.nodeInGridIndex + neighbourOffsets[j - 4]]; if (node.Walkable && node.GetConnectionInternal(((j - 4) + 1) % 4)) { flag = true; } } if (this.GetConnectionInternal(((j - 4) + 1) % 4)) { GridNode node2 = nodes[base.nodeInGridIndex + neighbourOffsets[((j - 4) + 1) % 4]]; if (node2.Walkable && node2.GetConnectionInternal(j - 4)) { flag2 = true; } } Vector3 vector3 = (Vector3)(((Vector3)(base.position + other.position)) * 0.5f); Vector3 vector4 = Vector3.Cross(gridGraph.collision.up, (Vector3)(other.position - base.position)); vector4.Normalize(); vector4 = (Vector3)(vector4 * (gridGraph.nodeSize * 1.4142f)); left.Add(vector3 - (!flag2 ? Vector3.zero : vector4)); right.Add(vector3 + (!flag ? Vector3.zero : vector4)); return(true); } } return(false); }
public bool HasNodeConnection (GridNode node, int dir) { if (!node.GetConnectionInternal(dir)) return false; else if (!node.EdgeNode) { return true; } else { int index = node.NodeInGridIndex; int x; int z = System.Math.DivRem (index,Width, out x); return HasNodeConnection (index, x, z, dir); } }
public GridNode GetNodeConnection (GridNode node, int dir) { if (!node.GetConnectionInternal(dir)) return null; else if (!node.EdgeNode) { return nodes[node.NodeInGridIndex + neighbourOffsets[dir]]; } else { int index = node.NodeInGridIndex; int x; int z = System.Math.DivRem (index,Width, out x); return GetNodeConnection (index, x, z, dir); } }
public override bool GetPortal(GraphNode other, List <Vector3> left, List <Vector3> right, bool backwards) { if (backwards) { return(true); } GridGraph gg = GetGridGraph(GraphIndex); int[] neighbourOffsets = gg.neighbourOffsets; GridNode[] nodes = gg.nodes; for (int i = 0; i < 4; i++) { if (GetConnectionInternal(i) && other == nodes[nodeInGridIndex + neighbourOffsets[i]]) { Vector3 middle = ((Vector3)(position + other.position)) * 0.5f; Vector3 cross = Vector3.Cross(gg.collision.up, (Vector3)(other.position - position)); cross.Normalize(); cross *= gg.nodeSize * 0.5f; left.Add(middle - cross); right.Add(middle + cross); return(true); } } for (int i = 4; i < 8; i++) { if (GetConnectionInternal(i) && other == nodes[nodeInGridIndex + neighbourOffsets[i]]) { bool rClear = false; bool lClear = false; if (GetConnectionInternal(i - 4)) { GridNode n2 = nodes[nodeInGridIndex + neighbourOffsets[i - 4]]; if (n2.Walkable && n2.GetConnectionInternal((i - 4 + 1) % 4)) { rClear = true; } } if (GetConnectionInternal((i - 4 + 1) % 4)) { GridNode n2 = nodes[nodeInGridIndex + neighbourOffsets[(i - 4 + 1) % 4]]; if (n2.Walkable && n2.GetConnectionInternal(i - 4)) { lClear = true; } } Vector3 middle = ((Vector3)(position + other.position)) * 0.5f; Vector3 cross = Vector3.Cross(gg.collision.up, (Vector3)(other.position - position)); cross.Normalize(); cross *= gg.nodeSize * 1.4142f; left.Add(middle - (lClear ? cross : Vector3.zero)); right.Add(middle + (rClear ? cross : Vector3.zero)); return(true); } } return(false); }
public bool HasNodeConnection (GridNode node, int dir) { if (!node.GetConnectionInternal(dir)) return false; if (!node.EdgeNode) { return true; } else { int index = node.NodeInGridIndex; int z = index/Width; int x = index - z*Width; return HasNodeConnection(index, x, z, dir); } }
public GridNode GetNodeConnection (GridNode node, int dir) { if (!node.GetConnectionInternal(dir)) return null; else if (!node.EdgeNode) { return nodes[node.NodeInGridIndex + neighbourOffsets[dir]]; } else { var index = node.NodeInGridIndex; //int z = Math.DivRem (index,Width, out x); var z = index/Width; var x = index - z*Width; return GetNodeConnection (index, x, z, dir); } }