コード例 #1
0
        private static bool Prefix(Pawn_RelationsTracker __instance, Pawn ___pawn, Pawn otherPawn, ref float __result)
        {
            if (!___pawn.RaceProps.Humanlike || !otherPawn.RaceProps.Humanlike || ___pawn == otherPawn)
            {
                __result = 0f;
                return(false);
            }
            float num1 = Mathf.Abs(___pawn.ageTracker.AgeBiologicalYearsFloat - otherPawn.ageTracker.AgeBiologicalYearsFloat);
            float num2 = GenMath.LerpDouble(0f, 20f, 0.45f, -0.45f, num1);

            num2 = Mathf.Clamp(num2, -0.45f, 0.45f);
            float num3 = __instance.ConstantPerPawnsPairCompatibilityOffset(otherPawn.thingIDNumber);

            float num4 = 0f;

            if (___pawn.def is RaceAddonThingDef thingDef1)
            {
                if (thingDef1.raceAddonSettings.relationSetting.specialRaces.Find(x => x.raceDef == otherPawn.def) is var set && set != null)
                {
                    num4 = set.compatibilityBonus;
                }
                else if (___pawn.def == otherPawn.def || thingDef1.raceAddonSettings.relationSetting.sameRaces.Contains(otherPawn.def))
                {
                    num4 = thingDef1.raceAddonSettings.relationSetting.sameRace.compatibilityBonus;
                }
                else
                {
                    num4 = thingDef1.raceAddonSettings.relationSetting.otherRace.compatibilityBonus;
                }
            }
コード例 #2
0
        internal static float               _CompatibilityWith(this Pawn_RelationsTracker _this, Pawn otherPawn)
        {
            var pawn = _this.GetPawn();

            if (!PawnsAreValidMatches(pawn, otherPawn))
            {
                return(0f);
            }
            return(Mathf.Clamp(GenMath.LerpDouble(0.0f, 20f, 0.45f, -0.45f, Mathf.Abs(pawn.ageTracker.AgeBiologicalYearsFloat - otherPawn.ageTracker.AgeBiologicalYearsFloat)), -0.45f, 0.45f) + _this.ConstantPerPawnsPairCompatibilityOffset(otherPawn.thingIDNumber));
        }