/// <inheritdoc/> public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams) { if (pawn?.inventory?.innerContainer == null) { return(ThinkResult.NoJob); } if (!pawn.UseLoadout(out CompAwesomeInventoryLoadout comp)) { return(ThinkResult.NoJob); } foreach (Thing thing in pawn.inventory.innerContainer) { if (thing is Apparel apparel) { bool extra = true; CompAwesomeInventoryLoadout.ThingGroupSelectorPool pool = comp.FindPotentialThingGroupSelectors(thing, comp.Loadout); if (pool.OrderedSelectorTuples.Any()) { foreach (var tuple in pool.OrderedSelectorTuples) { if (!(comp.InventoryMargins[tuple.Item2] > 0)) { extra = false; break; } } } if (extra) { if (StoreUtility.TryFindBestBetterStorageFor(apparel, pawn, pawn.Map, StoreUtility.CurrentStoragePriorityOf(apparel), pawn.Faction, out _, out _)) { UnloadApparelJob job = new UnloadApparelJob(thing); return(new ThinkResult(job, this, JobTag.UnloadingOwnInventory)); } } } } return(ThinkResult.NoJob); }
/* * public static IEnumerable<FloatMenuOption> EquipAndAddToLoadout(Pawn pawn, Thing thing) * { * if (pawn.UseLoadout(out CompAwesomeInventoryLoadout comp)) * { * if (comp.Loadout != null) * { * } * } * } */ /* * private static IEnumerable<FloatMenuOption> OptionForSpawnThing(Pawn pawn, Thing thing, CompAwesomeInventoryLoadout comp) * { * List<FloatMenuOption> options = new List<FloatMenuOption>(); * if (thing.def.IsWeapon) * { * var option = FloatMenuUtility.DecoratePrioritizedTask( * new FloatMenuOption( * "Equip, keep the replaced and add to loadout" * , () => * { * EquipWeaponDialog(pawn, thing); * } * , MenuOptionPriority.High) * , pawn * , thing); * options.Add(option); * } * else if (thing.def.IsApparel) * { * var option = FloatMenuUtility.DecoratePrioritizedTask( * new FloatMenuOption( * "Wear, keep the replaced and add to loadout" * , () => * { * WearApparel(pawn, thing, false); * AddToLoadoutDialog(pawn, comp, thing, false); * } * , MenuOptionPriority.High) * , pawn * , thing); * options.Add(option); * } * else * { * var option = FloatMenuUtility.DecoratePrioritizedTask( * new FloatMenuOption( * "Pick up and add to loadout" * , () => * { * AddToLoadoutDialog(pawn, comp, thing, true); * } * , MenuOptionPriority.High) * , pawn * , thing); * options.Add(option); * } * } */ /// <summary> /// Create loadout options(add to loadout or remove from loadout) for <paramref name="thing"/> that <paramref name="pawn"/> carries. /// </summary> /// <param name="pawn"> Pawn who carries <paramref name="thing"/>. </param> /// <param name="thing"> Thing that is carried by <paramref name="pawn"/>. </param> /// <param name="comp"> Comp on <paramref name="pawn"/>. </param> /// <returns> Returns different options based on the condition that whether <paramref name="thing"/> is in <paramref name="pawn"/>'s loadout. </returns> public static FloatMenuOption OptionForThingOnPawn(Pawn pawn, Thing thing, CompAwesomeInventoryLoadout comp) { ValidateArg.NotNull(comp, nameof(comp)); CompAwesomeInventoryLoadout.ThingGroupSelectorPool pool = comp.FindPotentialThingGroupSelectors(thing, comp.Loadout); if (pool.OrderedSelectorTuples.Any()) { return(MakeDecoratedOption( UIText.RemoveFromLoadout.Translate(comp.Loadout.label) , () => comp.Loadout.Remove(pool.OrderedSelectorTuples.First().Item2) , pawn , thing)); } else { return(MakeDecoratedOption( UIText.AddToLoadout.Translate(comp.Loadout.label) , () => AddToLoadoutDialog(pawn, comp, thing) , pawn , thing)); } }