コード例 #1
0
        public void Notify_CaravanArrived(Caravan caravan)
        {
            Pawn pawn = BestCaravanPawnUtility.FindBestDiplomat(caravan);

            if (pawn == null)
            {
                Messages.Message("MessagePeaceTalksNoDiplomat".Translate(), caravan, MessageTypeDefOf.NegativeEvent, false);
                return;
            }
            float badOutcomeWeightFactor = PeaceTalks.GetBadOutcomeWeightFactor(pawn);
            float num = 1f / badOutcomeWeightFactor;

            PeaceTalks.tmpPossibleOutcomes.Clear();
            PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate()
            {
                this.Outcome_Disaster(caravan);
            }, 0.05f * badOutcomeWeightFactor));
            PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate()
            {
                this.Outcome_Backfire(caravan);
            }, 0.1f * badOutcomeWeightFactor));
            PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate()
            {
                this.Outcome_TalksFlounder(caravan);
            }, 0.2f));
            PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate()
            {
                this.Outcome_Success(caravan);
            }, 0.55f * num));
            PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate()
            {
                this.Outcome_Triumph(caravan);
            }, 0.1f * num));
            Action first = PeaceTalks.tmpPossibleOutcomes.RandomElementByWeight((Pair <Action, float> x) => x.Second).First;

            first();
            pawn.skills.Learn(SkillDefOf.Social, 6000f, true);
            Find.WorldObjects.Remove(this);
        }
コード例 #2
0
        private static void AppendDebugChances(StringBuilder sb, float negotiationAbility)
        {
            if (sb.Length > 0)
            {
                sb.AppendLine();
            }
            sb.AppendLine("--- NegotiationAbility = " + negotiationAbility.ToStringPercent() + " ---");
            float badOutcomeWeightFactor = PeaceTalks.GetBadOutcomeWeightFactor(negotiationAbility);
            float num = 1f / badOutcomeWeightFactor;

            sb.AppendLine("Bad outcome weight factor: " + badOutcomeWeightFactor.ToString("0.##"));
            float num2 = 0.05f * badOutcomeWeightFactor;
            float num3 = 0.1f * badOutcomeWeightFactor;
            float num4 = 0.2f;
            float num5 = 0.55f * num;
            float num6 = 0.1f * num;
            float num7 = num2 + num3 + num4 + num5 + num6;

            sb.AppendLine("Disaster: " + (num2 / num7).ToStringPercent());
            sb.AppendLine("Backfire: " + (num3 / num7).ToStringPercent());
            sb.AppendLine("Talks flounder: " + (num4 / num7).ToStringPercent());
            sb.AppendLine("Success: " + (num5 / num7).ToStringPercent());
            sb.AppendLine("Triumph: " + (num6 / num7).ToStringPercent());
        }
コード例 #3
0
        private static void AppendDebugChances(StringBuilder sb, float diplomacyPower)
        {
            if (sb.Length > 0)
            {
                sb.AppendLine();
            }
            sb.AppendLine("--- DiplomacyPower = " + diplomacyPower.ToStringPercent() + " ---");
            float badOutcomeWeightFactor = PeaceTalks.GetBadOutcomeWeightFactor(diplomacyPower);
            float num = (float)(1.0 / badOutcomeWeightFactor);

            sb.AppendLine("Bad outcome weight factor: " + badOutcomeWeightFactor.ToString("0.##"));
            float num2 = (float)(0.05000000074505806 * badOutcomeWeightFactor);
            float num3 = (float)(0.10000000149011612 * badOutcomeWeightFactor);
            float num4 = 0.2f;
            float num5 = (float)(0.550000011920929 * num);
            float num6 = (float)(0.10000000149011612 * num);
            float num7 = num2 + num3 + num4 + num5 + num6;

            sb.AppendLine("Disaster: " + (num2 / num7).ToStringPercent());
            sb.AppendLine("Backfire: " + (num3 / num7).ToStringPercent());
            sb.AppendLine("Talks flounder: " + (num4 / num7).ToStringPercent());
            sb.AppendLine("Success: " + (num5 / num7).ToStringPercent());
            sb.AppendLine("Triumph: " + (num6 / num7).ToStringPercent());
        }
コード例 #4
0
        private static float GetBadOutcomeWeightFactor(Pawn diplomat)
        {
            float statValue = diplomat.GetStatValue(StatDefOf.NegotiationAbility, true);

            return(PeaceTalks.GetBadOutcomeWeightFactor(statValue));
        }
コード例 #5
0
        private static float GetBadOutcomeWeightFactor(Pawn diplomat)
        {
            float statValue = diplomat.GetStatValue(StatDefOf.DiplomacyPower, true);

            return(PeaceTalks.GetBadOutcomeWeightFactor(statValue));
        }