//---------------------------------------------------------------------------- public TCtrl Register <TCtrl, TBase>(string strAssetID, IMsgPipe pipe, bool bLocal = true, eUIImpower _impower = eUIImpower.Default) where TCtrl : UIController, new() where TBase : UIBase, new() { UISystem system = GetUISystem(); if (system.HasUIClass(strAssetID)) { return(default);
//---------------------------------------------------------------------------- protected override bool DispatchMsg_Down(IMsg msg, IMsgPipe except = null) { bool bResult = false; bResult = base.DispatchMsg_Down(msg, except); if (!bResult && ReferenceEquals(_curSubState, null) && @ReferenceEquals(_curSubState, except)) { bResult = _curSubState.ProcessMsg(msg); } return(bResult); }
//---------------------------------------------------------------------------- protected bool SwitchMsgUp2Down(IMsg msg, IMsgPipe fromWhere) { if (msg.m_Direction != MsgDispatchDir.MDD_UP || !m_bSwitchMsgUp2Down) { return(false); } bool bResult = false; msg.m_Direction = MsgDispatchDir.MDD_Down; bResult = DispatchMsg_Down(msg, fromWhere); msg.m_Direction = MsgDispatchDir.MDD_UP; return(bResult); }
//---------------------------------------------------------------------------- public override void PlugInMsgPipe(IMsgPipe thePipe) { itor = SubStateDict.GetEnumerator(); while (itor.MoveNext()) { if (ReferenceEquals(itor.Current.Value, thePipe)) { Debug.LogWarning("子状态不能插到父亲身上"); return; } } base.PlugInMsgPipe(thePipe); }
//---------------------------------------------------------------------------- protected bool SwitchMsgUp2Down(int msgId, ref MsgDispatchDir direction, IMsgPipe fromWhere) { if (direction != MsgDispatchDir.MDD_UP || !m_bSwitchMsgUp2Down) { return(false); } bool bResult = false; direction = MsgDispatchDir.MDD_Down; bResult = DispatchMsg_Down(msgId, direction, fromWhere); direction = MsgDispatchDir.MDD_UP; return(bResult); }
//---------------------------------------------------------------------------- public void PullOutMsgPipe(IMsgPipe thePipe) { if (thePipe == null) { return; } if (thePipe.m_pParentPipe != null) { Debug.LogWarning("not exists"); return; } if (m_listChildPipe != null && m_listChildPipe.Contains(thePipe)) { thePipe.m_pParentPipe = null; m_listChildPipe.Remove(thePipe); } }
//function //---------------------------------------------------------------------------- virtual public bool ProcessMsg(IMsg msg, IMsgPipe fromWhere = null) { bool bResult = false; //处理消息 bResult = ExecuteMsg(msg); //上转下 if (!bResult) { bResult = SwitchMsgUp2Down(msg, fromWhere); } //分发 if (!bResult) { bResult = DispatchMsg(msg); return(bResult); } return(bResult); }
//---------------------------------------------------------------------------- public virtual void PlugInMsgPipe(IMsgPipe thePipe) { if (thePipe == null) { return; } if (thePipe.m_pParentPipe != null) { if (thePipe.m_pParentPipe == this) { Debug.LogWarning("already Plug In!"); return; } thePipe.m_pParentPipe.PullOutMsgPipe(thePipe); } thePipe.m_pParentPipe = this; if (m_listChildPipe == null) { m_listChildPipe = new List <IMsgPipe>(); } m_listChildPipe.Add(thePipe); }
protected virtual bool DispatchMsg_Down(int msgId, MsgDispatchDir direction, IMsgPipe except = null) { bool bResult = false; if (m_listChildPipe == null) { return(bResult); } for (int i = 0; i < m_listChildPipe.Count; ++i) { if (m_listChildPipe[i] != except) { bResult = m_listChildPipe[i].ProcessMsg(msgId, direction, this); if (bResult) { break; } } } return(bResult); }
//---------------------------------------------------------------------------- protected virtual bool DispatchMsg_Down(IMsg msg, IMsgPipe except = null) { bool bResult = false; if (m_listChildPipe == null) { return(bResult); } int nChildNum = m_listChildPipe.Count; for (int i = 0; i < nChildNum; i++) { if (m_listChildPipe[i] != except) { bResult = m_listChildPipe[i].ProcessMsg(msg, this); if (bResult) { break; } } } return(bResult); }
//---------------------------------------------------------------------------- virtual public bool ProcessMsg <T>(int msgId, T arg, MsgDispatchDir direction = MsgDispatchDir.MDD_Down, IMsgPipe fromWhere = null) { bool bResult = false; //处理消息 bResult = ExecuteMsg(msgId, arg); //上转下 if (!bResult) { bResult = SwitchMsgUp2Down(msgId, arg, ref direction, fromWhere); } //分发 if (!bResult) { bResult = DispatchMsg(msgId, arg, direction); } return(bResult); }