Exemple #1
0
        public static bool EvaluteAssignment(Agent pAgent, Property opl, Property opr, behaviac.CMethodBase opr_m)
        {
            bool bValid = false;

            if (opl != null)
            {
                if (opr_m != null)
                {
                    object returnValue = opr_m.Invoke(pAgent);

                    Agent pParentOpl = opl.GetParentAgent(pAgent);
                    opl.SetValue(pParentOpl, returnValue);

                    bValid = true;
                }
                else if (opr != null)
                {
                    Agent pParentL = opl.GetParentAgent(pAgent);
                    Agent pParentR = opr.GetParentAgent(pAgent);

                    opl.SetFrom(pParentR, opr, pParentL);

                    bValid = true;
                }
            }

            return bValid;
        }
Exemple #2
0
        public static VariableComparator Create(string comparionOperator, Property lhs, CMethodBase lhs_m, Property rhs, CMethodBase rhs_m)
        {
            E_VariableComparisonType comparisonType = VariableComparator.ParseComparisonType(comparionOperator);

            VariableComparator pComparator = VariableComparator.Create(lhs, lhs_m, rhs, rhs_m);
            pComparator.SetComparisonType(comparisonType);

            return pComparator;
        }
Exemple #3
0
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Count")
                {
                    string typeName = null;
                    this.m_count_var = Condition.LoadRight(p.value, ref typeName);
                }
            }
        }
Exemple #4
0
        public static bool EvaluteCompute(Agent pAgent, Property opl, Property opr1, CMethodBase opr1_m, EComputeOperator opr, Property opr2, CMethodBase opr2_m)
        {
            bool bValid = false;
            object value1 = null;

            if (opl != null)
            {
            if (opr1_m != null)
            {
                bValid = true;
                value1 = opr1_m.Invoke(pAgent);
            }
            else if (opr1 != null)
            {
                bValid = true;
                Agent pParentR = opr1.GetParentAgent(pAgent);

                value1 = opr1.GetValue(pParentR);
            }

            Debug.Check(value1 != null, "weird, have you modified your meta? please reexport your trees");

            if (opr2_m != null)
            {
                bValid = true;
                object value2 = opr2_m.Invoke(pAgent);

                Agent pParentOpl = opl.GetParentAgent(pAgent);
                object returnValue = Details.ComputeValue(value1, value2, opr);

                opl.SetValue(pParentOpl, returnValue);
            }
            else if (opr2 != null)
            {
                bValid = true;
                Agent pParentL = opl.GetParentAgent(pAgent);
                Agent pParentR = opr2.GetParentAgent(pAgent);

                object value2 = opr2.GetValue(pParentR);

                object returnValue = Details.ComputeValue(value1, value2, opr);

                opl.SetValue(pParentL, returnValue);
            }
            }

            return bValid;
        }
Exemple #5
0
        public static bool EvaluteCompute(Agent pAgent, Property opl, Property opr1, CMethodBase opr1_m, EComputeOperator opr, Property opr2, CMethodBase opr2_m)
        {
            bool bValid = false;
            object value1 = null;

            if (opl != null)
            {
            if (opr1_m != null)
            {
                bValid = true;
                value1 = opr1_m.Invoke(pAgent);
            }
            else if (opr1 != null)
            {
                bValid = true;
                Agent pParentR = opr1.GetParentAgent(pAgent);

                value1 = opr1.GetValue(pParentR);
            }

            if (opr2_m != null)
            {
                bValid = true;
                object value2 = opr2_m.Invoke(pAgent);

                Agent pParentOpl = opl.GetParentAgent(pAgent);
                object returnValue = Details.ComputeValue(value1, value2, opr);

                opl.SetValue(pParentOpl, returnValue);
            }
            else if (opr2 != null)
            {
                bValid = true;
                Agent pParentL = opl.GetParentAgent(pAgent);
                Agent pParentR = opr2.GetParentAgent(pAgent);

                object value2 = opr2.GetValue(pParentR);

                object returnValue = Details.ComputeValue(value1, value2, opr);

                opl.SetValue(pParentL, returnValue);
            }
            }

            return bValid;
        }
