public void CopyTo(Agent pAgent, Variables target) { target.m_variables.Clear(); var e = this.m_variables.Keys.GetEnumerator(); while (e.MoveNext()) { uint id = e.Current; IInstantiatedVariable pVar = this.m_variables[id]; IInstantiatedVariable pNew = pVar.clone(); target.m_variables[id] = pNew; } if (!Object.ReferenceEquals(pAgent, null)) { e = target.m_variables.Keys.GetEnumerator(); while (e.MoveNext()) { uint id = e.Current; IInstantiatedVariable pVar = this.m_variables[id]; pVar.CopyTo(pAgent); } } }
public void Log(Agent agent) { #if !BEHAVIAC_RELEASE var e = this.m_variables.Keys.GetEnumerator(); while (e.MoveNext()) { uint id = e.Current; IInstantiatedVariable pVar = this.m_variables[id]; pVar.Log(agent); } #endif }
public override void AddVariable(uint varId, IInstantiatedVariable pVar, int stackIndex) { if (this.state_stack != null && this.state_stack.Count > 0 && stackIndex > 0 && stackIndex < this.state_stack.Count) { AgentState t = this.state_stack[stackIndex]; t.AddVariable(varId, pVar, -1); } else { base.AddVariable(varId, pVar, -1); } }
private void CopyTopValueTo(AgentState newly) { var e = this.m_variables.Keys.GetEnumerator(); while (e.MoveNext()) { uint id = e.Current; IInstantiatedVariable pVar = this.GetVariable(id); IInstantiatedVariable pNew = pVar.clone(); newly.m_variables[id] = pNew; } }
public Dictionary <uint, IInstantiatedVariable> InstantiateCustomizedProperties() { Dictionary <uint, IInstantiatedVariable> vars = new Dictionary <uint, IInstantiatedVariable>(); //instance customzied properties { var e = this._customizedProperties.Keys.GetEnumerator(); while (e.MoveNext()) { uint id = e.Current; ICustomizedProperty pCustomProperty = this._customizedProperties[id]; vars[id] = pCustomProperty.Instantiate(); } } if (_customizedStaticVars == null) { _customizedStaticVars = new Dictionary <uint, IInstantiatedVariable>(); var e = this._customizedStaticProperties.Keys.GetEnumerator(); while (e.MoveNext()) { uint id = e.Current; ICustomizedProperty pCustomProperty = this._customizedStaticProperties[id]; this._customizedStaticVars[id] = pCustomProperty.Instantiate(); } } //static customzied properties { var e = this._customizedStaticVars.Keys.GetEnumerator(); while (e.MoveNext()) { uint id = e.Current; IInstantiatedVariable pVar = this._customizedStaticVars[id]; vars[id] = pVar; } } return(vars); }
internal void SetVariable <VariableType>(string variableName, VariableType value) { uint variableId = Utils.MakeVariableId(variableName); if (this.LocalVars.ContainsKey(variableId)) { IInstantiatedVariable v = this.LocalVars[variableId]; CVariable <VariableType> var = (CVariable <VariableType>)v; if (var != null) { var.SetValue(null, value); return; } } Debug.Check(false, string.Format("The variable \"{0}\" with type \"{1}\" can not be found!", variableName, typeof(VariableType).Name)); }
public override IInstantiatedVariable GetVariable(uint varId) { if (this.state_stack != null && this.state_stack.Count > 0) { for (int i = this.state_stack.Count - 1; i >= 0; --i) { AgentState t = this.state_stack[i]; IInstantiatedVariable pVar = t.GetVariable(varId); if (pVar != null) { return(pVar); } } } return(base.GetVariable(varId)); }
public virtual void AddVariable(uint varId, IInstantiatedVariable pVar, int stackIndex) { Debug.Check(!this.m_variables.ContainsKey(varId)); this.m_variables[varId] = pVar; }