示例#1
0
        /// <summary>
        /// Secedes province to Taker. Also kills old province owner if it was last province
        /// </summary>
        public void secedeTo(Country taker, bool addModifier)
        {
            Country oldCountry = getCountry();

            //refuse pay back loans to old country bank
            foreach (var agent in getAllAgents())
            {
                if (agent.loans.isNotZero())
                {
                    agent.getBank().defaultLoaner(agent);
                }
                //take back deposits
                oldCountry.getBank().returnAllMoney(agent);
                agent.setBank(taker.getBank());
            }

            // transfer government owned factories
            allFactories.PerformAction(x => x.getOwner() == oldCountry, x => x.setOwner(taker));

            oldCountry.demobilize(x => x.getPopUnit().getProvince() == this);

            //kill country or move capital
            if (oldCountry.isOneProvince())
            {
                oldCountry.killCountry(taker);
            }
            else
            if (isCapital())
            {
                oldCountry.moveCapitalTo(oldCountry.getRandomOwnedProvince(x => x != this));
            }

            // add loyalty penalty for conquered province // temp
            foreach (var pop in allPopUnits)
            {
                if (pop.culture == taker.getCulture())
                {
                    pop.loyalty.add(Options.PopLoyaltyChangeOnAnnexStateCulture);
                }
                else
                {
                    pop.loyalty.subtract(Options.PopLoyaltyChangeOnAnnexNonStateCulture, false);
                }
                pop.loyalty.clamp100();
                Movement.leave(pop);
            }

            //transfer province
            if (oldCountry != null)
            {
                if (oldCountry.ownedProvinces != null)
                {
                    oldCountry.ownedProvinces.Remove(this);
                }
            }
            owner = taker;

            if (taker.ownedProvinces == null)
            {
                taker.ownedProvinces = new List <Province>();
            }
            taker.ownedProvinces.Add(this);

            taker.government.onReformEnacted(this);

            //graphic stuff
            color = taker.getColor().getAlmostSameColor();
            meshRenderer.material.color = this.getColorAccordingToMapMode();

            setBorderMaterials(false);
            if (addModifier)
            {
                if (modifiers.ContainsKey(Mod.recentlyConquered))
                {
                    modifiers[Mod.recentlyConquered].set(Game.date.getNewDate(20));
                }
                else
                {
                    modifiers.Add(Mod.recentlyConquered, Game.date.getNewDate(20));
                }
            }
        }
示例#2
0
        /// <summary>
        /// Secedes province to Taker. Also kills old province owner if it was last province
        /// Call it only from Country.TakeProvince()
        /// </summary>
        public void OnSecedeTo(Country taker, bool addModifier)
        {
            // rise event on day passed
            EventHandler <OwnerChangedEventArgs> handler = OwnerChanged;

            if (handler != null)
            {
                handler(this, new OwnerChangedEventArgs {
                    oldOwner = Country
                });
            }

            Country oldCountry = Country;

            // transfer government owned factories
            // don't do government property revoking for now
            allFactories.PerformAction(x => x.ownership.TransferAll(oldCountry, taker, false));
            oldCountry.demobilize(x => x.getPopUnit().Province == this);

            // add loyalty penalty for conquered province // temp
            foreach (var pop in allPopUnits)
            {
                if (pop.culture == taker.Culture)
                {
                    pop.loyalty.Add(Options.PopLoyaltyChangeOnAnnexStateCulture);
                }
                else
                {
                    pop.loyalty.Subtract(Options.PopLoyaltyChangeOnAnnexNonStateCulture, false);
                }
                pop.loyalty.clamp100();
                Movement.leave(pop);
            }

            //refuse pay back loans to old country bank
            foreach (var agent in AllAgents)
            {
                if (agent.loans.isNotZero())
                {
                    agent.Bank.OnLoanerRefusesToPay(agent);
                }
                //take back deposits
                oldCountry.Bank.ReturnAllDeposits(agent);
                //agent.setBank(taker.Bank);
                agent.OnProvinceOwnerChanged(taker);
            }
            //transfer province
            //oldCountry.ownedProvinces.Remove(this);
            //taker.ownedProvinces.Add(this);

            country = taker;
            if (addModifier)
            {
                if (modifiers.ContainsKey(TemporaryModifier.recentlyConquered))
                {
                    modifiers[TemporaryModifier.recentlyConquered].set(Date.Today.getNewDate(20));
                }
                else
                {
                    modifiers.Add(TemporaryModifier.recentlyConquered, Date.Today.getNewDate(20));
                }
            }
        }