Esempio n. 1
0
 public static bool CacheMissingPartsCommonAncestors(HediffSet __instance)
 {
     if (__instance.cachedMissingPartsCommonAncestors == null)
     {
         __instance.cachedMissingPartsCommonAncestors = new List <Hediff_MissingPart>();
     }
     else
     {
         __instance.cachedMissingPartsCommonAncestors.Clear();
     }
     missingPartsCommonAncestorsQueue.Clear();
     missingPartsCommonAncestorsQueue.Enqueue(__instance.pawn.def.race.body.corePart);
     while (missingPartsCommonAncestorsQueue.Count != 0)
     {
         BodyPartRecord node = missingPartsCommonAncestorsQueue.Dequeue();
         if (!__instance.PartOrAnyAncestorHasDirectlyAddedParts(node))
         {
             Hediff_MissingPart hediffMissingPart = __instance.GetHediffs <Hediff_MissingPart>().Where <Hediff_MissingPart>((Func <Hediff_MissingPart, bool>)(x => x.Part == node)).FirstOrDefault <Hediff_MissingPart>();
             if (hediffMissingPart != null)
             {
                 __instance.cachedMissingPartsCommonAncestors.Add(hediffMissingPart);
             }
             else
             {
                 for (int index = 0; index < node.parts.Count; ++index)
                 {
                     missingPartsCommonAncestorsQueue.Enqueue(node.parts[index]);
                 }
             }
         }
     }
     return(false);
 }
Esempio n. 2
0
        public static bool CacheMissingPartsCommonAncestors(HediffSet __instance)
        {
            if (cachedMissingPartsCommonAncestors(__instance) == null)
            {
                cachedMissingPartsCommonAncestors(__instance) = new List <Hediff_MissingPart>();
            }

            lock (cachedMissingPartsCommonAncestors(__instance))
            {
                cachedMissingPartsCommonAncestors(__instance).Clear();
                missingPartsCommonAncestorsQueue(__instance).Clear();
                missingPartsCommonAncestorsQueue(__instance).Enqueue(__instance.pawn.def.race.body.corePart);
                while (missingPartsCommonAncestorsQueue(__instance).Count != 0)
                {
                    BodyPartRecord node = missingPartsCommonAncestorsQueue(__instance).Dequeue();
                    if (node != null)
                    {
                        if (__instance.PartOrAnyAncestorHasDirectlyAddedParts(node))
                        {
                            continue;
                        }

                        Hediff_MissingPart hediff_MissingPart = (from x in __instance.GetHediffs <Hediff_MissingPart>()
                                                                 where x.Part == node
                                                                 select x).FirstOrDefault();
                        if (hediff_MissingPart != null)
                        {
                            cachedMissingPartsCommonAncestors(__instance).Add(hediff_MissingPart);
                            continue;
                        }

                        for (int i = 0; i < node.parts.Count; i++)
                        {
                            lock (missingPartsCommonAncestorsQueue(__instance))
                            {
                                missingPartsCommonAncestorsQueue(__instance).Enqueue(node.parts[i]);
                            }
                        }
                    }
                }
            }
            return(false);
        }