示例#1
0
        /// <summary>
        /// Adds a module to this screen and sets up the AttachedComponent on the module.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="module"></param>
        /// <param name="load"></param>
        /// <param name="initialise"></param>
        /// <returns></returns>
        public T AddModule <T>(T module, bool load = false, bool initialise = false) where T : Module
        {
            // Set up reference to attached component
            module.AttachedComponent = this;

            // Checks to make sure we are not adding another copy of the same type of module - should only have one
            Debug.Assert(!Modules.Exists(x => x.GetType() == typeof(T)));
            return(Modules.AddChild(module, load, initialise));
        }