示例#1
0
        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);
                }
            }
        }
示例#2
0
        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
        }
示例#3
0
 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);
     }
 }
示例#4
0
        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;
            }
        }
示例#5
0
        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);
        }
示例#6
0
        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));
        }
示例#7
0
        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));
        }
示例#8
0
        public virtual void AddVariable(uint varId, IInstantiatedVariable pVar, int stackIndex)
        {
            Debug.Check(!this.m_variables.ContainsKey(varId));

            this.m_variables[varId] = pVar;
        }
示例#9
0
        public virtual void AddVariable(uint varId, IInstantiatedVariable pVar, int stackIndex)
        {
            Debug.Check(!this.m_variables.ContainsKey(varId));

            this.m_variables[varId] = pVar;
        }
示例#10
0
 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);
     }
 }