Beispiel #1
0
        /// <summary>
        /// Get the OptionsType equivilent of the provided Type.
        /// </summary>
        /// <returns>The option type.</returns>
        /// <param name="type">Type.</param>
        public static Type GetOptionType(Type type)
        {
            Type otherType;

            if (OptionsClassMapping.TryGetValue(type, out otherType))
            {
                return(otherType);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Map out the ClassTypes with the appropriate OptionsType.  Used in the Editor,
        /// so when creating the BaseClass, it knows what OptionsClass to update.
        /// </summary>
        /// <param name="debug">If set to <c>true</c> debug.</param>
        public static void UpdateOptionClassMapping(bool debug = false)
        {
            //UpdateAvailibleTypes();


            //  Add all the derived classes.
            foreach (KeyValuePair <Type, Type> item in AvailibleTypes)
            {
                if (OptionsClassMapping.ContainsKey(item.Key) == false &&
                    item.Value == typeof(Selector))
                {
                    OptionsClassMapping.Add(item.Key, typeof(SelectorOption));
                }
                else if (OptionsClassMapping.ContainsKey(item.Key) == false &&
                         item.Value == typeof(QualifierBase) ||
                         item.Value == typeof(DefaultQualifier))
                {
                    OptionsClassMapping.Add(item.Key, typeof(QualifierOption));
                }
                else if (OptionsClassMapping.ContainsKey(item.Key) == false &&
                         item.Value == typeof(ActionBase))
                {
                    OptionsClassMapping.Add(item.Key, typeof(ActionOption));
                }
                else if (OptionsClassMapping.ContainsKey(item.Key) == false &&
                         item.Value == typeof(ScorerBase))
                {
                    OptionsClassMapping.Add(item.Key, typeof(ScorersOption));
                }
                //else{
                //    Debug.Log(string.Format("No match for {0} ", item.Key ));
                //}
            }


            if (debug)
            {
                var debug_log = "";
                foreach (KeyValuePair <Type, Type> item in OptionsClassMapping)
                {
                    debug_log += string.Format("Key: {0}, Value: {1}\n", item.Key, item.Value);
                }
                Debug.Log(debug_log);
            }
        }