Example #1
0
 public IVariable clone()
 {
     IVariable pVar = new IVariable(this);
     return pVar;
 }
Example #2
0
        public IVariable(IVariable copy)
        {
            m_id = copy.m_id;
            m_name = copy.m_name;
            m_property = copy.m_property;
            m_pMember = copy.m_pMember;
            m_instantiated = copy.m_instantiated;
			DeepCopy(out m_value, copy.m_value);
			//m_value = copy.m_value;

#if !BEHAVIAC_RELEASE
			m_changed = copy.m_changed;
#endif
        }
Example #3
0
        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++;
            }
        }
Example #4
0
		public void Set(Agent pAgent, CMemberBase pMember, string variableName, object value, uint varId)
        {
            Debug.Check(!string.IsNullOrEmpty(variableName));

			if (varId == 0) 
			{
				varId = Utils.MakeVariableId(variableName);			
			}

            IVariable pVar = null;

            if (!this.m_variables.ContainsKey(varId))
            {
				if (pMember == null)
				{
					if (pAgent != null)
					{
						pMember = pAgent.FindMember(variableName); 
					}
					else
					{
						pMember = Agent.FindMemberBase(variableName);
					}
				}

                pVar = new IVariable(pMember, variableName, varId);
				behaviac.Debug.Check(pVar != null);
                m_variables[varId] = pVar;
            }
            else
            {
                pVar = this.m_variables[varId];
            }

			pVar.SetValue(value, pAgent);
        }
Example #5
0
        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++;
            }
        }