Exemple #6
0
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
            property_t p = properties[i];
            if (p.name == "Opl")
            {
                this.m_opl = Condition.LoadLeft(p.value);
            }
            else if (p.name == "Operator")
            {
                if (p.value == "Add")
                {
                    this.m_operator = EComputeOperator.E_ADD;
                }
                else if (p.value == "Sub")
                {
                    this.m_operator = EComputeOperator.E_SUB;
                }
                else if (p.value == "Mul")
                {
                    this.m_operator = EComputeOperator.E_MUL;
                }
                else if (p.value == "Div")
                {
                    this.m_operator = EComputeOperator.E_DIV;
                }
                else
                {
                    Debug.Check(false);
                }
            }
            else if (p.name == "Opr1")
            {
                int pParenthesis = p.value.IndexOf('(');

                if (pParenthesis == -1)
                {
                    string typeName = null;
                    this.m_opr1 = Condition.LoadRight(p.value, ref typeName);
                }
                else
                {
                    //method
                    this.m_opr1_m = Action.LoadMethod(p.value);
                }
            }
            else if (p.name == "Opr2")
            {
                int pParenthesis = p.value.IndexOf('(');

                if (pParenthesis == -1)
                {
                    string typeName = null;
                    this.m_opr2 = Condition.LoadRight(p.value, ref typeName);
                }
                else
                {
                    //method
                    this.m_opr2_m = Action.LoadMethod(p.value);
                }
            }
            else
            {
                //Debug.Check(0, "unrecognised property %s", p.name);
            }
            }
        }
Exemple #7
0
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Frames")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        string typeName = null;
                        this.m_frames_var = Condition.LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        //method
                        this.m_frames_method = Action.LoadMethod(p.value);
                    }
                }
            }
        }
Exemple #8
0
        public virtual bool load(List<property_t> properties)
        {
            string opr2TypeName = null;
            string comparatorName = null;

            foreach(property_t p in properties)
            {
                if (p.name == "Mode")
                {
                    switch (p.value)
                    {
                        case "Condition":
                            this.m_mode = TransitionMode.Condition;
                            break;

                        case "Success":
                            this.m_mode = TransitionMode.Success;
                            break;

                        case "Failure":
                            this.m_mode = TransitionMode.Failure;
                            break;

                        case "End":
                            this.m_mode = TransitionMode.End;
                            break;
                    }
                }
                else if (p.name == "Opl")
                {
                    if (StringUtils.IsValidString(p.value))
                    {
                        int pParenthesis = p.value.IndexOf('(');

                        if (pParenthesis == -1)
                        {
                            string typeName = null;
                            this.m_opl = Condition.LoadRight(p.value, ref typeName);
                        }
                        else
                        {
                            //method
                            this.m_opl_m = Action.LoadMethod(p.value);
                        }
                    }
                }
                else if (p.name == "Opr1")
                {
                    if (StringUtils.IsValidString(p.value))
                    {
                        int pParenthesis = p.value.IndexOf('(');

                        if (pParenthesis == -1)
                        {
                            string typeName = null;
                            this.m_opr1 = Condition.LoadRight(p.value, ref typeName);
                        }
                        else
                        {
                            //method
                            this.m_opr1_m = Action.LoadMethod(p.value);
                        }
                    }
                }
                else if (p.name == "Operator")
                {
                    comparatorName = p.value;

                    switch (p.value)
                    {
                        case "Invalid":
                            this.m_operator = EOperatorType.E_INVALID;
                            break;

                        case "Assign":
                            this.m_operator = EOperatorType.E_ASSIGN;
                            break;

                        case "Add":
                            this.m_operator = EOperatorType.E_ADD;
                            break;

                        case "Sub":
                            this.m_operator = EOperatorType.E_SUB;
                            break;

                        case "Mul":
                            this.m_operator = EOperatorType.E_MUL;
                            break;

                        case "Div":
                            this.m_operator = EOperatorType.E_DIV;
                            break;

                        case "Equal":
                            this.m_operator = EOperatorType.E_EQUAL;
                            break;

                        case "NotEqual":
                            this.m_operator = EOperatorType.E_NOTEQUAL;
                            break;

                        case "Greater":
                            this.m_operator = EOperatorType.E_GREATER;
                            break;

                        case "Less":
                            this.m_operator = EOperatorType.E_LESS;
                            break;

                        case "GreaterEqual":
                            this.m_operator = EOperatorType.E_GREATEREQUAL;
                            break;

                        case "LessEqual":
                            this.m_operator = EOperatorType.E_LESSEQUAL;
                            break;
                    }
                }
                else if (p.name == "Opr2")
                {
                    if (StringUtils.IsValidString(p.value))
                    {
                        int pParenthesis = p.value.IndexOf('(');

                        if (pParenthesis == -1)
                        {
                            this.m_opr2 = Condition.LoadRight(p.value, ref opr2TypeName);
                        }
                        else
                        {
                            //method
                            this.m_opr2_m = Action.LoadMethod(p.value);
                        }
                    }
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }

            // compare
            if (this.m_operator >= EOperatorType.E_EQUAL && this.m_operator <= EOperatorType.E_LESSEQUAL)
            {
                if (!string.IsNullOrEmpty(comparatorName) && (this.m_opl != null || this.m_opl_m != null) &&
                    (this.m_opr2 != null || this.m_opr2_m != null))
                {
                    this.m_comparator = Condition.Create(comparatorName, this.m_opl, this.m_opl_m, this.m_opr2, this.m_opr2_m);
                }
            }

            return this.m_opl != null;
        }
Exemple #9
0
 public Descriptor_t(Descriptor_t copy)
 {
     Attribute = copy.Attribute;
     Reference = copy.Reference;
     Weight = copy.Weight;
 }
Exemple #10
0
 public Descriptor_t()
 {
     Attribute = null;
     Reference = null;
     Weight = 0.0f;
 }
Exemple #11
0
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            string typeName = null;
            string comparatorName = null;

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Operator")
                {
                    comparatorName = p.value;
                }
                else if (p.name == "Opl")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opl = LoadLeft(p.value);
                    }
                    else
                    {
                        this.m_opl_m = Action.LoadMethod(p.value);
                    }
                }
                else if (p.name == "Opr")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr = LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        this.m_opr_m = Action.LoadMethod(p.value);
                    }
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }

            if (!string.IsNullOrEmpty(comparatorName) && (this.m_opl != null || this.m_opl_m != null) && (this.m_opr != null || this.m_opr_m != null))
            {
                this.m_comparator = Condition.Create(comparatorName, this.m_opl, this.m_opl_m, this.m_opr, this.m_opr_m);
            }
        }
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            string typeName = null;

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Opl")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opl = Condition.LoadLeft(p.value);
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else if (p.name == "Opr")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr = Condition.LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        //method
                        this.m_opr_m = Action.LoadMethod(p.value);
                    }
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }
        }
