예제 #1
0
        public static void HideHats(ref bool hideHair, ref bool hideBeard, ref bool showHat, Rot4 bodyFacing)
        {
            try
            {
                //Log.Error($"Start {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                // Determine if hat should be shown
                if (flags.FlagSet(PawnRenderFlags.Portrait) && Prefs.HatsOnlyOnMap)
                {
                    showHat   = false;
                    hideHair  = false;
                    hideBeard = false;
                    //Log.Error($"0 {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                    return;
                }

                if (showHat == false ||
                    Settings.OnlyApplyToColonists && FactionUtility.IsPlayerSafe(pawn.Faction) == false && !Settings.OptionsOpen)
                {
                    //Log.Error($"1 {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                    return;
                }

                if (hideHair == false && showHat == false)
                {
                    CheckHideHat(ref hideHair, ref hideBeard, ref showHat, false);
                    //Log.Error($"2 {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                    return;
                }

                hideHair  = false;
                hideBeard = false;

                if (Settings.HideAllHats)
                {
                    showHat = false;
                    //Log.Error($"3 {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                    return;
                }

                if (Settings.ShowHatsOnlyWhenDrafted)
                {
                    showHat = isDrafted;
                    //Log.Error($"4.a {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                }
                else if (showHat &&
                         (Settings.Indoors == Indoors.HideHats ||
                          (Settings.Indoors == Indoors.ShowHatsWhenDrafted && !isDrafted)))
                {
                    CompCeilingDetect comp = pawn.GetComp <CompCeilingDetect>();
                    if (comp != null && comp.IsIndoors)
                    {
                        showHat   = false;
                        hideHair  = false;
                        hideBeard = false;
                        return;
                        //Log.Error($"4.b {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                    }
                }

                if (pawn.story?.hairDef != null && Settings.HairToHide.TryGetValue(pawn.story.hairDef, out bool hide) && hide)
                {
                    hideHair  = true;
                    hideBeard = true;
                    showHat   = true;
                    //Log.Error($"5 {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
                    return;
                }

                CheckHideHat(ref hideHair, ref hideBeard, ref showHat, false);
            }
            finally
            {
                if (!hideBeard)
                {
                    hideBeard = bodyFacing == Rot4.North;
                }
                skipDontShaveHead = !showHat;
            }
            //Log.Error($"Final {pawn.Name.ToStringShort} hideHair:{hideHair}  hideBeard:{hideBeard}  showHat:{showHat}");
        }