public float RetrieveAttractionForCategory(AttractionFactorCategoryDef category)
 {
     if (category.alwaysRecalculate)
     {
         Log.Error("[Gradual_Romance] Tried to pull a record for " + category.defName + ", but category is set to AlwaysRecalculate and is never stored.");
         return(1f);
     }
     return(categoryCalculations[category]);
 }
Пример #2
0
        public static float CalculateAttractionCategory(AttractionFactorCategoryDef category, Pawn observer, Pawn assessed)
        {
            List <AttractionFactorDef> veryHighFactors = new List <AttractionFactorDef>()
            {
            };
            List <AttractionFactorDef> highFactors = new List <AttractionFactorDef>()
            {
            };
            List <AttractionFactorDef> lowFactors = new List <AttractionFactorDef>()
            {
            };
            List <AttractionFactorDef> veryLowFactors = new List <AttractionFactorDef>()
            {
            };
            AttractionFactorDef reasonForInstantFailure = null;

            return(CalculateAttractionCategory(category, observer, assessed, out veryLowFactors, out lowFactors, out highFactors, out veryHighFactors, out reasonForInstantFailure));
        }
Пример #3
0
        private float CalculateAndSort(AttractionFactorCategoryDef category, Pawn observer, Pawn assessed, bool observerIsInitiator = true)
        {
            float result = AttractionUtility.CalculateAttractionCategory(category, observer, assessed, out List <AttractionFactorDef> veryLowFactors, out List <AttractionFactorDef> lowFactors, out List <AttractionFactorDef> hightFactors, out List <AttractionFactorDef> veryHighFactors, out AttractionFactorDef reasonForInstantFailure);

            if (observerIsInitiator)
            {
                veryHighInitiatorReasons.AddRange(veryHighFactors);
                highInitiatorReasons.AddRange(hightFactors);
                lowInitiatorReasons.AddRange(lowFactors);
                veryLowInitiatorReasons.AddRange(veryLowFactors);
                intiatorFailureReasons.Add(reasonForInstantFailure);
            }
            else
            {
                veryHighRecipientReasons.AddRange(veryHighFactors);
                highRecipientReasons.AddRange(hightFactors);
                lowRecipientReasons.AddRange(lowFactors);
                veryLowRecipientReasons.AddRange(veryLowFactors);
                recipientFailureReasons.Add(reasonForInstantFailure);
            }
            return(result);
        }
        public float RetrieveAttractionForCategory(Pawn other, AttractionFactorCategoryDef category)
        {
            AttractionRecord record = PullRecord(other);

            return(record.RetrieveAttractionForCategory(category));
        }
Пример #5
0
        public static float CalculateAttractionCategory(AttractionFactorCategoryDef category, Pawn observer, Pawn assessed, out List <AttractionFactorDef> veryLowFactors, out List <AttractionFactorDef> lowFactors, out List <AttractionFactorDef> highFactors, out List <AttractionFactorDef> veryHighFactors, out AttractionFactorDef reasonForInstantFailure)
        {
            //Log.Message("Method start.");
            //Log.Message("Making null values.");
            veryHighFactors = new List <AttractionFactorDef>()
            {
            };
            highFactors = new List <AttractionFactorDef>()
            {
            };
            lowFactors = new List <AttractionFactorDef>()
            {
            };
            veryLowFactors = new List <AttractionFactorDef>()
            {
            };
            reasonForInstantFailure = null;
            //Log.Message("Retrieving factor defs.");
            IEnumerable <AttractionFactorDef> allFactors = (from def in DefDatabase <AttractionFactorDef> .AllDefsListForReading
                                                            where def.category == category
                                                            select def);

            float attraction = 1f;

            //Log.Message("Starting factor calculations for " + allFactors.Count().ToString() + "factors");

            foreach (AttractionFactorDef factor in allFactors)
            {
                if (factor.calculator.Check(observer, assessed) == false)
                {
                    continue;
                }

                //Log.Message("Doing calculation for " + factor.defName);
                float result = CalculateFactor(observer, assessed, factor);
                if (result == 1f)
                {
                    continue;
                }
                if (result == 0f)
                {
                    if (GradualRomanceMod.detailedAttractionLogs)
                    {
                        Log.Message("Instantly failed at " + factor.defName);
                    }
                    veryLowFactors.Add(factor);
                    reasonForInstantFailure = factor;
                    return(0f);
                }
                if (factor.hidden)
                {
                    continue;
                }
                //Log.Message("Sort factor into results.");
                if (result >= veryHighReasonThreshold)
                {
                    veryHighFactors.Add(factor);
                }
                else if (result >= highReasonThreshold)
                {
                    highFactors.Add(factor);
                }
                else if (result <= veryLowReasonThreshold)
                {
                    veryLowFactors.Add(factor);
                }
                else if (result <= lowReasonThreshold)
                {
                    lowFactors.Add(factor);
                }
                //Log.Message("Integrating result.");
                if (GradualRomanceMod.detailedAttractionLogs)
                {
                    Log.Message(factor.defName + "(" + observer.Name.ToStringShort + "," + assessed.Name.ToStringShort + ")(" + category.defName + "): " + result.ToString() + "=>" + (attraction * result).ToString());
                }

                attraction *= result;
            }
            //Log.Message("Concluding method.");
            return(attraction);
        }