/// <summary> /// 从配置创建状态机 /// </summary> /// <param name="fsmXMLEntity"></param> /// <returns></returns> public bool CreateFromFSMXML(CFSMXMLEntity fsmXMLEntity) { if (fsmXMLEntity == null) { return(false); } m_uEnteranceStateId = fsmXMLEntity.m_uEntranceStateId; m_uAnyStateId = fsmXMLEntity.m_uAnyStateId; Int32 nStateSize = fsmXMLEntity.m_FSMStateList == null ? 0 : fsmXMLEntity.m_FSMStateList.Count; for (Int32 i = 0; i < nStateSize; ++i) { CFSMXMLState xmlState = fsmXMLEntity.m_FSMStateList[i]; if (xmlState == null) { continue; } CFSMExecutableState fsmState = new CFSMExecutableState(); if (fsmState.CreateFromXML(xmlState) == false) { BTDebug.Warning("<BTFSM> Create FSM State Failed"); continue; } AddState(fsmState); } return(true); }
/// <summary> /// 从xml脚本数据创建 /// </summary> /// <param name="xmlState"></param> /// <returns></returns> public bool CreateFromXML(CFSMXMLState xmlState) { if (xmlState == null) { return(false); } m_strStateName = xmlState.m_strName; m_uStateID = xmlState.m_uStateId; List <CFSMTransition> transList = CreateTransitionListFromXML(xmlState.m_transArray); if (transList != null && m_TransitionList != null) { m_TransitionList.AddRange(transList); } m_EnterActionList = CreateActionListFromXML(xmlState.m_Enter); m_ExitActionList = CreateActionListFromXML(xmlState.m_Exit); m_ProcessActionList = CreateActionListFromXML(xmlState.m_Process); return(true); }