示例#1
0
        /// <summary>
        /// Add an element to the end of a list
        /// </summary>
        /// <param name="list"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        public static QuestList <T> operator +(QuestList <T> list, T element)
        {
            //System.Diagnostics.Debug.Assert(false, "Operators on lists are deprecated");
            QuestList <T> result = new QuestList <T>(list);

            result.Add(element);
            return(result);
        }
示例#2
0
        /// <summary>
        /// Concatenates lists. Appends all items in list2 onto list1, except for any items in list2 which already appear in list1.
        /// </summary>
        /// <param name="list1"></param>
        /// <param name="list2"></param>
        /// <returns></returns>
        public static QuestList <T> operator *(QuestList <T> list1, QuestList <T> list2)
        {
            QuestList <T> result = new QuestList <T>(list1);

            foreach (T item in list2)
            {
                if (!list1.Contains(item))
                {
                    result.Add(item);
                }
            }
            return(result);
        }
示例#3
0
            private QuestList <object> LoadQuestList(XElement xml)
            {
                var result = new QuestList <object>();

                foreach (var xmlValue in xml.Elements("value"))
                {
                    var    typeAttr = xmlValue.Attribute("type");
                    string type     = typeAttr != null ? typeAttr.Value : null;
                    var    value    = GameLoader.ReadXmlValue(type, xmlValue);

                    result.Add(value);
                }
                return(result);
            }
        protected override object ConvertField(Element e, string fieldName, object value)
        {
            if (fieldName == "steps")
            {
                QuestList <string> steps  = (QuestList <string>)value;
                QuestList <string> result = new QuestList <string>();

                foreach (string step in steps)
                {
                    if (step.StartsWith("assert:"))
                    {
                        string     expr       = step.Substring(7);
                        Expression expression = new Expression(expr, e.Loader);
                        result.Add("assert:" + expression.Save(new Context()));
                    }
                    else
                    {
                        result.Add(step);
                    }
                }
                return(result);
            }
            return(value);
        }
            private QuestList <object> LoadQuestList(XElement xml)
            {
                var result = new QuestList <object>();

                foreach (var xmlValue in xml.Elements("value"))
                {
                    var typeAttribute = xmlValue.Attribute("type");
                    if (typeAttribute == null)
                    {
                        throw new Exception("Type not specified for value " + xmlValue);
                    }
                    string type  = typeAttribute.Value;
                    var    value = GameLoader.ReadXmlValue(type, xmlValue);

                    result.Add(value);
                }
                return(result);
            }
示例#6
0
 internal void AddInternal(T item)
 {
     m_source.Add(item, UpdateSource.User);
 }