private void CacheItems() { this.CheckCreateSorters(); this.cachedItems.Clear(); List <Thing> list = CaravanInventoryUtility.AllInventoryItems(base.SelCaravan); int seed = 0; for (int i = 0; i < list.Count; i++) { TransferableImmutable transferableImmutable = TransferableUtility.TransferableMatching <TransferableImmutable>(list[i], this.cachedItems, TransferAsOneMode.Normal); if (transferableImmutable == null) { transferableImmutable = new TransferableImmutable(); this.cachedItems.Add(transferableImmutable); } transferableImmutable.things.Add(list[i]); seed = Gen.HashCombineInt(seed, list[i].GetHashCode()); } IOrderedEnumerable <TransferableImmutable> source = this.cachedItems.OrderBy((TransferableImmutable tr) => tr, this.sorter1.Comparer).ThenBy((TransferableImmutable tr) => tr, this.sorter2.Comparer); if (WITab_Caravan_Items.< > f__mg$cache0 == null) { WITab_Caravan_Items.< > f__mg$cache0 = new Func <TransferableImmutable, float>(TransferableUIUtility.DefaultListOrderPriority); } this.cachedItems = source.ThenBy(WITab_Caravan_Items.< > f__mg$cache0).ToList <TransferableImmutable>(); this.cachedItemsCount = list.Count; this.cachedItemsHash = seed; }
private void SubtractFromToLoadList(Thing t, int count) { if (leftToLoad == null) { return; } var transferableOneWay = TransferableUtility.TransferableMatching(t, leftToLoad, TransferAsOneMode.PodsOrCaravanPacking); if (transferableOneWay == null) { return; } transferableOneWay.AdjustBy(-count); if (transferableOneWay.CountToTransfer <= 0) { leftToLoad.Remove(transferableOneWay); } if (!AnyInGroupHasAnythingLeftToLoad) { Messages.Message("MessageFinishedLoadingTransporters".Translate(), parent, MessageTypeDefOf.PositiveEvent); } }
public void AddToTheToLoadList(TransferableOneWay t, int count) { if (!t.HasAnyThing || t.CountToTransfer <= 0) { return; } if (leftToLoad == null) { leftToLoad = new List <TransferableOneWay>(); } if (TransferableUtility.TransferableMatching(t.AnyThing, leftToLoad, TransferAsOneMode.PodsOrCaravanPacking) != null) { Log.Error("Transferable already exists."); return; } var transferableOneWay = new TransferableOneWay(); leftToLoad.Add(transferableOneWay); transferableOneWay.things.AddRange(t.things); transferableOneWay.AdjustTo(count); }
public static void AddThings(Dialog_FormCaravan dialog, Map map) { //Add manifest if (Settings.Get().caravanSaveManifest&& SaveManifest.caravan && map == SaveManifest.savedMap && SaveManifest.savedMap != null) { foreach (ThingCountUNLIMITED thingCount in SaveManifest.savedManifest) { Log.Message($"Loading {thingCount.thing}:{thingCount.count}"); TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(thingCount.thing, dialog.transferables, TransferAsOneMode.PodsOrCaravanPacking); transferableOneWay?.AdjustTo(transferableOneWay.ClampAmount(transferableOneWay.CountToTransfer + thingCount.count)); } } //Add selection else if (Settings.Get().caravanLoadSelection) { foreach (object obj in Find.Selector.SelectedObjectsListForReading.Where(o => o is Thing)) { if (obj is Thing thing) { Log.Message($"Adding Selected {thing}:{thing.stackCount}"); TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(thing, dialog.transferables, TransferAsOneMode.PodsOrCaravanPacking); transferableOneWay?.AdjustTo(transferableOneWay.ClampAmount(transferableOneWay.CountToTransfer + thing.stackCount)); } } } }
public static void Load(List <TransferableOneWay> transferables) { foreach (ThingCountUNLIMITED thingCount in SaveManifest.savedManifest) { Log.Message($"Loading {thingCount.thing}:{thingCount.count}"); TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(thingCount.thing, transferables, TransferAsOneMode.PodsOrCaravanPacking); transferableOneWay?.AdjustTo(transferableOneWay.ClampAmount(transferableOneWay.CountToTransfer + thingCount.count)); } }
private void AddToTransferables(Thing t) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(t, this.transferables, TransferAsOneMode.PodsOrCaravanPacking); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); this.transferables.Add(transferableOneWay); } transferableOneWay.things.Add(t); }
private void AddToTransferables(Thing t) { TransferableOneWay transferable = TransferableUtility.TransferableMatching(t, transferables, TransferAsOneMode.PodsOrCaravanPacking); if (transferable is null) { transferable = new TransferableOneWay(); transferables.Add(transferable); } transferable.things.Add(t); }
private static void AddToTransferables(Thing t, List <TransferableOneWay> transferables) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(t, transferables, TransferAsOneMode.Normal); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); transferables.Add(transferableOneWay); } transferableOneWay.things.Add(t); }
private void AddToTransferables(Thing t) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(t, this.transferables); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); this.transferables.Add(transferableOneWay); } transferableOneWay.things.Add(t); }
private static void AddThingsToTransferables(List <TransferableOneWay> transferables, Thing thing) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(thing, transferables); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); transferables.Add(transferableOneWay); } transferableOneWay.things.Add(thing); DropShipUtility.AdjustToOneWayReflection(transferableOneWay, thing.stackCount); }
private void AddToTransferables(Thing t) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(t, this.transferables); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); this.transferables.Add(transferableOneWay); } transferableOneWay.things.Add(t); transferableOneWay.countToTransfer -= ship.GetInnerContainer().ToList().FindAll(x => transferableOneWay.ThingDef == x.def).Count; }
private void AddToTransferablesSelected(Thing t) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching(t, transferables, TransferAsOneMode.PodsOrCaravanPacking); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); transferables.Add(transferableOneWay); } transferableOneWay.things.Add(t); transferableOneWay.AdjustTo(t.stackCount); }
private static void AddThingsToTransferables(List <TransferableOneWay> transferables, Thing thing) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(thing, transferables); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); transferables.Add(transferableOneWay); } transferableOneWay.things.Add(thing); transferableOneWay.countToTransfer = thing.stackCount; }
public static Job JobOnTransporter(Pawn p, CompTransporterPawn transporter) { Cthulhu.Utility.DebugReport("JobOnTransporter Called"); Thing thing = LoadTransportersPawnJobUtility.FindThingToLoad(p, transporter); return(new Job(JobDefOf.HaulToContainer, thing, transporter.parent) { count = Mathf.Min( TransferableUtility.TransferableMatching <TransferableOneWay>(thing, transporter.leftToLoad, TransferAsOneMode.PodsOrCaravanPacking).CountToTransfer, thing.stackCount), ignoreForbidden = true }); }
public static Job JobLoadShipCargo(Pawn p, ShipBase ship) { Thing thing = LoadShipCargoUtility.FindThingToLoad(p, ship); if (thing != null) { return(new Job(ShipNamespaceDefOfs.LoadContainerMultiplePawns, thing, ship) { count = Mathf.Min(TransferableUtility.TransferableMatching <TransferableOneWay>(thing, ship.compShip.leftToLoad).countToTransfer, thing.stackCount), ignoreForbidden = true }); } return(null); }
public static void Postfix(Dialog_LoadTransporters __instance, Map ___map) { //Add manifest if (Mod.settings.caravanSaveManifest && !SaveManifest.caravan && ___map == SaveManifest.savedMap && SaveManifest.savedMap != null) { foreach (ThingCountUNLIMITED thingCount in SaveManifest.savedManifest) { Log.Message($"Loading {thingCount.thing}:{thingCount.count}"); TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(thingCount.thing, __instance.Transferables(), TransferAsOneMode.PodsOrCaravanPacking); transferableOneWay?.AdjustTo(transferableOneWay.ClampAmount(transferableOneWay.CountToTransfer + thingCount.count)); } } //No selection like caravans - you're already selecting pods! }
private void AddToTransferables(Thing t, bool setToTransferMax = false) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(t, this.transferables, TransferAsOneMode.PodsOrCaravanPacking); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); this.transferables.Add(transferableOneWay); } transferableOneWay.things.Add(t); if (setToTransferMax) { transferableOneWay.AdjustTo(transferableOneWay.CountToTransfer + t.stackCount); } }
private void AddToTransferables(Thing t, bool setToTransferMax = false) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(t, this.transferables); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); this.transferables.Add(transferableOneWay); } transferableOneWay.things.Add(t); if (setToTransferMax) { transferableOneWay.AdjustTo(transferableOneWay.MaxCount); } }
private void AddToTransferables(Thing t, int countAlreadyIn = 0) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(t, this.transferables); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); this.transferables.Add(transferableOneWay); } // Dialog_LoadShipCargo.RemoveExistingTransferable(transferableOneWay, null, this.ship); transferableOneWay.things.Add(t); transferableOneWay.AdjustBy(-countAlreadyIn); }
/// <summary> /// Объединяет одинаковые вещи в список внутри одного контейнера TransferableOneWay /// </summary> /// <param name=""></param> /// <returns></returns> public static List <TransferableOneWay> DistinctThings(IEnumerable <Thing> things) { var transferables = new List <TransferableOneWay>(); foreach (var item in things) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching <TransferableOneWay>(item, transferables, TransferAsOneMode.Normal); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); transferables.Add(transferableOneWay); } transferableOneWay.things.Add(item); } return(transferables); }
private void AddToTransferables(Thing t) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching(t, transferables, TransferAsOneMode.Normal); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); transferables.Add(transferableOneWay); } if (transferableOneWay.things.Contains(t)) { Log.Error("Tried to add the same thing twice to TransferableOneWay: " + t); } else { transferableOneWay.things.Add(t); } }
private void AddToTransferables(Thing t, bool setToTransferMax = false) { TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatching(t, transferables, TransferAsOneMode.PodsOrCaravanPacking); if (transferableOneWay == null) { transferableOneWay = new TransferableOneWay(); transferables.Add(transferableOneWay); } if (transferableOneWay.things.Contains(t)) { Log.Error("Tried to add the same thing twice to TransferableOneWay: " + t); return; } transferableOneWay.things.Add(t); if (setToTransferMax) { transferableOneWay.AdjustTo(transferableOneWay.CountToTransfer + t.stackCount); } }
public void AddToTheToLoadList(TransferableOneWay t, int count) { if (!t.HasAnyThing || t.CountToTransfer <= 0) { Log.Message("NoThingsToTransfer"); return; } if (this.leftToLoad == null) { this.leftToLoad = new List <TransferableOneWay>(); } if (TransferableUtility.TransferableMatching <TransferableOneWay>(t.AnyThing, this.leftToLoad) != null) { Log.Error("Transferable already exists."); return; } TransferableOneWay transferableOneWay = new TransferableOneWay(); this.leftToLoad.Add(transferableOneWay); transferableOneWay.things.AddRange(t.things); transferableOneWay.countToTransfer = count; }
private void CacheItems() { CheckCreateSorters(); cachedItems.Clear(); List <Thing> list = CaravanInventoryUtility.AllInventoryItems(base.SelCaravan); int seed = 0; for (int i = 0; i < list.Count; i++) { TransferableImmutable transferableImmutable = TransferableUtility.TransferableMatching(list[i], cachedItems, TransferAsOneMode.Normal); if (transferableImmutable == null) { transferableImmutable = new TransferableImmutable(); cachedItems.Add(transferableImmutable); } transferableImmutable.things.Add(list[i]); seed = Gen.HashCombineInt(seed, list[i].GetHashCode()); } cachedItems = cachedItems.OrderBy((TransferableImmutable tr) => tr, sorter1.Comparer).ThenBy((TransferableImmutable tr) => tr, sorter2.Comparer).ThenBy(TransferableUIUtility.DefaultListOrderPriority) .ToList(); cachedItemsCount = list.Count; cachedItemsHash = seed; }