コード例 #1
0
        List <BiomeSwitchData> GetPrecedentSwitchDatas(PWNode currentNode, PWNode rootNode)
        {
            var precedentSwitchDatas = new List <BiomeSwitchData>();

            PWNode n = currentNode;

            while (n != rootNode)
            {
                PWNode prevNode = n;
                n = n.GetInputNodes().First();
                if (n.GetType() != typeof(PWNodeBiomeSwitch))
                {
                    break;
                }

                var switches = (n as PWNodeBiomeSwitch).switchList;

                int index = n.outputAnchors.ToList().FindIndex(a => a.links.Any(l => l.toNode == prevNode));

                if (index == -1)
                {
                    throw new Exception("[PWBiomeSwitchGraph] IMPOSSIBRU !!!!! check your node API !");
                }

                precedentSwitchDatas.Add(switches[index]);
            }

            precedentSwitchDatas.Reverse();

            return(precedentSwitchDatas);
        }
コード例 #2
0
        void UpdateRelativeBounds()
        {
            var inputNodes = GetInputNodes();

            if (inputNodes.Count() == 0)
            {
                return;
            }

            PWNode prevNode    = inputNodes.First();
            PWNode currentNode = this;

            while (prevNode.GetType() == typeof(PWNodeBiomeSwitch))
            {
                PWNodeBiomeSwitch prevSwitch = (PWNodeBiomeSwitch)prevNode;

                if (prevSwitch.samplerName != samplerName)
                {
                    inputNodes = prevNode.GetInputNodes();

                    if (inputNodes.Count() == 0)
                    {
                        return;
                    }

                    currentNode = prevNode;
                    prevNode    = inputNodes.First();
                    continue;
                }

                var prevNodeOutputAnchors = prevSwitch.outputAnchors.ToList();

                for (int i = 0; i < prevNodeOutputAnchors.Count; i++)
                {
                    var anchor = prevNodeOutputAnchors[i];

                    if (anchor.links.Any(l => l.toNode == currentNode))
                    {
                        relativeMin = prevSwitch.switchList.switchDatas[i].min;
                        relativeMax = prevSwitch.switchList.switchDatas[i].max;
                    }
                }

                break;
            }

            if (prevNode.GetType() != typeof(PWNodeBiomeSwitch))
            {
                //update currentSampler value:
                if (inputBiome != null)
                {
                    currentSampler = inputBiome.GetSampler(samplerName);
                }

                if (currentSampler == null)
                {
                    return;
                }

                relativeMin = currentSampler.min;
                relativeMax = currentSampler.max;
                return;
            }
        }