Example #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;
        }
Example #2
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			Debug.Check(behaviac.Utils.MakeVariableId("par_float_type_0") == 569873069u);
			float method_p0 = pAgent.GetVariable<float>(569873069u);
			((AgentNodeTest)pAgent).setTestVar_2(method_p0);
			return EBTStatus.BT_SUCCESS;
		}
Example #3
0
		public static object GetProperty(behaviac.Agent agent, string property)
		{
			Type type = agent.GetType();
			string propertyName = type.FullName + property;
			if (_fields.ContainsKey(propertyName))
			{
				return _fields[propertyName].GetValue(agent);
			}

			if (_properties.ContainsKey(propertyName))
			{
				return _properties[propertyName].GetValue(agent, null);
			}

			while (type != typeof(object))
			{
				FieldInfo field = type.GetField(property, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
				if (field != null)
				{
					_fields[propertyName] = field;
					return field.GetValue(agent);
				}

				PropertyInfo prop = type.GetProperty(property, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
				if (prop != null)
				{
					_properties[propertyName] = prop;
					return prop.GetValue(agent, null);
				}

				type = type.BaseType;
			}
			Debug.Check(false, "No property can be found!");
			return null;
		}
Example #4
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			float opr = ((AgentNodeTest)pAgent).testVar_2;
			Debug.Check(behaviac.Utils.MakeVariableId("par_float_type_1") == 955032556u);
			pAgent.SetVariable<float>("par_float_type_1", 955032556u, opr);
			return result;
		}
Example #5
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			int opr = 2;
			Debug.Check(behaviac.Utils.MakeVariableId("parT_SpawnCountPerWave") == 193379536u);
			pAgent.SetVariable<int>("parT_SpawnCountPerWave", 193379536u, opr);
			return result;
		}
Example #6
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			Debug.Check(behaviac.Utils.MakeVariableId("parT_WaveCount") == 2998764825u);
			int opl = pAgent.GetVariable<int>(2998764825u);
			int opr = 0;
			bool op = opl > opr;
			return op ? EBTStatus.BT_SUCCESS : EBTStatus.BT_FAILURE;
		}
Example #7
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			float opr1 = 0.5f;
			float opr2 = 1.3f;
			Debug.Check(behaviac.Utils.MakeVariableId("par_float_type_0") == 569873069u);
			pAgent.SetVariable<float>("par_float_type_0", 569873069u, (float)(opr1 + opr2));
			return result;
		}
Example #8
0
        protected virtual int GetWeight(behaviac.Agent pAgent)
        {
            if (this.m_weight != null)
            {
                Debug.Check(this.m_weight is CInstanceMember<int>);
                return ((CInstanceMember<int>)this.m_weight).GetValue(pAgent);
            }

            return 0;
        }
Example #9
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			Debug.Check(behaviac.Utils.MakeVariableId("par_float_type_1") == 955032556u);
			float opr1 = pAgent.GetVariable<float>(955032556u);
			Debug.Check(behaviac.Utils.MakeVariableId("par_float_type_2") == 331477039u);
			float opr2 = pAgent.GetVariable<float>(331477039u);
			Debug.Check(behaviac.Utils.MakeVariableId("par_float_type_0") == 569873069u);
			pAgent.SetVariable<float>("par_float_type_0", 569873069u, (float)(opr1 + opr2));
			return result;
		}
        protected virtual int GetWeight(behaviac.Agent pAgent)
        {
            if (this.m_weight_var != null)
            {
                Debug.Check(this.m_weight_var != null);
                int count = (int)this.m_weight_var.GetValue(pAgent);

                return count;
            }

            return 0;
        }
Example #11
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			int opl = ((AgentNodeTest)pAgent).testVar_1;
			int opr = 0;
			bool op = opl == opr;
			return op ? EBTStatus.BT_SUCCESS : EBTStatus.BT_FAILURE;
		}
Example #12
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			FSMAgentTest.EMessage opl = ((FSMAgentTest)pAgent).Message;
			FSMAgentTest.EMessage opr2 = FSMAgentTest.EMessage.Pause;
			bool op = (opl == opr2);
			if (!op)
				result = EBTStatus.BT_FAILURE;
			return result;
		}
