Exemplo n.º 1
0
 public static float ChanceToLeaveGift(Faction faction, Map map)
 {
     if (faction.IsPlayer)
     {
         return(0f);
     }
     return(0.25f * VisitorGiftForPlayerUtility.PlayerWealthChanceFactor(map) * VisitorGiftForPlayerUtility.FactionRelationsChanceFactor(faction));
 }
Exemplo n.º 2
0
        private static void VisitorGiftChance()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("Current wealth factor (wealth=" + Find.CurrentMap.wealthWatcher.WealthTotal.ToString("F0") + "): ");
            stringBuilder.AppendLine(VisitorGiftForPlayerUtility.PlayerWealthChanceFactor(Find.CurrentMap).ToStringPercent());
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Chance per faction:");
            foreach (Faction current in Find.FactionManager.AllFactions)
            {
                if (!current.IsPlayer && !current.HostileTo(Faction.OfPlayer) && !current.def.hidden)
                {
                    stringBuilder.Append(string.Concat(new string[]
                    {
                        current.Name,
                        " (",
                        current.PlayerGoodwill.ToStringWithSign(),
                        ", ",
                        current.PlayerRelationKind.GetLabel(),
                        ")"
                    }));
                    stringBuilder.Append(": " + VisitorGiftForPlayerUtility.ChanceToLeaveGift(current, Find.CurrentMap).ToStringPercent());
                    stringBuilder.AppendLine(" (rels factor: " + VisitorGiftForPlayerUtility.FactionRelationsChanceFactor(current).ToStringPercent() + ")");
                }
            }
            int num = 0;

            for (int i = 0; i < 6; i++)
            {
                Dictionary <IIncidentTarget, int> dictionary;
                int[] array;
                List <Pair <IncidentDef, IncidentParms> > list;
                int num2;
                StorytellerUtility.DebugGetFutureIncidents(60, true, out dictionary, out array, out list, out num2, null, null);
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j].First == IncidentDefOf.VisitorGroup || list[j].First == IncidentDefOf.TraderCaravanArrival)
                    {
                        Faction faction = list[j].Second.faction ?? Find.FactionManager.RandomNonHostileFaction(false, false, false, TechLevel.Undefined);
                        if (Rand.Chance(VisitorGiftForPlayerUtility.ChanceToLeaveGift(faction, Find.CurrentMap)))
                        {
                            num++;
                        }
                    }
                }
            }
            float num3 = (float)num / 6f;

            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Calculated number of gifts received on average within the next 1 year");
            stringBuilder.AppendLine("(assuming current wealth and faction relations)");
            stringBuilder.Append("  = " + num3.ToString("0.##"));
            Log.Message(stringBuilder.ToString(), false);
        }
        public static float ChanceToLeaveGift(Faction faction, Map map)
        {
            float result;

            if (faction.IsPlayer)
            {
                result = 0f;
            }
            else
            {
                result = VisitorGiftForPlayerUtility.PlayerWealthChanceFactor(map) * VisitorGiftForPlayerUtility.FactionRelationsChanceFactor(faction) * 0.75f;
            }
            return(result);
        }