Пример #1
0
 public void RemoveArticle(ArticleObjType target, TArticleData data)
 {
     if (!IsStarNegotiation)
     {
         CLog.Error("AddArticle 没有调用StarNegotiation");
         return;
     }
     if (data == null)
     {
         return;
     }
     if (target == ArticleObjType.Self)
     {
         TempSelfArticlies.Remove(data);
         BaseTempSelfArticlies.Remove(data);
         TempSelfArticlies     = TempSelfArticlies.OrderBy((x) => x.TDID).ToList();
         BaseTempSelfArticlies = BaseTempSelfArticlies.OrderBy((x) => x.TDID).ToList();
     }
     if (target == ArticleObjType.Target)
     {
         TempTargetArticlies.Remove(data);
         BaseTempTargetArticlies.Remove(data);
         TempTargetArticlies     = TempTargetArticlies.OrderBy((x) => x.TDID).ToList();
         BaseTempTargetArticlies = BaseTempTargetArticlies.OrderBy((x) => x.TDID).ToList();
     }
     if (BaseGlobal.IsUnReadData)
     {
         Callback_OnRemoveArticle?.Invoke(data);
     }
 }
Пример #2
0
        public void AddArticle(string articleID, ArticleObjType targetType, Callback <TArticleData> action)
        {
            if (!IsStarNegotiation)
            {
                CLog.Error("AddArticle 没有调用StarNegotiation");
                return;
            }
            TArticleData data = TDLuaMgr.Get <TArticleData>(articleID);

            if (data == null)
            {
                return;
            }
            if (!IsCanAddArticle(targetType, data))
            {
                return;
            }
            var newData = data.Copy <TArticleData>();

            action?.Invoke(newData);
            if (IsRepeate(targetType, newData))
            {
                return;
            }

            if (targetType == ArticleObjType.Self)
            {
                newData.ArticleObjType = targetType;
                newData.SetSelfBaseUnit(SelfArticleUnit);
                newData.BaseTarget = TargetArticleUnit;
                TempSelfArticlies.Add(newData);
                BaseTempSelfArticlies.Add(newData);
                if (newData.IsMutex)
                {
                    RemoveArticle(ArticleObjType.Target, TempTargetArticlies.FindLast(x => x.TDID == articleID));
                }
                TempSelfArticlies     = TempSelfArticlies.OrderBy((x) => x.TDID).ToList();
                BaseTempSelfArticlies = BaseTempSelfArticlies.OrderBy((x) => x.TDID).ToList();
            }
            else if (targetType == ArticleObjType.Target)
            {
                newData.ArticleObjType = targetType;
                newData.SetSelfBaseUnit(TargetArticleUnit);
                newData.BaseTarget = SelfArticleUnit;
                TempTargetArticlies.Add(newData);
                BaseTempTargetArticlies.Add(newData);
                if (newData.IsMutex)
                {
                    RemoveArticle(ArticleObjType.Self, TempSelfArticlies.FindLast(x => x.TDID == articleID));
                }
                TempTargetArticlies     = TempTargetArticlies.OrderBy((x) => x.TDID).ToList();
                BaseTempTargetArticlies = BaseTempTargetArticlies.OrderBy((x) => x.TDID).ToList();
            }
            if (BaseGlobal.IsUnReadData)
            {
                Callback_OnAddArticle?.Invoke(newData);
            }
            return;
        }
Пример #3
0
 void clearNagotiation()
 {
     CurNegotiationType = null;
     CurNegotiation     = null;
     IsStarNegotiation  = false;
     BaseTempSelfArticlies.Clear();
     BaseTempTargetArticlies.Clear();
     TempSelfArticlies.Clear();
     TempTargetArticlies.Clear();
 }