Example #13
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			Debug.Check(behaviac.Utils.MakeVariableId("ActiveCount") == 177115358u);
			uint opr1 = pAgent.GetVariable<uint>(177115358u);
			uint opr2 = 1;
			Debug.Check(behaviac.Utils.MakeVariableId("ActiveCount") == 177115358u);
			pAgent.SetVariable("ActiveCount", 177115358u, (uint)(opr1 + opr2));
			return result;
		}
Example #14
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			Debug.Check(behaviac.Utils.MakeVariableId("par_agent") == 239606442u);
			ParTestAgent opl = pAgent.GetVariable<ParTestAgent>(239606442u);
			bool op = opl == opr;
			return op ? EBTStatus.BT_SUCCESS : EBTStatus.BT_FAILURE;
		}
Example #15
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			int opr1 = 1000;
			int opr2 = 500;
			Debug.Check(behaviac.Utils.MakeVariableId("par_int_type_0") == 4028995106u);
			pAgent.SetVariable<int>("par_int_type_0", 4028995106u, (int)(opr1 * opr2));
			return result;
		}
Example #16
0
		private static void ExportMethod(Dictionary<string, Type> types, XmlWriter xmlWriter, MethodInfo m, behaviac.MethodMetaInfoAttribute methodDesc, string eventName, bool onlyExportPublicMembers)
		{
			string methodName = !string.IsNullOrEmpty(eventName) ? eventName : m.Name;

//			if (methodName == "Func_SByteListIR")
//			{
//				Debug.Check(true);
//			}

			if (!m.IsPublic)
			{
				if (!Config.IsSuppressingNonPublicWarning)
				{
					string warningInfo = string.Format("Export non-public method : {0}.{1}()", m.DeclaringType.Name, methodName);
					Debug.LogWarning(warningInfo);
				}
				
				if (onlyExportPublicMembers)
				{
					return;
				}
			}

            Type returnType = m.ReturnType;
            if (methodDesc.IsNamedEvent && returnType != typeof(bool))
            {
				string clsName = (m.DeclaringType.DeclaringType != null) ? m.DeclaringType.DeclaringType.Name : m.DeclaringType.Name;
				behaviac.Debug.LogWarning(string.Format("The return type of {0}.{1}() is not bool type", clsName, methodName));
                returnType = typeof(bool);
            }

            string returnTypeStr = GetFullTypeName(returnType);

            Type parentClassType = m.DeclaringType;
            if (methodDesc.IsNamedEvent)
            {
                parentClassType = m.DeclaringType.DeclaringType;
            }

			string parentClassTypeFullName = GetFullTypeName(parentClassType);

            if (types == null)
            {
                xmlWriter.WriteStartElement("Method");

                xmlWriter.WriteAttributeString("Name", methodName);
                xmlWriter.WriteAttributeString("DisplayName", methodDesc.DisplayName);
                xmlWriter.WriteAttributeString("Desc", methodDesc.Description);
                xmlWriter.WriteAttributeString("ReturnType", returnTypeStr);
                xmlWriter.WriteAttributeString("Class", parentClassTypeFullName);

                if (m.IsStatic)
                {
                    xmlWriter.WriteAttributeString("Static", "true");
                }
                if (m.IsPublic)
                {
                    xmlWriter.WriteAttributeString("Public", "true");
                }
                if (methodDesc.IsNamedEvent)
                {
                    xmlWriter.WriteAttributeString("Flag", "namedevent");
                }
            }

            //TODO:IsActionMethodOnly

            ParameterInfo[] parameters = m.GetParameters();

            foreach (ParameterInfo para in parameters)
            {
                Attribute[] paramAttributes = (Attribute[])para.GetCustomAttributes(typeof(behaviac.ParamMetaInfoAttribute), false);

                Type paramType = para.ParameterType;
                if (para.ParameterType.IsByRef)
                {
                    paramType = para.ParameterType.GetElementType();
                }

                string paramNativeType = GetFullTypeName(paramType);
                string paramDisplayName = para.Name;
                string paramDescription = paramDisplayName;
                string defaultValue = "";
                float rangeMin = float.MinValue;
                float rangeMax = float.MaxValue;

                if (paramAttributes.Length > 0)
                {
                    behaviac.ParamMetaInfoAttribute paramDescAttr = ((behaviac.ParamMetaInfoAttribute)paramAttributes[0]);
                    paramDisplayName = paramDescAttr.DisplayName;
                    paramDescription = paramDescAttr.Description;
                    defaultValue = paramDescAttr.DefaultValue;
                    rangeMin = paramDescAttr.RangeMin;
                    rangeMax = paramDescAttr.RangeMax;
                }

                if (para.ParameterType.IsByRef)
                {
                    paramNativeType += "&";
                }

				bool bIsNullValueType = Utils.IsNullValueType(paramType);
				if (bIsNullValueType)
                {
                    paramNativeType += "*";
                }

                if (types == null)
                {
                    xmlWriter.WriteStartElement("Param");
                    xmlWriter.WriteAttributeString("DisplayName", paramDisplayName);
                    xmlWriter.WriteAttributeString("Desc", paramDescription);
                    xmlWriter.WriteAttributeString("Type", paramNativeType);
                    if (!string.IsNullOrEmpty(defaultValue))
                    {
                        xmlWriter.WriteAttributeString("Default", defaultValue);
                    }
                    if (rangeMin != float.MinValue)
                    {
                        xmlWriter.WriteAttributeString("RangeMin", rangeMin.ToString());
                    }
                    if (rangeMax != float.MaxValue)
                    {
                        xmlWriter.WriteAttributeString("RangeMax", rangeMax.ToString());
                    }

                    //end of Param
                    xmlWriter.WriteEndElement();
                }
                else
                {
					if (Utils.IsArrayType(paramType))
					{
						Type elementType = paramType.GetGenericArguments()[0];
						if (Utils.IsCustomClassType(elementType))
						{
							ExportStructTypeField(types, xmlWriter, elementType, onlyExportPublicMembers);
						}
						else if (Utils.IsEnumType(elementType))
						{
							ExportEnumTypeField(types, xmlWriter, elementType);
						}
					}
					else if (Utils.IsCustomClassType(paramType))
					{
						ExportStructTypeField(types, xmlWriter, paramType, onlyExportPublicMembers);
					}
					else if (Utils.IsEnumType(paramType))
					{
						ExportEnumTypeField(types, xmlWriter, paramType);
					}
				}
			}

			if (types == null)
			{
				//end of Method
				xmlWriter.WriteEndElement();
			}
			else
			{
				if (Utils.IsArrayType(returnType))
				{
					Type elementType = returnType.GetGenericArguments()[0];
					if (Utils.IsCustomClassType(elementType))
					{
						ExportStructTypeField(types, xmlWriter, elementType, onlyExportPublicMembers);
					}
					else if (Utils.IsEnumType(elementType))
					{
						ExportEnumTypeField(types, xmlWriter, elementType);
					}
				}
				else if (Utils.IsCustomClassType(returnType))
				{
					ExportStructTypeField(types, xmlWriter, returnType, onlyExportPublicMembers);
				}
				else if (Utils.IsEnumType(returnType))
				{
					ExportEnumTypeField(types, xmlWriter, returnType);
				}
			}
		}
