Esempio n. 1
0
        // Token: 0x06001D81 RID: 7553 RVA: 0x00089754 File Offset: 0x00087954
        private void AddLink(MapNode nodeB, float distanceScore, float minJumpHeight, HullClassification hullClassification)
        {
            int num = this.links.FindIndex((MapNode.Link item) => item.nodeB == nodeB);

            if (num == -1)
            {
                this.links.Add(new MapNode.Link
                {
                    nodeB = nodeB
                });
                num = this.links.Count - 1;
            }
            MapNode.Link link = this.links[num];
            link.distanceScore = Mathf.Max(link.distanceScore, distanceScore);
            link.minJumpHeight = Mathf.Max(link.minJumpHeight, minJumpHeight);
            link.hullMask     |= 1 << (int)hullClassification;
            if (minJumpHeight > 0f)
            {
                link.jumpHullMask |= 1 << (int)hullClassification;
            }
            if (string.IsNullOrEmpty(link.gateName))
            {
                link.gateName = nodeB.gateName;
            }
            this.links[num] = link;
        }
Esempio n. 2
0
        // Token: 0x06001D85 RID: 7557 RVA: 0x00089C04 File Offset: 0x00087E04
        public void BuildLinks(ReadOnlyCollection <MapNode> nodes, MapNodeGroup.GraphType graphType)
        {
            this.links.Clear();
            Vector3 position = base.transform.position;

            MapNode.MoveProbe moveProbe = new MapNode.MoveProbe();
            moveProbe.Init();
            switch (graphType)
            {
            case MapNodeGroup.GraphType.Ground:
                this.BuildGroundLinks(nodes, moveProbe);
                break;

            case MapNodeGroup.GraphType.Air:
                this.BuildAirLinks(nodes, moveProbe);
                break;

            case MapNodeGroup.GraphType.Rail:
                this.BuildRailLinks(nodes, moveProbe);
                break;
            }
            foreach (MapNodeLink mapNodeLink in base.GetComponents <MapNodeLink>())
            {
                if (mapNodeLink.other)
                {
                    MapNode.Link link = new MapNode.Link
                    {
                        nodeB         = mapNodeLink.other,
                        distanceScore = Vector3.Distance(position, mapNodeLink.other.transform.position),
                        minJumpHeight = mapNodeLink.minJumpHeight,
                        gateName      = mapNodeLink.gateName,
                        hullMask      = -1
                    };
                    bool flag = false;
                    for (int j = 0; j < this.links.Count; j++)
                    {
                        if (this.links[j].nodeB == mapNodeLink.other)
                        {
                            this.links[j] = link;
                            flag          = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        this.links.Add(link);
                    }
                }
            }
            moveProbe.Destroy();
        }
Esempio n. 3
0
        // Token: 0x06001DD9 RID: 7641 RVA: 0x0007FC08 File Offset: 0x0007DE08
        public void SetNodes(ReadOnlyCollection <MapNode> mapNodes, ReadOnlyCollection <SerializableBitArray> lineOfSightMasks)
        {
            this.Clear();
            Dictionary <MapNode, NodeGraph.NodeIndex> dictionary = new Dictionary <MapNode, NodeGraph.NodeIndex>();
            List <NodeGraph.Node> list  = new List <NodeGraph.Node>();
            List <NodeGraph.Link> list2 = new List <NodeGraph.Link>();

            for (int i = 0; i < mapNodes.Count; i++)
            {
                MapNode key = mapNodes[i];
                dictionary[key] = new NodeGraph.NodeIndex(i);
            }
            for (int j = 0; j < mapNodes.Count; j++)
            {
                MapNode             mapNode    = mapNodes[j];
                NodeGraph.NodeIndex nodeIndexA = dictionary[mapNode];
                int count = list2.Count;
                for (int k = 0; k < mapNode.links.Count; k++)
                {
                    MapNode.Link link = mapNode.links[k];
                    if (!dictionary.ContainsKey(link.nodeB))
                    {
                        Debug.LogErrorFormat(link.nodeB, "[{0}] Node {1} was not registered.", new object[]
                        {
                            k,
                            link.nodeB
                        });
                    }
                    list2.Add(new NodeGraph.Link
                    {
                        nodeIndexA    = nodeIndexA,
                        nodeIndexB    = dictionary[link.nodeB],
                        distanceScore = link.distanceScore,
                        minJumpHeight = link.minJumpHeight,
                        hullMask      = link.hullMask,
                        jumpHullMask  = link.jumpHullMask,
                        gateIndex     = this.RegisterGateName(link.gateName)
                    });
                }
                HullMask hullMask = mapNode.forbiddenHulls;
                for (HullClassification hullClassification = HullClassification.Human; hullClassification < HullClassification.Count; hullClassification++)
                {
                    bool flag = false;
                    int  num  = 1 << (int)hullClassification;
                    List <MapNode.Link> list3 = mapNode.links;
                    for (int l = 0; l < list3.Count; l++)
                    {
                        if ((list3[l].hullMask & num) != 0)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        hullMask |= (HullMask)num;
                    }
                }
                list.Add(new NodeGraph.Node
                {
                    position      = mapNode.transform.position,
                    linkListIndex = new NodeGraph.LinkListIndex
                    {
                        index = count,
                        size  = (uint)mapNode.links.Count
                    },
                    forbiddenHulls  = hullMask,
                    flags           = mapNode.flags,
                    lineOfSightMask = new SerializableBitArray(lineOfSightMasks[j]),
                    gateIndex       = this.RegisterGateName(mapNode.gateName)
                });
            }
            this.nodes = list.ToArray();
            this.links = list2.ToArray();
        }