/// <summary> /// 转换通道是否畅通 /// 重载 /// </summary> /// <param name="fsmEntity"></param> /// <returns></returns> public override bool IsPipelineOpen(CFSM fsmEntity) { if (m_EventTrigger == null) { return(false); } List <CFSMEvent> listenedEventList = fsmEntity.GetListenedEvent(); if (listenedEventList == null) { return(false); } Int32 nSize = listenedEventList == null ? 0 : listenedEventList.Count; for (Int32 i = 0; i < nSize; ++i) { CFSMEvent listenedEvent = listenedEventList[i]; bool bTrigger = m_EventTrigger.Trigger(listenedEvent); if (bTrigger == true) { return(true); } } return(false); }
/// <summary> /// 状态更新 /// </summary> /// <param name="fsmEntity"></param> /// <param name="fsmEvent"></param> public override bool Process(CFSM fsmEntity, CFSMEvent fsmEvent) { if (m_ProcessActionList == null) { return(true); } if (fsmEntity == null) { return(false); } Int32 nActionSize = m_ProcessActionList.Count; bool bInvokeRet = true; for (Int32 i = 0; i < nActionSize; ++i) { CFSMAction action = m_ProcessActionList[i]; if (action == null) { continue; } System.Object objReturnValue = null; bInvokeRet &= action.InvokeWhenPipelineOpen(fsmEntity, out objReturnValue); } return(bInvokeRet); }
/// <summary> /// 获取状态机该状态下的下一个转换状态 /// </summary> /// <param name="fsmEntity"></param> /// <returns></returns> public virtual UInt32 GetFSMTransState(CFSM fsmEntity) { UInt32 uNextState = cuInvalieStateId; if (m_TransitionList == null) { return(uNextState); } Int32 nSize = m_TransitionList.Count; for (Int32 i = 0; i < nSize; ++i) { CFSMTransition fsmTrans = m_TransitionList[i]; if (fsmTrans == null) { continue; } if (fsmTrans.CheckTransition(fsmEntity) == true) { uNextState = fsmTrans.GetTargetStateId(); break; } } return(uNextState); }
/// <summary> /// 是否条件符合 /// </summary> /// <param name="fsmEntity"></param> /// <returns></returns> public bool IsFit(CFSM fsmEntity) { if (fsmEntity == null) { return(false); } Int32 nSize = m_ConditionCmpList == null ? 0 : m_ConditionCmpList.Count; for (Int32 i = 0; i < nSize; ++i) { CFSMConditionCmp conCmp = m_ConditionCmpList[i]; if (conCmp == null) { continue; } string strMemberName = conCmp.GetMemberName(); System.Object objCondition = null; if (fsmEntity.GetFSMCondition(strMemberName, out objCondition) == false || objCondition == null) { return(false); } IComparable cmpObj = objCondition as IComparable; if (cmpObj == null) { return(false); } bool bFit = conCmp.IsFit((IComparable)objCondition); if (bFit == false) { return(false); } } return(true); }
/// <summary> /// 条件符合时执行操作 /// </summary> /// <param name="fsmEntity"></param> /// <param name="rOutReturnValue"></param> /// <returns>是否执行成功,若未执行依然返回true</returns> public bool InvokeWhenPipelineOpen(CFSM fsmEntity, out System.Object rOutReturnValue) { rOutReturnValue = default(System.Object); if (CheckAction(fsmEntity) == false) { return(true); } return(ForceInvoke(fsmEntity, out rOutReturnValue)); }
/// <summary> /// 检查当前是否有管道畅通可以进行状态转换 /// </summary> /// <param name="fsmEntity"></param> /// <returns></returns> public bool CheckTransition(CFSM fsmEntity) { if (m_PipelineCollection == null) { return(false); } bool bCheck = m_PipelineCollection.IsOpenToFSM(fsmEntity); return(bCheck); }
/// <summary> /// 转换通道是否畅通 /// 重载 /// </summary> /// <param name="fsmEntity"></param> /// <returns></returns> public override bool IsPipelineOpen(CFSM fsmEntity) { if (m_ConditionTrigger == null) { return(true); } bool bIsOpen = m_ConditionTrigger.IsFit(fsmEntity); return(bIsOpen); }
/// <summary> /// 执行动作 /// </summary> /// <param name="fsmEntity"></param> /// <param name="rOutReturnValue"></param> /// <returns></returns> public bool ForceInvoke(CFSM fsmEntity, out System.Object rOutReturnValue) { rOutReturnValue = default(System.Object); if (fsmEntity == null) { return(false); } if (fsmEntity.InvokeFSMAction(m_StrActionName, m_ParamArray, out rOutReturnValue) == false) { return(false); } return(true); }
public bool IsOpenToFSM(CFSM fsmEntity) { if (m_ConditionPipelineList == null) { return(true); } Int32 nSize = m_ConditionPipelineList.Count; for (Int32 i = 0; i < nSize; ++i) { CFSMPipeline pipeline = m_ConditionPipelineList[i]; if (pipeline == null) { continue; } if (pipeline.IsPipelineOpen(fsmEntity) == false) { return(false); } } return(true); }
/// <summary> /// 进入状态 /// </summary> /// <param name="fsmEntity"></param> /// <param name="fsmEvent"></param> public abstract bool OnEnter(CFSM fsmEntity, CFSMEvent fsmEvent);
/// <summary> /// 状态更新 /// </summary> /// <param name="fsmEntity"></param> /// <param name="fsmEvent"></param> public abstract bool Process(CFSM fsmEntity, CFSMEvent fsmEvent);
/// <summary> /// 是否畅通 /// 只会返回true /// </summary> /// <param name="fsmEntity"></param> /// <returns></returns> public override bool IsPipelineOpen(CFSM fsmEntity) { return(true); }
public abstract bool IsPipelineOpen(CFSM fsmEntity);