Пример #1
0
        /******************************************************
         * 基地仓库给特定npc补给(从仓库移除,添加到NPC背包)
         * ***************************************************/
        public static bool CsStorageSupply(PeEntity npc, CSAssembly assembly, int protoId, int count)
        {
            if (assembly == null || assembly.Storages == null || npc.packageCmpt == null)
            {
                return(false);
            }

            int curCount = CSUtils.GetItemCounFromFactoryAndAllStorage(protoId, assembly);

            if (curCount > count)
            {
                if (CSUtils.CountDownItemFromAllStorage(protoId, count, assembly))
                {
                    return(npc.packageCmpt.Add(protoId, count));
                }
            }
            else if (curCount > 0)
            {
                if (CSUtils.CountDownItemFromAllStorage(protoId, curCount, assembly))
                {
                    return(npc.packageCmpt.Add(protoId, curCount));
                }
            }
            return(false);
        }