protected override void GenerateMethod(Attachment attachment, StringWriter stream, string indent)
        {
            base.GenerateMethod(attachment, stream, indent);

            AttachAction attach = attachment as AttachAction;

            if (attach == null)
            {
                return;
            }

            stream.WriteLine("{0}\t\tvirtual EBTStatus update_impl(Agent* pAgent, EBTStatus childStatus)", indent);
            stream.WriteLine("{0}\t\t{{", indent);
            stream.WriteLine("{0}\t\t\tEBTStatus result = BT_SUCCESS;", indent);

            if (attach.IsAction())
            {
                string method = MethodCppExporter.GenerateCode(attachment, attach.Opl.Method, stream, indent + "\t\t\t", string.Empty, string.Empty, "opl");

                stream.WriteLine("{0}\t\t\t{1};", indent, method);
                MethodCppExporter.PostGenerateCode(attach.Opl.Method, stream, indent + "\t\t\t", string.Empty, string.Empty, "opl");
            }
            else if (attach.IsAssign())
            {
                if (attach.Opl != null && !attach.Opl.IsMethod && attach.Opl.Var != null && attach.Opr2 != null)
                {
                    PropertyDef prop = attach.Opl.Var.Property;

                    if (prop != null)
                    {
                        RightValueCppExporter.GenerateCode(attachment, attach.Opr2, stream, indent + "\t\t\t", attach.Opr2.NativeType, "opr2", "opr2");

                        string property = PropertyCppExporter.GetProperty(attachment, prop, attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "opl", "attach");
                        string propName = prop.BasicName.Replace("[]", "");

                        if (prop.IsArrayElement && attach.Opl.Var.ArrayIndexElement != null)
                        {
                            ParameterCppExporter.GenerateCode(attachment, attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "int", "opl_index", "attach_opl");
                            property = string.Format("({0})[opl_index]", property);
                        }

                        if (!prop.IsArrayElement && (prop.IsPar || prop.IsCustomized))
                        {
                            string propBasicName = prop.BasicName.Replace("[]", "");
                            uint   id            = Behaviac.Design.CRC32.CalcCRC(propBasicName);
                            string agentName     = PropertyCppExporter.GetGenerateAgentName(prop, "opl", "attach");

                            stream.WriteLine("{0}\t\t\t{1}->SetVariable(\"{2}\", {3}u, opr2);", indent, agentName, propBasicName, id);
                        }
                        else
                        {
                            stream.WriteLine("{0}\t\t\t{1} = opr2;", indent, property);
                        }

                        if (attach.Opr2.IsMethod)
                        {
                            RightValueCppExporter.PostGenerateCode(attach.Opr2, stream, indent + "\t\t\t", attach.Opr2.NativeType, "opr2", string.Empty);
                        }
                    }
                }
            }
            else if (attach.IsCompare())
            {
                ConditionCppExporter.GenerateOperand(attachment, stream, indent + "\t\t\t", attach.Opl, "opl", "");
                ConditionCppExporter.GenerateOperand(attachment, stream, indent + "\t\t\t", attach.Opr2, "opr2", "");

                switch (attach.Operator)
                {
                case OperatorTypes.Equal:
                    stream.WriteLine("{0}\t\t\tbool op = PrivateDetails::Equal(opl, opr2);", indent);
                    break;

                case OperatorTypes.NotEqual:
                    stream.WriteLine("{0}\t\t\tbool op = !PrivateDetails::Equal(opl, opr2);", indent);
                    break;

                case OperatorTypes.Greater:
                    stream.WriteLine("{0}\t\t\tbool op = PrivateDetails::Greater(opl, opr2);", indent);
                    break;

                case OperatorTypes.GreaterEqual:
                    stream.WriteLine("{0}\t\t\tbool op = PrivateDetails::GreaterEqual(opl, opr2);", indent);
                    break;

                case OperatorTypes.Less:
                    stream.WriteLine("{0}\t\t\tbool op = PrivateDetails::Less(opl, opr2);", indent);
                    break;

                case OperatorTypes.LessEqual:
                    stream.WriteLine("{0}\t\t\tbool op = PrivateDetails::LessEqual(opl, opr2);", indent);
                    break;

                default:
                    stream.WriteLine("{0}\t\t\tbool op = false;", indent);
                    break;
                }

                stream.WriteLine("{0}\t\t\tif (!op)", indent);
                stream.WriteLine("{0}\t\t\t\tresult = BT_FAILURE;", indent);
            }
            else if (attach.IsCompute())
            {
                if (attach.Opl != null && !attach.Opl.IsMethod && attach.Opl.Var != null && attach.Opr1 != null && attach.Opr2 != null)
                {
                    PropertyDef prop = attach.Opl.Var.Property;

                    if (prop != null)
                    {
                        string typeName = DataCppExporter.GetGeneratedNativeType(attach.Opr1.ValueType);

                        RightValueCppExporter.GenerateCode(attachment, attach.Opr1, stream, indent + "\t\t\t", typeName, "opr1", "opr1");
                        RightValueCppExporter.GenerateCode(attachment, attach.Opr2, stream, indent + "\t\t\t", typeName, "opr2", "opr2");

                        string oprStr = string.Empty;

                        switch (attach.Operator)
                        {
                        case OperatorTypes.Add:
                            oprStr = "opr1 + opr2";
                            break;

                        case OperatorTypes.Sub:
                            oprStr = "opr1 - opr2";
                            break;

                        case OperatorTypes.Mul:
                            oprStr = "opr1 * opr2";
                            break;

                        case OperatorTypes.Div:
                            oprStr = "opr1 / opr2";
                            break;

                        default:
                            Debug.Check(false, "The operator is wrong!");
                            break;
                        }

                        oprStr = string.Format("({0})({1})", typeName, oprStr);

                        string property = PropertyCppExporter.GetProperty(attachment, prop, attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "opl", "attach");
                        string propName = prop.BasicName.Replace("[]", "");

                        if (prop.IsArrayElement && attach.Opl.Var.ArrayIndexElement != null)
                        {
                            ParameterCppExporter.GenerateCode(attachment, attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "int", "opl_index", "attach_opl");
                            property = string.Format("({0})[opl_index]", property);
                        }

                        string propBasicName = prop.BasicName.Replace("[]", "");

                        if (!prop.IsArrayElement && (prop.IsPar || prop.IsCustomized))
                        {
                            uint   id        = Behaviac.Design.CRC32.CalcCRC(propBasicName);
                            string agentName = PropertyCppExporter.GetGenerateAgentName(prop, "opl", "attach");

                            stream.WriteLine("{0}\t\t\t{1}->SetVariable(\"{2}\", {3}u, {4});", indent, agentName, propBasicName, id, oprStr);
                        }
                        else
                        {
                            stream.WriteLine("{0}\t\t\t{1} = {2};", indent, property, oprStr);
                        }

                        if (attach.Opr1.IsMethod)
                        {
                            RightValueCppExporter.PostGenerateCode(attach.Opr1, stream, indent + "\t\t\t", typeName, "opr1", string.Empty);
                        }

                        if (attach.Opr2.IsMethod)
                        {
                            RightValueCppExporter.PostGenerateCode(attach.Opr2, stream, indent + "\t\t\t", typeName, "opr2", string.Empty);
                        }
                    }
                }
            }

            stream.WriteLine("{0}\t\t\treturn result;", indent);
            stream.WriteLine("{0}\t\t}}", indent);
        }
        protected override void GenerateMethod(Behaviac.Design.Attachments.Attachment attachment, StreamWriter stream, string indent)
        {
            base.GenerateMethod(attachment, stream, indent);

            AttachAction attach = attachment as AttachAction;

            if (attach == null)
            {
                return;
            }

            stream.WriteLine("{0}\t\tprotected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)", indent);
            stream.WriteLine("{0}\t\t{{", indent);
            stream.WriteLine("{0}\t\t\tEBTStatus result = EBTStatus.BT_SUCCESS;", indent);

            if (attach.IsAction())
            {
                string method = MethodCsExporter.GenerateCode(attach.Opl.Method, stream, indent + "\t\t\t", string.Empty, string.Empty, "opl");

                stream.WriteLine("{0}\t\t\t{1};", indent, method);
                MethodCsExporter.PostGenerateCode(attach.Opl.Method, stream, indent + "\t\t\t", string.Empty, string.Empty, "opl");
            }
            else if (attach.IsAssign())
            {
                if (attach.Opl != null && !attach.Opl.IsMethod && attach.Opl.Var != null && attach.Opr2 != null)
                {
                    PropertyDef prop = attach.Opl.Var.Property;
                    if (prop != null)
                    {
                        RightValueCsExporter.GenerateCode(attach.Opr2, stream, indent + "\t\t\t", attach.Opr2.NativeType.Replace("::", "."), "opr2", "opr2");

                        string property = PropertyCsExporter.GetProperty(prop, attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "opl", "attach");
                        string propName = prop.BasicName.Replace("[]", "");

                        if (prop.IsArrayElement && attach.Opl.Var.ArrayIndexElement != null)
                        {
                            ParameterCsExporter.GenerateCode(attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "int", "opl_index", "attach_opl");
                            property = string.Format("({0})[opl_index]", property);
                        }

                        string propBasicName = prop.BasicName.Replace("[]", "");
                        if (!prop.IsArrayElement && (prop.IsPar || prop.IsCustomized))
                        {
                            uint id = Behaviac.Design.CRC32.CalcCRC(propBasicName);

                            stream.WriteLine("{0}\t\t\tDebug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
                            stream.WriteLine("{0}\t\t\tpAgent.SetVariable(\"{1}\", opr2, {2}u);", indent, propBasicName, id);
                        }
                        else if (prop.IsPublic)
                        {
                            stream.WriteLine("{0}\t\t\t{1} = opr2;", indent, property);
                        }
                        else
                        {
                            string agentName = PropertyCsExporter.GetGenerateAgentName(prop, "opr2", "opr2");
                            stream.WriteLine("{0}\t\t\tAgentExtra_Generated.SetProperty({1}, \"{2}\", opr2);", indent, agentName, propBasicName);
                        }

                        if (attach.Opr2.IsMethod)
                        {
                            RightValueCsExporter.PostGenerateCode(attach.Opr2, stream, indent + "\t\t\t", attach.Opr2.NativeType.Replace("::", "."), "opr2", string.Empty);
                        }
                    }
                }
            }
            else if (attach.IsCompare())
            {
                string typeName = Plugin.GetNativeTypeName(attach.Opl.ValueType);
                typeName = typeName.Replace("::", ".");

                RightValueCsExporter.GenerateCode(attach.Opl, stream, indent + "\t\t\t", typeName, "opl", "");
                RightValueCsExporter.GenerateCode(attach.Opr2, stream, indent + "\t\t\t", typeName, "opr2", "");

                if (attach.Opl != null && attach.Opl.IsMethod)
                {
                    RightValueCsExporter.PostGenerateCode(attach.Opl, stream, indent + "\t\t\t", typeName, "opl", "");
                }

                if (attach.Opr2 != null && attach.Opr2.IsMethod)
                {
                    RightValueCsExporter.PostGenerateCode(attach.Opr2, stream, indent + "\t\t\t", typeName, "opr2", "");
                }

                switch (attach.Operator)
                {
                case OperatorTypes.Equal:
                    stream.WriteLine("{0}\t\t\tbool op = (opl == opr2);", indent);
                    break;

                case OperatorTypes.NotEqual:
                    stream.WriteLine("{0}\t\t\tbool op = (opl != opr2);", indent);
                    break;

                case OperatorTypes.Greater:
                    stream.WriteLine("{0}\t\t\tbool op = (opl > opr2);", indent);
                    break;

                case OperatorTypes.GreaterEqual:
                    stream.WriteLine("{0}\t\t\tbool op = (opl >= opr2);", indent);
                    break;

                case OperatorTypes.Less:
                    stream.WriteLine("{0}\t\t\tbool op = (opl < opr2);", indent);
                    break;

                case OperatorTypes.LessEqual:
                    stream.WriteLine("{0}\t\t\tbool op = (opl <= opr2);", indent);
                    break;

                default:
                    stream.WriteLine("{0}\t\t\tbool op = false;", indent);
                    break;
                }
                stream.WriteLine("{0}\t\t\tif (!op)", indent);
                stream.WriteLine("{0}\t\t\t\tresult = EBTStatus.BT_FAILURE;", indent);
            }
            else if (attach.IsCompute())
            {
                if (attach.Opl != null && !attach.Opl.IsMethod && attach.Opl.Var != null && attach.Opr1 != null && attach.Opr2 != null)
                {
                    PropertyDef prop = attach.Opl.Var.Property;
                    if (prop != null)
                    {
                        string typeName = Plugin.GetNativeTypeName(attach.Opr1.ValueType);
                        typeName = typeName.Replace("::", ".");

                        RightValueCsExporter.GenerateCode(attach.Opr1, stream, indent + "\t\t\t", typeName, "opr1", "opr1");
                        RightValueCsExporter.GenerateCode(attach.Opr2, stream, indent + "\t\t\t", typeName, "opr2", "opr2");

                        string oprStr = string.Empty;
                        switch (attach.Operator)
                        {
                        case OperatorTypes.Add:
                            oprStr = "opr1 + opr2";
                            break;

                        case OperatorTypes.Sub:
                            oprStr = "opr1 - opr2";
                            break;

                        case OperatorTypes.Mul:
                            oprStr = "opr1 * opr2";
                            break;

                        case OperatorTypes.Div:
                            oprStr = "opr1 / opr2";
                            break;

                        default:
                            Debug.Check(false, "The operator is wrong!");
                            break;
                        }

                        oprStr = string.Format("({0})({1})", typeName, oprStr);

                        string property = PropertyCsExporter.GetProperty(prop, attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "opl", "attach");
                        string propName = prop.BasicName.Replace("[]", "");

                        if (prop.IsArrayElement && attach.Opl.Var.ArrayIndexElement != null)
                        {
                            ParameterCsExporter.GenerateCode(attach.Opl.Var.ArrayIndexElement, stream, indent + "\t\t\t", "int", "opl_index", "attach_opl");
                            property = string.Format("({0})[opl_index]", property);
                        }

                        string propBasicName = prop.BasicName.Replace("[]", "");
                        if (!prop.IsArrayElement && (prop.IsPar || prop.IsCustomized))
                        {
                            uint id = Behaviac.Design.CRC32.CalcCRC(propBasicName);

                            stream.WriteLine("{0}\t\t\tDebug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
                            stream.WriteLine("{0}\t\t\tpAgent.SetVariable(\"{1}\", {2}, {3}u);", indent, propBasicName, oprStr, id);
                        }
                        else if (prop.IsPublic)
                        {
                            stream.WriteLine("{0}\t\t\t{1} = {2};", indent, property, oprStr);
                        }
                        else
                        {
                            string agentName = PropertyCsExporter.GetGenerateAgentName(prop, "opl", "attach");
                            stream.WriteLine("{0}\t\t\tAgentExtra_Generated.SetProperty({1}, \"{2}\", {3});", indent, agentName, propBasicName, oprStr);
                        }

                        if (attach.Opr1.IsMethod)
                        {
                            RightValueCsExporter.PostGenerateCode(attach.Opr1, stream, indent + "\t\t\t", typeName, "opr1", string.Empty);
                        }

                        if (attach.Opr2.IsMethod)
                        {
                            RightValueCsExporter.PostGenerateCode(attach.Opr2, stream, indent + "\t\t\t", typeName, "opr2", string.Empty);
                        }
                    }
                }
            }

            stream.WriteLine("{0}\t\t\treturn result;", indent);
            stream.WriteLine("{0}\t\t}}", indent);
        }