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++; } }
public object Get(Agent pAgent, uint varId) { IVariable variable = null; if (this.m_variables.TryGetValue(varId, out variable)) { Property property = variable.GetProperty(); if (property != null) { string refName = property.GetRefName(); if (!string.IsNullOrEmpty(refName)) { return(this.Get(pAgent, property.GetRefNameId())); } } return(variable.GetValue(pAgent)); } CMemberBase cMemberBase = pAgent.FindMember(varId); if (cMemberBase != null) { return(cMemberBase.Get(pAgent)); } return(null); }
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 object Get(Agent pAgent, uint varId) { if (!this.m_variables.ContainsKey(varId)) { //possible static property CMemberBase pMember = pAgent.FindMember(varId); if (pMember != null) { object pAddr = pMember.Get(pAgent); return(pAddr); } Debug.Check(false, "a compatible property is not found"); } else { //par IVariable pVar = this.m_variables[varId]; { Property refPropety = pVar.GetProperty(); if (refPropety != null) { string refName = refPropety.GetRefName(); if (!string.IsNullOrEmpty(refName)) { return(this.Get(pAgent, refPropety.GetRefNameId())); } } return(pVar.GetValue(pAgent)); } } return(null); }
public object Get(Agent pAgent, uint varId) { IVariable variable = null; if (!this.m_variables.TryGetValue(varId, out variable)) { CMemberBase base2 = pAgent.FindMember(varId); if (base2 != null) { return(base2.Get(pAgent)); } } else { Property property = variable.GetProperty(); if ((property != null) && !string.IsNullOrEmpty(property.GetRefName())) { return(this.Get(pAgent, property.GetRefNameId())); } return(variable.GetValue(pAgent)); } return(null); }