private bool CheckAndFillCorpseProduct() { if (HasCorpseProduct && HasWorkFlow) { return(true); } if (MyCsDebug) { Log.Warning( DebugStr + " cant work without corpseProduct, Loading it " + "for pawn:" + pawn?.ThingID + " corpse:" + Corpse?.ThingID ); } if (pawn.RetrieveCorpseJobDef(out MyDebug, MyCsDebug) is CorpseJobDef DefToUse) { string meFunc = MyCsDebug ? "CheckAndFillCorpseProduct" : string.Empty; IEnumerable <CorpseRecipeSettings> CRSList = pawn.RetrieveCorpseRecipeSettings(DefToUse, MyDebug) .Where(c => c.target.ValidateCorpse(Corpse, pawn, MyDebug, meFunc)); /* * IEnumerable<CorpseRecipeSettings> CRSPrime = pawn.RetrieveCorpseRecipeSettings(DefToUse, MyDebug); * * if (MyDebug && !CRSPrime.EnumerableNullOrEmpty()) * Log.Warning(meFunc + " found " + CRSPrime.Count() + " prime CRS"); * * IEnumerable<CorpseRecipeSettings> CRSList = CRSPrime.Where(c => FindCorpse.ValidateCorpse(Corpse, pawn.Map, pawn.Faction, c.target, MyDebug, meFunc)); */ if (CRSList.EnumerableNullOrEmpty()) { Log.Warning(DebugStr + "did not find CorpseRecipeSettings relative to Corpse " + Corpse.ThingID); return(false); } else { if (MyDebug) { Log.Warning(meFunc + " found " + CRSList.Count() + " CRS"); } } RetrievedCRS = CRSList.FirstOrFallback(); if (RetrievedCRS == null) { Log.Warning(DebugStr + "did not find CorpseRecipeSettings relative to Corpse (2)"); return(false); } if (MyDebug) { Log.Warning(DebugStr + " did it - OK"); } return(true); } return(false); }
public static Toil SpawnProductDespawnCorpse(this CorpseRecipeSettings CRS, Pawn ParentPawn, Corpse corpse, bool MyDebug = false) { return(new Toil { initAction = delegate { //CRS.product.SpawnConsumptionProduct(corpse, ParentPawn, SpawnPos, map, MyDebug); CRS.product.SpawnConsumptionProduct(corpse, ParentPawn, corpse.Position, MyDebug); if (CRS.HasWorkFlow && CRS.workFlow.MustStrip) { CRS.workFlow.strip.StripAndDamageBelongings(corpse); } corpse.Destroy(DestroyMode.KillFinalize); }, atomicWithPrevious = true }); }