// Token: 0x060001DA RID: 474 RVA: 0x00009C70 File Offset: 0x00007E70 public SerializableBitArray(SerializableBitArray src) { if (src.bytes != null) { this.bytes = new byte[src.bytes.Length]; src.bytes.CopyTo(this.bytes, 0); } this.length = src.length; }
// Token: 0x06001D9C RID: 7580 RVA: 0x0008A6D8 File Offset: 0x000888D8 public void Bake(NodeGraph nodeGraph) { List <MapNode> nodes = this.GetNodes(); ReadOnlyCollection <MapNode> readOnlyCollection = nodes.AsReadOnly(); for (int i = 0; i < nodes.Count; i++) { nodes[i].BuildLinks(readOnlyCollection, this.graphType); } List <SerializableBitArray> list = new List <SerializableBitArray>(); for (int j = 0; j < nodes.Count; j++) { MapNode mapNode = nodes[j]; SerializableBitArray serializableBitArray = new SerializableBitArray(nodes.Count); for (int k = 0; k < nodes.Count; k++) { MapNode other = nodes[k]; serializableBitArray[k] = mapNode.TestLineOfSight(other); } list.Add(serializableBitArray); } nodeGraph.SetNodes(readOnlyCollection, list.AsReadOnly()); }
private void BuildGroundNodes(GameObject arena) { //Destroy existing nodes Object.DestroyImmediate(GameObject.Find("TestSceneGroundNode")); var nodeGroupObj = Object.Instantiate(new GameObject("GroundNodes")); var nodeGroup = nodeGroupObj.AddComponent <MapNodeGroup>(); //We're going to distribute ground nodes as a vertex fan around the central ring platform //First, we'll generate these positions as local positions const int n = 40; const float dw = 2 * Mathf.PI / n; const float r1 = 35f; const float r2 = 45f; const float y = 0.2f; var ringVertices = new Vector3[n]; for (int i = 0; i < n; i++) { var r = (i & 1) == 0 ? r1 : r2; var w = i * dw; var x = r * Mathf.Cos(w); var z = r * Mathf.Sin(w); ringVertices[i] = new Vector3(x, y, z); } //Transform the local vertices into world space around the central arena and use those to construct nodes var centralArena = GameObject.Find("Central Arena"); var nodes = new MapNode[n]; for (int i = 0; i < n; i++) { var p = centralArena.transform.TransformPoint(ringVertices[i]); var nodeObj = Object.Instantiate(new GameObject("MapNode"), nodeGroupObj.transform); nodes[i] = nodeObj.AddComponent <MapNode>(); nodes[i].flags = NodeFlags.NoCeiling; nodes[i].transform.position = p; } //Construct links based on tri strip topology var lineOfSightMasks = new SerializableBitArray[n]; for (int i = 0; i < n; i++) { var links = new List <MapNode.Link>(4); for (int k = -2; k <= 2; k++) { if (k == 0) { continue; } int relIdx = (i + k) % n; if (relIdx < 0) { relIdx += n; } var link = new MapNode.Link { nodeB = nodes[relIdx], distanceScore = Vector3.Distance(nodes[i].transform.position, nodes[relIdx].transform.position), minJumpHeight = 100f, hullMask = -1 }; links.Add(link); } nodes[i].links = links; var losMask = new SerializableBitArray(n); for (int j = 0; j < n; j++) { losMask[j] = true; } lineOfSightMasks[i] = losMask; } nodeGroup.graphType = MapNodeGroup.GraphType.Ground; nodeGroup.nodeGraph = new NodeGraph(); nodeGroup.nodeGraph.SetNodes(new ReadOnlyCollection <MapNode>(nodes), new ReadOnlyCollection <SerializableBitArray>(lineOfSightMasks)); nodeGroup.nodeGraph.DebugDrawLinks(HullClassification.Human); SceneInfo.instance.groundNodes = nodeGroup.nodeGraph; SceneInfo.instance.groundNodeGroup = nodeGroup; }