Example #17
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			Debug.Check(behaviac.Utils.MakeVariableId("par_int_type_0") == 4028995106u);
			int method_p0 = pAgent.GetVariable<int>(4028995106u);
			((AgentNodeTest)pAgent).setTestVar_1(method_p0);
			return EBTStatus.BT_SUCCESS;
		}
Example #18
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			Debug.Check(behaviac.Utils.MakeVariableId("redirectCount") == 767249388u);
			uint opl = pAgent.GetVariable<uint>(767249388u);
			Debug.Check(behaviac.Utils.MakeVariableId("redirectTime") == 3775965105u);
			uint opr = pAgent.GetVariable<uint>(3775965105u);
			bool op = opl >= opr;
			return op ? EBTStatus.BT_SUCCESS : EBTStatus.BT_FAILURE;
		}
Example #19
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			int opr = 2;
			((AgentNodeTest)pAgent).testVar_0 = opr;
			return result;
		}
Example #20
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			int opr = ((AgentNodeTest)pAgent).testVar_0;
			Debug.Check(behaviac.Utils.MakeVariableId("par_int_type_1") == 3913197411u);
			pAgent.SetVariable<int>("par_int_type_1", 3913197411u, opr);
			return result;
		}
Example #21
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			((FSMAgentTest)pAgent).pause_update();
			return behaviac.EBTStatus.BT_RUNNING;
		}
