Пример #1
0
        private float CalculateFlirtStyleWeight(FlirtStyleDef flirtStyle, Pawn pawn, Pawn other)
        {
            string flirtLog = pawn.Name.ToStringShort + " => " + other.Name.ToStringShort + " considers " + flirtStyle.defName + ": ";

            //if a pawn has a canceling trait, we abort immediately
            for (int i = 0; i < flirtStyle.cancelingTraits.Count(); i++)
            {
                if (pawn.story.traits.HasTrait(flirtStyle.cancelingTraits[i]))
                {
                    flirtLog += "canceled by " + flirtStyle.cancelingTraits[i].defName + ".";
                    LogFlirt(flirtLog);
                    return(0f);
                }
            }
            //we start with base weight chance
            float weight = flirtStyle.baseChance;

            //add relationship factor
            weight   *= RelationshipFactorForFlirtStyle(RelationshipUtility.MostAdvancedRomanceOrExStage(pawn, other), flirtStyle);
            flirtLog += "base " + weight.ToString() + " ";
            //calculate attraction factors

            /*
             * weight *= recipientPhysicalAttraction * flirtStyle.baseSexiness;
             * flirtLog += "physical " + weight.ToString() + " ";
             * weight *= recipientRomanticAttraction * flirtStyle.baseRomance;
             * flirtLog += "romantic " + weight.ToString() + " ";
             * weight *= recipientSocialAttraction * flirtStyle.baseLogic;
             * flirtLog += "logical " + weight.ToString() + " ";
             */


            //calculate promoting traits
            for (int i = 0; i < flirtStyle.traitModifiers.Count(); i++)
            {
                if (pawn.story.traits.HasTrait(flirtStyle.traitModifiers[i].trait))
                {
                    weight    = weight * flirtStyle.traitModifiers[i].modifier;
                    flirtLog += flirtStyle.traitModifiers[i].trait.defName + ": " + weight.ToString() + " ";
                }
            }
            if (PsycheHelper.PsychologyEnabled(pawn) && GradualRomanceMod.AttractionCalculation == GradualRomanceMod.AttractionCalculationSetting.Complex)
            {
                //calculate contributing personality traits
                for (int i = 0; i < flirtStyle.moreLikelyPersonalities.Count(); i++)
                {
                    PersonalityNodeModifier currentModifier = flirtStyle.moreLikelyPersonalities[i];
                    weight    = weight * Mathf.Pow(Mathf.Lerp(0.5f, 1.5f, PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(currentModifier.personalityNode)), currentModifier.modifier);
                    flirtLog += currentModifier.personalityNode.defName + "+: " + weight.ToString() + " ";
                }
                for (int i = 0; i < flirtStyle.lessLikelyPersonalities.Count(); i++)
                {
                    PersonalityNodeModifier currentModifier = flirtStyle.lessLikelyPersonalities[i];
                    weight    = weight * Mathf.Pow(Mathf.Lerp(0.5f, 1.5f, Mathf.Abs(1 - PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(currentModifier.personalityNode))), currentModifier.modifier);
                    flirtLog += currentModifier.personalityNode.defName + "-: " + weight.ToString() + " ";
                }
            }
            if (flirtStyle.incompetent)
            {
                weight   *= pressureCache;
                flirtLog += "pressure: " + weight.ToString() + " ";
            }

            flirtLog += "end.";
            LogFlirt(flirtLog);
            return(weight);
        }