public static IEnumerable <IPawnTransformer> GetAllTransformers([NotNull] this HediffDef hediff)
        {
            if (hediff == null)
            {
                throw new ArgumentNullException(nameof(hediff));
            }

            foreach (IPawnTransformer pawnTransformer in hediff.GetAllHediffGivers().OfType <IPawnTransformer>())
            {
                yield return(pawnTransformer);
            }


            foreach (IPawnTransformer pawnTransformer in hediff.stages.MakeSafe().OfType <IPawnTransformer>())
            {
                yield return(pawnTransformer);
            }
        }
Example #2
0
        public static IEnumerable <MorphDef> GetAssociatedMorph(HediffDef transformationDef)
        {
            if (_morphAssociationCache.TryGetValue(transformationDef, out List <MorphDef> lst))
            {
                return(lst);
            }

            lst = new List <MorphDef>();

            var enumerable = transformationDef.GetAllHediffGivers().Select(g => g.hediff).OfType <MutationDef>();

            foreach (MutationDef mutationDef in enumerable)
            {
                if (mutationDef.classInfluence is MorphDef morph)
                {
                    if (!lst.Contains(morph))
                    {
                        lst.Add(morph);
                    }
                }
            }
            _morphAssociationCache[transformationDef] = lst;
            return(lst);
        }