Esempio n. 1
0
        private void GroupingOutput(BuildTarget target,
                                    Model.NodeData node,
                                    IEnumerable <PerformGraph.AssetGroups> incoming,
                                    IEnumerable <Model.ConnectionData> connectionsToOutput,
                                    PerformGraph.Output Output)
        {
            ValidateGroupingKeyword(
                m_groupSizeByte[target],
                () => {
                throw new NodeException("Invalid size.", node.Id);
            }
                );

            if (connectionsToOutput == null || Output == null)
            {
                return;
            }

            var  outputDict = new Dictionary <string, List <AssetReference> >();
            long szGroup    = m_groupSizeByte[target] * 1000;

            int  groupCount   = 0;
            long szGroupCount = 0;

            if (m_freezeGroups && m_savedGroups != null)
            {
                while (m_savedGroups.ContainsKey(groupCount.ToString()))
                {
                    ++groupCount;
                }
            }
            var groupName = groupCount.ToString();

            if (incoming != null)
            {
                foreach (var ag in incoming)
                {
                    foreach (var assets in ag.assetGroups.Values)
                    {
                        foreach (var a in assets)
                        {
                            if (m_freezeGroups && m_savedGroups != null)
                            {
                                var savedGroupName = m_savedGroups.FindGroupOfAsset(a.importFrom);
                                if (!string.IsNullOrEmpty(savedGroupName))
                                {
                                    if (!outputDict.ContainsKey(savedGroupName))
                                    {
                                        outputDict[savedGroupName] = new List <AssetReference>();
                                    }
                                    outputDict[savedGroupName].Add(a);
                                    continue;
                                }
                            }

                            szGroupCount += GetSizeOfAsset(a, (GroupingType)m_groupingType[target]);

                            if (!outputDict.ContainsKey(groupName))
                            {
                                outputDict[groupName] = new List <AssetReference>();
                            }
                            outputDict[groupName].Add(a);

                            if (szGroupCount >= szGroup)
                            {
                                szGroupCount = 0;
                                ++groupCount;
                                if (m_freezeGroups && m_savedGroups != null)
                                {
                                    while (m_savedGroups.ContainsKey(groupCount.ToString()))
                                    {
                                        ++groupCount;
                                    }
                                }
                                groupName = groupCount.ToString();
                            }
                        }
                    }
                }
            }

            var dst = (connectionsToOutput == null || !connectionsToOutput.Any())?
                      null : connectionsToOutput.First();

            Output(dst, outputDict);

            if (m_groupViewController == null)
            {
                m_groupViewController = new GroupViewController(m_groupViewContext);
            }
            m_groupViewController.SetGroups(outputDict);
            m_lastOutputGroups = outputDict;
        }