/**
         * Override the contents of this definition set with another.
         */
        public virtual void OverrideBy(MyDefinitionSet definitionSet)
        {
            MyDefinitionPostprocessor.Bundle myBundle = new MyDefinitionPostprocessor.Bundle()
            {
                Set     = this,
                Context = Context
            };

            MyDefinitionPostprocessor.Bundle thyBundle = new MyDefinitionPostprocessor.Bundle()
            {
                Set     = definitionSet,
                Context = definitionSet.Context
            };

            foreach (var defgrp in definitionSet.Definitions)
            {
                Dictionary <MyStringHash, MyDefinitionBase> dict;
                if (!Definitions.TryGetValue(defgrp.Key, out dict))
                {
                    dict = new Dictionary <MyStringHash, MyDefinitionBase>();
                    Definitions[defgrp.Key] = dict;
                }

                var pp = MyDefinitionManagerBase.GetPostProcessor(defgrp.Key);

                myBundle.Definitions  = dict;
                thyBundle.Definitions = defgrp.Value;

                pp.OverrideBy(ref myBundle, ref thyBundle);
            }
        }
Exemple #2
0
        /**
         * Override the contents of this definition set with another.
         */
        public virtual void OverrideBy(MyDefinitionSet definitionSet)
        {
            MyDefinitionPostprocessor.Bundle myBundle = new MyDefinitionPostprocessor.Bundle()
            {
                Set     = this,
                Context = Context
            };

            MyDefinitionPostprocessor.Bundle thyBundle = new MyDefinitionPostprocessor.Bundle()
            {
                Set     = definitionSet,
                Context = definitionSet.Context
            };

            foreach (var defgrp in definitionSet.Definitions)
            {
                Dictionary <MyStringHash, MyDefinitionBase> dict;
                if (!Definitions.TryGetValue(defgrp.Key, out dict))
                {
                    dict = new Dictionary <MyStringHash, MyDefinitionBase>();
                    Definitions[defgrp.Key] = dict;
                }

                // TODO: Postprocessing should be per definition type, not typeid.
                var pp = MyDefinitionManagerBase.GetPostProcessor(defgrp.Key);

                // Since that is too big a refactor this should fix it in the meantime.
                // This line gets me sick :(
                if (pp == null)
                {
                    pp = MyDefinitionManagerBase.GetPostProcessor(
                        MyDefinitionManagerBase.GetObjectBuilderType(defgrp.Value.First().Value.GetType()));
                }

                myBundle.Definitions  = dict;
                thyBundle.Definitions = defgrp.Value;

                pp.OverrideBy(ref myBundle, ref thyBundle);
            }
        }