Exemple #13
0
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            string typeName = null;
            string propertyName = null;
            string comparatorName = null;

            foreach (property_t p in properties)
            {
                if (p.name == "Operator")
                {
                    comparatorName = p.value;
                }
                else if (p.name == "Opl")
                {
                    int pParenthesis = p.value.IndexOf('(');
                    if (pParenthesis == -1)
                    {
                        this.m_opl = Condition.LoadLeft(p.value, ref propertyName, null);
                    }
                    else
                    {
                        //method
                        this.m_opl_m = Action.LoadMethod(p.value);
                    }
                }
                else if (p.name == "Opr")
                {
                    this.m_opr = Condition.LoadRight(p.value, propertyName, ref typeName);
                }
                else if (p.name == "BinaryOperator")
                {
                    if (p.value == "Or")
                    {
                        this.m_bAnd = false;
                    }
                    else if (p.value == "And")
                    {
                        this.m_bAnd = true;
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }

            if (!string.IsNullOrEmpty(comparatorName) && (this.m_opl != null || this.m_opl_m != null) && this.m_opr != null)
            {
                this.m_comparator = Condition.Create(typeName, comparatorName, this.m_opl, this.m_opr);
            }
        }
Exemple #14
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);
            string propertyName = null;

            using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    property_t current = enumerator.get_Current();
                    if (current.name == "Opl")
                    {
                        this.m_opl = Condition.LoadLeft(current.value, ref propertyName, null);
                    }
                    else if (current.name == "Operator")
                    {
                        if (current.value == "Add")
                        {
                            this.m_operator = EComputeOperator.E_ADD;
                        }
                        else if (current.value == "Sub")
                        {
                            this.m_operator = EComputeOperator.E_SUB;
                        }
                        else if (current.value == "Mul")
                        {
                            this.m_operator = EComputeOperator.E_MUL;
                        }
                        else if (current.value == "Div")
                        {
                            this.m_operator = EComputeOperator.E_DIV;
                        }
                    }
                    else if (current.name == "Opr1")
                    {
                        int num = current.value.IndexOf('(');
                        if (num == -1)
                        {
                            string text = null;
                            this.m_opr1 = Condition.LoadRight(current.value, propertyName, ref text);
                        }
                        else
                        {
                            this.m_opr1_m = Action.LoadMethod(current.value);
                        }
                    }
                    else if (current.name == "Opr2")
                    {
                        int num2 = current.value.IndexOf('(');
                        if (num2 == -1)
                        {
                            string text2 = null;
                            this.m_opr2 = Condition.LoadRight(current.value, propertyName, ref text2);
                        }
                        else
                        {
                            this.m_opr2_m = Action.LoadMethod(current.value);
                        }
                    }
                }
            }
        }
Exemple #15
0
 public Descriptor_t(Descriptor_t copy)
 {
     Attribute = copy.Attribute.clone();
     Reference = copy.Reference.clone();
     Weight = copy.Weight;
 }
Exemple #16
0
        public static VariableComparator Create(string comparionOperator, Property lhs, CMethodBase lhs_m, Property rhs, CMethodBase rhs_m)
        {
            E_VariableComparisonType comparisonType = VariableComparator.ParseComparisonType(comparionOperator);

            VariableComparator pComparator = VariableComparator.Create(lhs, lhs_m, rhs, rhs_m);

            pComparator.SetComparisonType(comparisonType);

            return(pComparator);
        }