/// <summary> /// 查找指定的BaseItem /// </summary> /// <param name="name">Key值.</param> static RFCObject Find(string name) { if (mDictionary == null) { return(null); } RFCObject obj = null; mDictionary.TryGetValue(name, out obj); return(obj); }
public void RFC <T>(string methodName, params object[] parameters) { string target = typeof(T).Name; RFCObject obj = RFCObject.Find(target); if (obj == null) { Debug.LogError("Cannot Find The RFCObject: " + target); return; } for (int i = 0; i < obj.mRFCs.Count; ++i) { CachedRFC rfc = obj.mRFCs[i]; if (rfc.func.Name == methodName) { rfc.func.Invoke(obj, parameters); } } }
public void RFC(RFCType type, object param, params object[] parameters) { for (int i = 0; i < mList.Count; ++i) { RFCObject obj = mList[i]; for (int j = 0; j < obj.mRFCs.Count; ++j) { CachedRFC rfc = obj.mRFCs[j]; if (rfc.type == type && rfc.Param == param) { if (obj.ProxyTarget != null) { rfc.func.Invoke(obj.ProxyTarget, parameters); } else { rfc.func.Invoke(obj, parameters); } } } } }
// public static object SRFC<T>(string methodName, params object[] parameters) where T : RFCObject // { // string target = typeof(T).Name; // RFCObject obj = RFCObject.Find(target); // if (obj == null) // { // Debug.LogError("Cannot Find The RFCObject: " + target); // return null; // } // // for (int i = 0; i < obj.mRFCs.Count; ++i) // { // CachedRFC rfc = obj.mRFCs[i]; // if (rfc.func.Name == methodName) // { // return rfc.func.Invoke(obj, parameters); // } // } // return null; // } // // public static void SRFC(RFCType group, object param, params object[] parameters) // { // for (int i = 0; i < mList.Count; ++i) // { // RFCObject obj = mList[i]; // for (int j = 0; j < obj.mRFCs.Count; ++j) // { // CachedRFC rfc = obj.mRFCs[j]; // if (rfc.type == group) // { // rfc.func.Invoke(obj, parameters); // } // } // } // } /// <summary> /// 手动注册. /// </summary> /// <param name="target">注册目标.</param> public static void ManualRegister(MonoBehaviour target) { RFCObject rfcObject = target.gameObject.GetOrAddComponent <RFCObject>(); rfcObject.SetProxy(target); }