public TDBaseAlertData Add(string alertName, BaseUnit cast = null) { if (!Table.Contains(alertName)) { if (CommonAlert == alertName) { CLog.Error("请手动添加 CommonAlert"); } return(null); } TDBaseAlertData tempAlert = null; if (IsHaveCache(alertName)) { tempAlert = GetCache(alertName); CachesAlert.Remove(alertName); } else { tempAlert = Table.Find(alertName).Copy(); } tempAlert.Cast = cast?cast:LocalPlayer; if (tempAlert == null) { CLog.Error("未找到alert errorId=" + alertName); return(null); } //判断通知是否可以被合并 var mergeAlert = CanMerge(tempAlert); if (mergeAlert != null) { mergeAlert.OnMerge(); Callback_OnMerge?.Invoke(mergeAlert); } else { tempAlert.ID = IDMgr.GetNextId(); Data.Add(tempAlert); tempAlert.OnBeAdded(SelfBaseUnit); Callback_OnAdded?.Invoke(tempAlert); tempAlert.OnStart(); } return(tempAlert); }
private TData Add(string tdid, BaseUnit cast = null, Callback <TData> action = null, bool isAutoTrigger = false) { if (!TDLuaMgr.Contains(tdid)) { if (CommonAlert == tdid) { CLog.Error("没有:{0},请手动添加CommonAlert", tdid); } else { CLog.Error("没有:{0},请手动添加Alert", tdid); } return(null); } TData sourceAlert = TDLuaMgr.Get <TData>(tdid); sourceAlert.Cast = cast ? cast : LocalPlayer; sourceAlert.AlertMgr = this; //判断通知是否可以被合并 var finalAlert = CanMerge(sourceAlert); if (finalAlert != null) { finalAlert.OnMerge(); Callback_OnMerge?.Invoke(finalAlert); } else { finalAlert = sourceAlert.Copy <TData>(); finalAlert.ID = IDUtil.Gen(); finalAlert.OnBeAdded(SelfBaseUnit); Data.Add(finalAlert); if (finalAlert.Type == AlertType.Interaction) { //推送最近一次的谈判信息 if (ArticleMgr.IsStarNegotiation) { ArticleMgr.PushNagotiationToAlert(finalAlert); } InteractionData.Add(finalAlert); Callback_OnInteractionChange?.Invoke(finalAlert); } else if (finalAlert.Type == AlertType.Disposable) { DisposableData.Add(finalAlert); Callback_DisposableChange?.Invoke(finalAlert); } else if (finalAlert.Type == AlertType.Continue) { ContinueData.Add(finalAlert); Callback_ContinueChange?.Invoke(finalAlert); } action?.Invoke(finalAlert); if (BaseGlobal.IsUnReadData) { Callback_OnAdded?.Invoke(finalAlert); } } if (finalAlert.IsAutoTrigger || isAutoTrigger) { finalAlert.DoLeftClickTrigger(); } return(finalAlert); }