Beispiel #1
0
        /**
         * bind 'agentInstanceName' to 'pAgentInstance'.
         * 'agentInstanceName' should have been registered to the class of 'pAgentInstance' or its parent class.
         *
         * @sa RegisterName
         */
        public bool BindInstance(Agent pAgentInstance, string agentInstanceName)
        {
            if (string.IsNullOrEmpty(agentInstanceName))
            {
                agentInstanceName = pAgentInstance.GetType().FullName;
            }

            if (Agent.IsNameRegistered(agentInstanceName))
            {
                Debug.Check(GetInstance(agentInstanceName) == null, "the name has been bound to an instance already!");

                string className = Agent.GetRegisteredClassName(agentInstanceName);

                if (Agent.IsDerived(pAgentInstance, className))
                {
                    m_namedAgents[agentInstanceName] = pAgentInstance;

                    return(true);
                }
            }
            else
            {
                Debug.Check(false);
            }

            return(false);
        }
Beispiel #2
0
        public virtual bool IsValid(Agent pAgent, BehaviorTask pTask)
        {
#if !BEHAVIAC_RELEASE
            Debug.Check(!string.IsNullOrEmpty(this.m_agentType));

            return(Agent.IsDerived(pAgent, this.m_agentType));
#else
            return(true);
#endif//#if !BEHAVIAC_RELEASE
        }
Beispiel #3
0
 public bool BindInstance(Agent pAgentInstance, string agentInstanceName)
 {
     if (string.IsNullOrEmpty(agentInstanceName))
     {
         agentInstanceName = pAgentInstance.GetType().get_FullName();
     }
     if (Agent.IsNameRegistered(agentInstanceName))
     {
         string registeredClassName = Agent.GetRegisteredClassName(agentInstanceName);
         if (Agent.IsDerived(pAgentInstance, registeredClassName))
         {
             this.m_namedAgents.set_Item(agentInstanceName, pAgentInstance);
             return(true);
         }
     }
     return(false);
 }