Example #22
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			int opr = ((AgentNodeTest)pAgent).testVar_0;
			behaviac.Agent pAgent_opl = behaviac.Utils.GetParentAgent(pAgent, "par_child_agent_1");
			Debug.Check(pAgent_opl != null || Utils.IsStaticClass("par_child_agent_1"));
			Debug.Check(behaviac.Utils.MakeVariableId("testInt") == 2614050066u);
			pAgent_opl.SetVariable<int>("testInt", 2614050066u, opr);
			return result;
		}
Example #23
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			((AgentNodeTest)pAgent).initChildAgentTest();
			return EBTStatus.BT_SUCCESS;
		}
Example #24
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			Debug.Check(behaviac.Utils.MakeVariableId("ExitCount") == 1184325508u);
			long opr1 = pAgent.GetVariable<long>(1184325508u);
			long opr2 = 1;
			Debug.Check(behaviac.Utils.MakeVariableId("ExitCount") == 1184325508u);
			pAgent.SetVariable("ExitCount", 1184325508u, (long)(opr1 + opr2));
			return result;
		}
Example #25
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			((AgentNodeTest)pAgent).setTestVar_0(method_p0);
			return EBTStatus.BT_SUCCESS;
		}
Example #26
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			Debug.Check(behaviac.Utils.MakeVariableId("PauseCount") == 3020354788u);
			short opr1 = pAgent.GetVariable<short>(3020354788u);
			short opr2 = 1;
			Debug.Check(behaviac.Utils.MakeVariableId("PauseCount") == 3020354788u);
			pAgent.SetVariable("PauseCount", 3020354788u, (short)(opr1 + opr2));
			return result;
		}
Example #27
0
 public Vector3 predicateFirePoint(behaviac.Agent target)
 {
     return Vector3.zero;
 }
Example #28
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			int opr1 = ((AgentNodeTest)pAgent).testVar_1;
			int opr2 = 1;
			((AgentNodeTest)pAgent).testVar_1 = (int)(opr1 + opr2);
			return result;
		}
Example #29
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			behaviac.Agent pAgent_opl = behaviac.Utils.GetParentAgent(pAgent, "par_child_agent_1");
			Debug.Check(pAgent_opl != null || Utils.IsStaticClass("par_child_agent_1"));
			Debug.Check(behaviac.Utils.MakeVariableId("testInt") == 2614050066u);
			int opl = pAgent_opl.GetVariable<int>(2614050066u);
			int opr = ((AgentNodeTest)pAgent).testVar_0;
			bool op = opl == opr;
			return op ? EBTStatus.BT_SUCCESS : EBTStatus.BT_FAILURE;
		}
Example #30
0
		protected override EBTStatus update_impl(behaviac.Agent pAgent, behaviac.EBTStatus childStatus)
		{
			EBTStatus result = EBTStatus.BT_SUCCESS;
			Debug.Check(behaviac.Utils.MakeVariableId("par_int_type_1") == 3913197411u);
			int opr1 = pAgent.GetVariable<int>(3913197411u);
			Debug.Check(behaviac.Utils.MakeVariableId("par_int_type_2") == 3256087712u);
			int opr2 = pAgent.GetVariable<int>(3256087712u);
			Debug.Check(behaviac.Utils.MakeVariableId("par_int_type_0") == 4028995106u);
			pAgent.SetVariable<int>("par_int_type_0", 4028995106u, (int)(opr1 / opr2));
			return result;
		}