Example #1
0
        public EntityProperty(string Name, string Desc, EntityPropertyType Type, EntityPropertyLimits Limits, uint Flags = 0)
            : this(Name, Desc, Type)
        {
            if(Limits.max == 0 && Limits.min == 0)
            {
                limits.max = Sandbox.UIConstants.MAX_SLIDER_VALUE;
            }
            else
            {
                limits.max = Limits.max;
                limits.min = Limits.min;
            }

            flags = Flags;
        }
Example #2
0
        internal EntityConfig GetEntityConfig()
        {
            Type type = GetType();
            var properties = type.GetProperties();
            var fields = type.GetFields();
            var entityProperties = new List<object>();

            //Process all properties
            foreach(var property in properties)
            {
                if(property.ContainsAttribute<EditorPropertyAttribute>())
                {
                    var attribute = property.GetAttribute<EditorPropertyAttribute>();
                    EntityPropertyType propertyType = GetEditorType(property.PropertyType, attribute.Type);
                    var limits = new EntityPropertyLimits(attribute.Min, attribute.Max);
                    memberIsProperty.Add(property.Name, true);
                    entityProperties.Add(new EntityProperty(property.Name, attribute.Description, propertyType, limits, attribute.Flags));
                }
            }

            //Process all fields
            foreach(var field in fields)
            {
                if(field.ContainsAttribute<EditorPropertyAttribute>())
                {
                    var attribute = field.GetAttribute<EditorPropertyAttribute>();
                    EntityPropertyType propertyType = GetEditorType(field.FieldType, attribute.Type);
                    var limits = new EntityPropertyLimits(attribute.Min, attribute.Max);
                    memberIsProperty.Add(field.Name, false);
                    entityProperties.Add(new EntityProperty(field.Name, attribute.Description, propertyType, limits, attribute.Flags));
                }
            }

            return new EntityConfig(GetRegistrationConfig(type), entityProperties.ToArray());
        }