public void Instantiate(Property property_, object value) { Debug.Check(property_ != null); //string varirableName = property_.GetVariableName(); //if (varirableName == "TempTargetEnemy") //{ // Debug.Check(true); //} uint varId = property_.GetVariableId(); if (!this.m_variables.ContainsKey(varId)) { IVariable pVar = new IVariable(null, property_); behaviac.Debug.Check(pVar != null); pVar.SetValue(value, null); m_variables[varId] = pVar; } else { IVariable pVar = this.m_variables[varId]; Debug.Check(pVar.m_instantiated < 255, "dead loop?!"); //don't update it, so the par set by outer scope can override the one in the internal if (pVar.m_instantiated == 0) { pVar.SetProperty(property_); } else { Debug.Check(pVar.GetValue(null) == null || (property_.GetValue(null) == null && Utils.IsNullValueType(pVar.GetValue(null).GetType())) || pVar.GetValue(null).GetType() == property_.GetValue(null).GetType(), "the same name par doesn't have the same type"); } //use the original value, don't update it pVar.m_instantiated++; } }
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); }
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; }
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); }
public void SetFrom(Agent pAgentFrom, Property from, Agent pAgentTo) { object value = from.GetValue(pAgentFrom); this.SetValue(pAgentTo, value); }
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; }
public void SetFrom(Agent pAgentFrom, Property from, Agent pAgentTo) { object retV = from.GetValue(pAgentFrom); this.SetValue(pAgentTo, retV); }
public object run(Agent parent, Agent parHolder) { if (this.m_params != null) { for (int i = 0; i < this.m_params.Length; i++) { Property paramProperty = this.m_params[i].paramProperty; if (paramProperty != null) { this.m_param_values[i] = paramProperty.GetValue(parent, parHolder); } if (this.m_params[i].paramStructMembers != null) { Type type = this.m_param_values[i].GetType(); Agent.CTagObjectDescriptor descriptorByName = Agent.GetDescriptorByName(type.get_FullName()); using (DictionaryView <string, Property> .Enumerator enumerator = this.m_params[i].paramStructMembers.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <string, Property> current = enumerator.get_Current(); CMemberBase member = descriptorByName.GetMember(current.get_Key()); if (member != null) { object value = current.get_Value().GetValue(parent, parHolder); member.Set(this.m_param_values[i], value); } } } } } } object result = this.method_.Invoke(parent, this.m_param_values); if (this.m_params != null) { for (int j = 0; j < this.m_params.Length; j++) { Property paramProperty2 = this.m_params[j].paramProperty; if (paramProperty2 != null) { object v = this.m_param_values[j]; paramProperty2.SetValue(parHolder, v); } if (this.m_params[j].paramStructMembers != null) { Type type2 = this.m_param_values[j].GetType(); Agent.CTagObjectDescriptor descriptorByName2 = Agent.GetDescriptorByName(type2.get_FullName()); using (DictionaryView <string, Property> .Enumerator enumerator2 = this.m_params[j].paramStructMembers.GetEnumerator()) { while (enumerator2.MoveNext()) { KeyValuePair <string, Property> current2 = enumerator2.get_Current(); CMemberBase member2 = descriptorByName2.GetMember(current2.get_Key()); if (member2 != null) { object v2 = member2.Get(this.m_param_values[j]); current2.get_Value().SetValue(parHolder, v2); } } } } } } return(result); }
public void Instantiate(Property property_, object value) { Debug.Check(property_ != null); uint varId = property_.GetVariableId(); if (!this.m_variables.ContainsKey(varId)) { IVariable pVar = new IVariable(null, property_); behaviac.Debug.Check(pVar != null); pVar.SetValue(value, null); m_variables[varId] = pVar; } else { IVariable pVar = this.m_variables[varId]; Debug.Check(pVar.m_instantiated < 255, "dead loop?!"); //don't update it, so the par set by outer scope can override the one in the internal if (pVar.m_instantiated == 0) { pVar.SetProperty(property_); } else { Debug.Check((property_.GetValue(null) == null && pVar.GetValue(null).GetType().IsSubclassOf(typeof(Agent))) || pVar.GetValue(null).GetType() == property_.GetValue(null).GetType(), "the same name par doesn't have the same type"); } //use the original value, don't update it pVar.m_instantiated++; } }