示例#1
0
    void AddBackgroundFor(List <Vector3> coords)
    {
        if (nodeMap == null || nodeMap.Length == 0)
        {
            return;
        }

        List <StreamingMapNode> nodes = new List <StreamingMapNode>();

        for (int i = 0; i < coords.Count; i++)
        {
            int x = (int)coords[i].x;
            int y = (int)coords[i].y;
            int z = (int)coords[i].z;

            StreamingMapNode n = nodeMap[GetIndexFor(x, y, z)];

            if (n == null)
            {
                coords.RemoveAt(i);
                i--;
                continue;
            }

            Material m = n.backgroundEntry;

            if (m == null)
            {
                coords.RemoveAt(i);
                i--;
                continue;
            }

            nodes.Add(n);
        }

        while (nodes.Count > 0)
        {
            StreamingMapNode n = nodes[0];

            List <Vector3> mNodes = new List <Vector3>();

            for (int j = 0; j < nodes.Count; j++)
            {
                if (n.backgroundEntry == nodes[j].backgroundEntry)
                {
                    mNodes.Add(coords[j]);
                    nodes.RemoveAt(j);
                    coords.RemoveAt(j);
                    j--;
                }
            }

            if (!blockMap.HasBackgroundEntryFor(n.backgroundEntry.name))
            {
                blockMap.AddBackground(n.backgroundEntry);
            }

            blockMap.AddEntryToBackground(mNodes.ToArray(), n.backgroundEntry.name);
        }

        backgroundChanged = true;
    }