/************************************************ * 与仓库交换电池 * *********************************************/ public static bool CsStrargeSupplyExchangeBattery(PeEntity npc, CSAssembly assembly, List <ItemObject> objs, int protoId, int count = 1) { if (assembly == null || assembly.Storages == null || npc.packageCmpt == null) { return(false); } List <ItemObject> curObjs = CSUtils.GetItemListInStorage(protoId, assembly); //当前背包里不可以用的item if (objs != null) { for (int i = 0; i < objs.Count; i++) { //put back if (CSUtils.AddItemObjToStorage(objs[i].instanceId, assembly)) { npc.packageCmpt.Remove(objs[i]); } } } if (curObjs.Count <= 0) { return(false); } for (int i = 0; i < curObjs.Count; i++) { Energy energy = curObjs[i].GetCmpt <Energy>(); if (energy != null && energy.floatValue.percent > 0) { if (CSUtils.RemoveItemObjFromStorage(curObjs[i].instanceId, assembly)) { return(npc.packageCmpt.Add(curObjs[i])); } } } return(false); }