Ejemplo n.º 1
0
 /// <summary> Check if a component is cached as valid </summary>
 private bool IsValid(GunComponent component)
 {
     if (!validation_cache_components.ContainsKey(component.GetType()))
     {
         return(false);
     }
     return(validation_cache_components[component.GetType()]);
 }
Ejemplo n.º 2
0
    /// <summary> Check if a property is cached as valid </summary>
    private bool IsValid(SerializedProperty property, GunComponent component)
    {
        FieldInfo field = component.GetType().GetField(property.name);

        if (!validation_cache_fields.ContainsKey(field))
        {
            return(false);
        }
        return(validation_cache_fields[field]);
    }
Ejemplo n.º 3
0
    bool isTiered <T>(GunComponent gc) where T : struct,
    System.IComparable,
    System.IComparable <T>,
    System.IConvertible,
    System.IEquatable <T>,
    System.IFormattable
    {
        var val = typeof(ITierable <T>).IsAssignableFrom(gc.GetType());

        //Debug.Log(
        //    $"type: {gc.GetType()}, " +
        //    $"t: {typeof(T)}, " +
        //    $"val: {val}");
        return(val);
    }
Ejemplo n.º 4
0
    public void DrawAspects()
    {
        // Draw Header
        EditorGUI.BeginChangeCheck();
        foreach (GunAspect aspect in possible_aspects)
        {
            if (aspect.IsEmpty() || !loaded_aspects.HasFlag(aspect))
            {
                continue;
            }

            GunComponent component = GetComponentFromAspect(aspect);
            if (!component || !ShouldShowComponent(component.GetType()))
            {
                continue;
            }

            bool show_error = !IsValid(component);
            if (show_error)
            {
                BeginError();
            }

            GUILayout.BeginVertical("Box");
            EditorGUI.indentLevel++;

            // Show Aspect Header
            bool unfold = EditorGUILayout.Foldout(expanded_aspects.HasFlag(aspect), aspect.GetGUIContent(), true, EditorStyles.label);

            // Display Aspect Data
            if (unfold)
            {
                DrawAspectData(component);
            }

            // Update folded Aspects
            if (unfold != expanded_aspects.HasFlag(aspect))
            {
                if (unfold)
                {
                    expanded_aspects = expanded_aspects | aspect;
                }
                else
                {
                    expanded_aspects = ~(~expanded_aspects | aspect);
                }
            }

            // Endgroup
            EditorGUI.indentLevel--;
            GUILayout.EndVertical();
            if (show_error)
            {
                EndError();
            }
        }

        if (EditorGUI.EndChangeCheck())
        {
            UpdateValidationCache();
        }
    }