public static bool PlayerSellableNow(Thing t, ITrader trader) { t = t.GetInnerIfMinified(); if (!EverPlayerSellable(t.def)) { return(false); } if (t.IsNotFresh()) { return(false); } Apparel apparel = t as Apparel; if (apparel != null && apparel.WornByCorpse) { return(false); } if (EquipmentUtility.IsBiocoded(t)) { return(false); } Pawn pawn = t as Pawn; if (pawn != null && ((pawn.GetExtraHostFaction() != null && pawn.GetExtraHostFaction() == trader.Faction) || (pawn.IsQuestLodger() && pawn.GetExtraHomeFaction() == trader.Faction))) { return(false); } return(true); }
private static bool DisplayTradeStats(StatRequest req) { ThingDef thingDef; if ((thingDef = req.Def as ThingDef) == null) { return(false); } if (req.HasThing && EquipmentUtility.IsBiocoded(req.Thing)) { return(false); } if (thingDef.category == ThingCategory.Building && thingDef.Minifiable) { return(true); } if (TradeUtility.EverPlayerSellable(thingDef)) { return(true); } if (thingDef.tradeability.TraderCanSell() && (thingDef.category == ThingCategory.Item || thingDef.category == ThingCategory.Pawn)) { return(true); } return(false); }
public override bool Matches(Thing t) { if (!t.def.IsApparel) { return(false); } return(EquipmentUtility.IsBiocoded(t)); }
public void Wear(Apparel newApparel, bool dropReplacedApparel = true, bool locked = false) { if (newApparel.Spawned) { newApparel.DeSpawn(); } if (!ApparelUtility.HasPartsToWear(pawn, newApparel.def)) { Log.Warning(pawn + " tried to wear " + newApparel + " but he has no body parts required to wear it."); return; } if (EquipmentUtility.IsBiocoded(newApparel) && !EquipmentUtility.IsBiocodedFor(newApparel, pawn)) { CompBiocodable compBiocodable = newApparel.TryGetComp <CompBiocodable>(); Log.Warning(pawn + " tried to wear " + newApparel + " but it is biocoded for " + compBiocodable.CodedPawnLabel + " ."); return; } for (int num = wornApparel.Count - 1; num >= 0; num--) { Apparel apparel = wornApparel[num]; if (!ApparelUtility.CanWearTogether(newApparel.def, apparel.def, pawn.RaceProps.body)) { if (dropReplacedApparel) { bool forbid = pawn.Faction != null && pawn.Faction.HostileTo(Faction.OfPlayer); if (!TryDrop(apparel, out Apparel _, pawn.PositionHeld, forbid)) { Log.Error(pawn + " could not drop " + apparel); return; } } else { Remove(apparel); } } } if (newApparel.Wearer != null) { Log.Warning(pawn + " is trying to wear " + newApparel + " but this apparel already has a wearer (" + newApparel.Wearer + "). This may or may not cause bugs."); } wornApparel.TryAdd(newApparel, canMergeWithExistingStacks: false); if (locked) { Lock(newApparel); } }
private Apparel FindGarmentSatisfyingTitleRequirement(Pawn pawn, RoyalTitleDef.ApparelRequirement req) { Room room = pawn.GetRoom(); if (room.isPrisonCell) { foreach (IntVec3 cell in room.Cells) { List <Thing> thingList = cell.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { Apparel apparel = thingList[i] as Apparel; if (apparel != null && req.ApparelMeetsRequirement(thingList[i].def, allowUnmatched: false) && pawn.CanReserve(apparel) && !apparel.IsBurning() && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def)) { return(apparel); } } } } return(null); }
private Apparel FindGarmentCoveringPart(Pawn pawn, BodyPartGroupDef bodyPartGroupDef) { Room room = pawn.GetRoom(); if (room.isPrisonCell) { foreach (IntVec3 cell in room.Cells) { List <Thing> thingList = cell.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { Apparel apparel = thingList[i] as Apparel; if (apparel != null && apparel.def.apparel.bodyPartGroups.Contains(bodyPartGroupDef) && pawn.CanReserve(apparel) && !apparel.IsBurning() && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def)) { return(apparel); } } } } return(null); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn.outfits == null) { Log.ErrorOnce(pawn + " tried to run JobGiver_OptimizeApparel without an OutfitTracker", 5643897); return(null); } if (pawn.Faction != Faction.OfPlayer) { Log.ErrorOnce("Non-colonist " + pawn + " tried to optimize apparel.", 764323); return(null); } if (pawn.IsQuestLodger()) { return(null); } if (!DebugViewSettings.debugApparelOptimize) { if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick) { return(null); } } else { debugSb = new StringBuilder(); debugSb.AppendLine("Scanning for " + pawn + " at " + pawn.Position); } Outfit currentOutfit = pawn.outfits.CurrentOutfit; List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int num = wornApparel.Count - 1; num >= 0; num--) { if (!currentOutfit.filter.Allows(wornApparel[num]) && pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(wornApparel[num]) && !pawn.apparel.IsLocked(wornApparel[num])) { Job job = JobMaker.MakeJob(JobDefOf.RemoveApparel, wornApparel[num]); job.haulDroppedApparel = true; return(job); } } Thing thing = null; float num2 = 0f; List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel); if (list.Count == 0) { SetNextOptimizeTick(pawn); return(null); } neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn)); for (int i = 0; i < list.Count; i++) { Apparel apparel = (Apparel)list[i]; if (currentOutfit.filter.Allows(apparel) && apparel.IsInAnyStorage() && !apparel.IsForbidden(pawn) && !apparel.IsBurning() && (apparel.def.apparel.gender == Gender.None || apparel.def.apparel.gender == pawn.gender) && (!apparel.def.apparel.tags.Contains("Royal") || pawn.royalty.AllTitlesInEffectForReading.Count != 0)) { float num3 = ApparelScoreGain(pawn, apparel); if (DebugViewSettings.debugApparelOptimize) { debugSb.AppendLine(apparel.LabelCap + ": " + num3.ToString("F2")); } if (!(num3 < 0.05f) && !(num3 < num2) && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def) && pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger())) { thing = apparel; num2 = num3; } } } if (DebugViewSettings.debugApparelOptimize) { debugSb.AppendLine("BEST: " + thing); Log.Message(debugSb.ToString()); debugSb = null; } if (thing == null) { SetNextOptimizeTick(pawn); return(null); } return(JobMaker.MakeJob(JobDefOf.Wear, thing)); }