Ejemplo n.º 1
0
        /// <summary>
        /// Merge multiple ParameterBundles into one. Note that parameters with the same key will override each other and parameters with the same key but different value will be ignored
        /// </summary>
        /// <param name="bundles"></param>
        /// <returns></returns>
        public static ParameterBundle Merge(List <ParameterBundle> bundles)
        {
            ParameterBundle merged = new ParameterBundle();

            foreach (ParameterBundle bundle in bundles)
            {
                foreach (KeyValuePair <string, object> pair in bundle.parameters)
                {
                    if (!merged.Set(pair.Key, pair.Value))
                    {
                        merged.Put(pair.Key, pair.Value);
                    }
                }
            }
            return(merged);
        }
Ejemplo n.º 2
0
        public void AnyExecute(ParameterBundle bundle)
        {
            Profiler.BeginSample("LSystem.Seed.Execute");

            if (previous != null)
            {
                transform.position = previous.transform.position;
            }

            Sentence sentence = new Sentence(axiom);

            if (generateMode == GenMode.PreEdgeRewrite)
            {
                //Pre calculate final sentence.
                for (int i = 0; i < iterations; i++)
                {
                    sentence = rules.NextGeneration(sentence);
                }
                rules.Fertile = false;
                bundle.SetOrPut("Iterations", 0);
            }
            else // if(preGrow == GenMode.IterateNodeRewrite)
            {
                rules.Fertile = true;
                bundle.SetOrPut("Iterations", iterations);
            }

            bundle.SetOrPut("Generation", 0);
            bundle.SetOrPut("Sentence", sentence);
            bundle.SetOrPut("Implementations", implementations);
            bundle.SetOrPut("RuleSet", rules);


            if (!bundle.Exists("Position"))
            {
                bundle.Put("Position", transform.position);
            }

            if (!inheritRotation)
            {
                bundle.SetOrPut("Rotation", transform.rotation);
            }
            else if (!bundle.Exists("Rotation"))
            {
                bundle.Put("Rotation", transform.rotation);
            }

            // execute modules in the axiom
            if (!executed)
            {
                executed = true;

                if (baked)
                {
                    BakeNextModule(transform, sentence, implementations, rules, bundle);
                }
                else
                {
                    EnqueueProcessNextModule(transform, sentence, implementations, rules, bundle);
                }
            }
            Profiler.EndSample();
        }