示例#1
0
        private static void BeardRoulette(
            [NotNull] Pawn pawn,
            FactionDef factionType,
            out BeardDef mainBeard,
            out MoustacheDef moustache)
        {
            moustache = MoustacheDefOf.Shaved;
            IEnumerable <BeardDef> source;

            {
                source = from beard in DefDatabase <BeardDef> .AllDefs

                         // where !beard.forbiddenOnRace.Contains(pawn.def)
                         where beard.hairTags.SharesElementWith(factionType.hairTags)
                         select beard;
            }

            if (!source.Any())
            {
                source = from beard in DefDatabase <BeardDef> .AllDefs select beard;
            }

            BeardDef chosenBeard;
            float    rand = Rand.Value;
            bool     flag = false;

            if (pawn.ageTracker.AgeBiologicalYearsFloat < 19)
            {
                chosenBeard = BeardDefOf.Beard_Shaved;
                flag        = true;
            }
            else if (rand < 0.1f)
            {
                chosenBeard = BeardDefOf.Beard_Shaved;
            }
            else if (rand < 0.2f)
            {
                chosenBeard = BeardDefOf.Beard_Stubble;
            }
            else
            {
                chosenBeard = source.RandomElementByWeight(beard => BeardChoiceLikelihoodFor(beard, pawn));
            }

            mainBeard = chosenBeard;
            if (!flag && mainBeard.beardType != BeardType.FullBeard)
            {
                moustache = MoustacheRoulette(pawn, factionType);
            }
        }
示例#2
0
        public static void RandomBeardDefFor(
            [NotNull] CompFace face,
            [NotNull] FactionDef factionType,
            [NotNull] out BeardDef mainBeard,
            [NotNull] out MoustacheDef moustache)
        {
            if (!face.Props.hasBeard)
            {
                mainBeard = BeardDefOf.Beard_Shaved;
                moustache = MoustacheDefOf.Shaved;
                return;
            }

            BeardRoulette(face.Pawn, factionType, out mainBeard, out moustache);
        }
示例#3
0
        private static float TacheChoiceLikelihoodFor([NotNull] MoustacheDef tache, Pawn pawn)
        {
            if (tache.hairTags.Contains("MaleOld") && pawn.ageTracker.AgeBiologicalYears < 37)
            {
                return(0f);
            }

            switch (tache.hairGender)
            {
            case HairGender.Male: return(70f);

            case HairGender.MaleUsually: return(30f);
            }

            Log.Error(string.Concat("Unknown tache likelihood for ", tache, " with ", pawn));
            return(0f);
        }