protected override RenderData CreateDataInstance(SerializedPropertyX property, bool isNewTarget)
    {
        var data = new DecisionRenderData();

        data.isDisplayed   = !isNewTarget;
        data.isActionShown = false;
        data.considerationSection.SetTargetProperty(property["evaluator"]);
        data.requirementSection.SetTargetProperty(property["evaluator"]);
        return(data);
    }
    protected override void AddListItem(Type type)
    {
        listRoot.ArraySize++;
        SerializedPropertyX newChild = listRoot.GetChildAt(listRoot.ArraySize - 1);
        var decision = new Decision();

        decision.action    = Activator.CreateInstance(type) as CharacterAction;
        decision.name      = decision.action.GetType().Name;
        decision.evaluator = new DecisionEvaluator(decision.action.ContextType);
        newChild.Value     = decision;
        DecisionRenderData data = CreateDataInstance(newChild, true) as DecisionRenderData;

        renderData.Add(data);
    }
    protected override void RenderBody(SerializedPropertyX property, RenderData renderData, int index)
    {
        DecisionRenderData data = renderData as DecisionRenderData;

        EditorGUI.indentLevel++;

        EditorGUILayoutX.PropertyField(property["name"]);
        EditorGUILayoutX.PropertyField(property["description"]);
        EditorGUILayoutX.PropertyField(property["weight"]);

        SerializedPropertyX action    = property["action"];
        SerializedPropertyX collector = property["contextCollector"];

        CharacterAction charAction    = action.GetValue <CharacterAction>();
        string          contextString = "<" + charAction.ContextType.Name + ">";
        string          actionString  = "Action (" + action.Type.Name + contextString + ")";

        if (action.ChildCount > 0)
        {
            data.isActionShown = EditorGUILayout.Foldout(data.isActionShown, actionString);
        }
        else
        {
            GUIContent content = new GUIContent(actionString);
            content.image = EditorGUIUtility.FindTexture("cs Script Icon");
            EditorGUILayout.LabelField(content);
            data.isActionShown = false;
        }
        if (data.isActionShown)
        {
            EditorGUI.indentLevel++;
            EditorGUILayoutX.DrawProperties(action);
            EditorGUI.indentLevel--;
        }

        data.GetContextCollectorData(charAction, collector.GetValue <ContextCollector>());
        string[] options      = data.contextCollectorNames;
        int      currentIndex = data.contextCollectorIndex;
        int      idx          = EditorGUILayout.Popup("Collector", currentIndex, options, GUILayout.Width(EditorGUIUtility.labelWidth + 300f));

        if (idx != data.contextCollectorIndex)
        {
            if (idx == 0)
            {
                collector.Value = null; //todo return an empty collector type?
            }
            else
            {
                Type newCollectorType = data.contextCollectorTypes[idx];
                collector.Value = Activator.CreateInstance(newCollectorType) as ContextCollector;
            }
        }
        if (collector.Value != null)
        {
            EditorGUI.indentLevel++;
            EditorGUILayoutX.DrawProperties(collector);
            EditorGUI.indentLevel--;
        }

        data.isEvaluatorShown = EditorGUILayout.Foldout(data.isEvaluatorShown, "Evaluator");
        if (data.isEvaluatorShown)
        {
            EditorGUI.indentLevel++;
            SerializedPropertyX evaluator      = property["evaluator"];
            SerializedPropertyX considerations = evaluator["considerations"];
            SerializedPropertyX requirements   = evaluator["requirements"];
            if (considerations.ChildCount == 0 && requirements.ChildCount == 0)
            {
                data.GetEvaluatorTemplateData(charAction.ContextType);
                int newIdx = EditorGUILayout.Popup("Set From Template", 0, data.evaluatorOptions, GUILayout.Width(EditorGUIUtility.labelWidth + 300f));
                if (newIdx != 0)
                {
                    evaluator.Value = data.evaluatorCreators[newIdx].Create();
                    data.requirementSection.SetTargetProperty(evaluator);
                    data.considerationSection.SetTargetProperty(evaluator);
                }
            }
            data.requirementSection.Render();
            data.considerationSection.Render();
            EditorGUI.indentLevel--;
        }
        EditorGUI.indentLevel--;
    }