/// <summary>
        /// If the top culture is different than the current culture, it will be changed here
        /// </summary>
        void applyCulture()
        {
            Settlement    settlement = Settlement.Find(settlementId);
            CultureObject topCulture = getTopCulture();

            if (settlement.Culture.StringId != topCulture.StringId)
            {
                ChangeCultureUtils.ChangeSettlementCulture(settlement, topCulture);
            }
        }
        /// <summary>
        /// Gets the influence strength from otherSettlement on thisSettlement
        /// </summary>
        /// <param name="otherSettlement">Influencer</param>
        /// <param name="thisSettlement">Influencee</param>
        /// <param name="firstTimeSetup">First time setup will ignore the Ratio calculation, because the InfluenceMap has not been fully populated</param>
        /// <returns></returns>
        int getInfluenceFromSettlement(Settlement otherSettlement, Settlement thisSettlement, bool firstTimeSetup)
        {
            var otherCulture = ChangeCultureUtils.GetOwnerCulture(otherSettlement);
            var thisCulture  = ChangeCultureUtils.GetOwnerCulture(thisSettlement);

            int influenceValue = BASE_INFLUENCE;

            if (otherSettlement.IsTown)
            {
                influenceValue *= 3;
            }
            if (otherSettlement.IsCastle)
            {
                influenceValue *= 2;
            }
            if (otherSettlement.IsVillage)
            {
                influenceValue *= 1;
            }

            // Self influence bonus
            if (otherSettlement.StringId == this.settlementId)
            {
                influenceValue *= 2;
            }

            // Homeland bonus only applied for self influence
            if (otherCulture.StringId == homelandCultureId && otherSettlement.StringId == thisSettlement.StringId)
            {
                influenceValue *= 2;
            }

            // For first time setup
            //if (firstTimeSetup && (otherSettlement.StringId == thisSettlement.StringId))
            //    influenceValue *= 5;

            // Scale the influence based on the influence ratios of the other settlement. Skip on first time setup.
            if (!firstTimeSetup)
            {
                influenceValue = (int)decimal.Round((decimal)influenceValue * ChangeCultureManager.Instance.InfluenceMap[otherSettlement.StringId].GetPercentOfTopCulture());
            }

            return(influenceValue);
        }
        /// <summary>
        /// Recalculate influence based on campaign circumstances and save it as "TargetInfluence"
        /// </summary>
        /// <param name="firstTimeSetup"></param>
        /// <returns></returns>
        public int RecalculateInfluencers(bool firstTimeSetup)
        {
            Settlement settlement = Settlement.Find(settlementId);

            if (settlement.Name.ToString() == "Syronea")
            {
                int u = 0;
            }

            // foreach nearby settlement, sum up the influence of each culture type
            List <Settlement> influencingSettlements = new List <Settlement>();

            // Geographically close settlements
            influencingSettlements.AddRange(Settlement.FindSettlementsAroundPosition(settlement.Position2D, Settings.Instance.SettlementInfluenceRange).Where(x => x.IsVillage || x.IsCastle || x.IsTown));

            if (Settings.Instance.TradeLinkedInfluence)
            {
                // Trade-linked settlements
                if (settlement.IsCastle || settlement.IsTown)
                {
                    influencingSettlements.AddRange(settlement.BoundVillages.Select(v => v.Settlement));
                }

                // Parent's Trade-linked settlements
                if (settlement.IsVillage)
                {
                    influencingSettlements.AddRange(Settlement.FindFirst(s => s.BoundVillages.Contains(settlement.Village)).BoundVillages.Select(v => v.Settlement));
                }
            }

            // calculate the influence caused by our neighbors
            int sum = 0;
            Dictionary <CultureObject, int> influencers = new Dictionary <CultureObject, int>();

            foreach (var otherSettlement in influencingSettlements)
            {
                int influence = getInfluenceFromSettlement(otherSettlement, settlement, firstTimeSetup);
                sum += influence;

                if (!influencers.ContainsKey(otherSettlement.Culture))
                {
                    influencers.Add(otherSettlement.Culture, influence);
                }
                else
                {
                    influencers[otherSettlement.Culture] += influence;
                }
            }

            // calculate the influence caused by our owners
            int ownerInfluence = BASE_INFLUENCE * Settings.Instance.OwnerInfluenceStrength;

            sum += ownerInfluence;

            if (ownerInfluence > 0)
            {
                var ownerCulture = ChangeCultureUtils.GetOwnerCulture(settlement);

                if (!influencers.ContainsKey(ownerCulture))
                {
                    influencers.Add(ownerCulture, ownerInfluence);
                }
                else
                {
                    influencers[ownerCulture] += ownerInfluence;
                }
            }

            // foreach influencing culture, calculate the percent of total influence
            bool didTargetsChange = false;

            foreach (var pair in influencers)
            {
                CultureObject culture = pair.Key;
                decimal       percent = (decimal)pair.Value / sum;

                if (!TargetInfluences.ContainsKey(culture.StringId))
                {
                    TargetInfluences.Add(culture.StringId, percent);
                    didTargetsChange = true;
                }
                else if (percent != TargetInfluences[culture.StringId])
                {
                    TargetInfluences[culture.StringId] = percent;
                    didTargetsChange = true;
                }
            }

            // clear out no longer influencing cultures
            for (int x = 0; x < TargetInfluences.Count; x++)//foreach (var pair in TargetInfluences)
            {
                if (!influencers.Select(c => c.Key.StringId).Contains(TargetInfluences.ElementAt(x).Key))
                {
                    TargetInfluences[TargetInfluences.ElementAt(x).Key] = 0m;
                }
            }

            if (didTargetsChange)
            {
                TargetInfluencesIDKey++;
            }

            return(sum);
        }