Example #1
0
        private void AddComplexType(XElement element)
        {
            // Get the type name
            var typeName = element.GetAttributeValue("Class");

            if (typeName == null)
            {
                throw new ProtocolMalformedException("All members of type ComplexType/ListOfComplexType must have a Class.");
            }


            var members = element
                          .Elements()
                          .Where(member => member.Name.LocalName == "Member");

            //if has members
            if (members.Count() > 0)
            {
                if (CustomTypes.Any(ct => ct.Name == typeName))
                {
                    throw new ProtocolMalformedException("Complex type have 2 definitions");
                }

                var complexType = new CustomType(typeName);

                foreach (var xmember in members)
                {
                    complexType.Members.Add(GetMember(xmember));
                }

                CustomTypes.Add(complexType);
            }
        }
Example #2
0
 public void AddCustomTag(string tagname, int tagValue)
 {
     if (CustomTypes != null)
     {
         CustomTypes.Add(new s_customType(tagname, tagValue));
     }
     else
     {
         CustomTypes = new List <s_customType>();
         CustomTypes.Add(new s_customType(tagname, tagValue));
     }
 }
Example #3
0
 public void AddCustomTag(string tagname, Vector2Int tagval)
 {
     if (CustomTypes != null)
     {
         CustomTypes.Add(new s_customType(tagname, tagval.x, tagval.y));
     }
     else
     {
         CustomTypes = new List <s_customType>();
         CustomTypes.Add(new s_customType(tagname, tagval.x, tagval.y));
     }
 }
Example #4
0
        /// <summary>
        ///     Look for SLUI custom component types in currently all loaded assemblies.
        /// </summary>
        public static void LookForCustomTypes()
        {
            CustomTypes.Clear();
            foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (var t in a.GetTypes())
                {
                    var attributes = t.GetCustomAttributes(typeof(SLUIComponentAttribute), true);
                    if (attributes.Length > 0)
                    {
                        CustomTypes.Add(t.Name, t);
                    }
                }
            }

            Debug.Log($"{CustomTypes.Count} SLUI's custom component types found.");
        }