Пример #1
0
        private void UpdateOnSettlementOwnerChanged(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            var lst = ButterLib.DistanceMatrix.DistanceMatrix.GetSettlementOwnersPairedList(SettlementDistanceMatrix !);

            if (lst is null)
            {
                return;
            }

            if ((newOwner.Clan is not null || oldOwner.Clan is not null) && newOwner.Clan != oldOwner.Clan)
            {
                var clans = Clan.All.Where(c => c.IsInitialized && c.Fiefs.Any()).ToList();

                if (oldOwner.Clan is not null)
                {
                    foreach (Clan clan in clans)
                    {
                        if (clan != oldOwner.Clan)
                        {
                            var distance = ButterLib.DistanceMatrix.DistanceMatrix.CalculateDistanceBetweenClans(oldOwner.Clan, clan, lst);
                            ClanDistanceMatrix !.SetDistance(oldOwner.Clan, clan, distance.GetValueOrDefault());
                        }
                    }
                }
                if (newOwner.Clan is not null)
                {
                    foreach (Clan clan in clans)
                    {
                        if (clan != newOwner.Clan)
                        {
                            var distance = ButterLib.DistanceMatrix.DistanceMatrix.CalculateDistanceBetweenClans(newOwner.Clan, clan, lst);
                            ClanDistanceMatrix !.SetDistance(newOwner.Clan, clan, distance.GetValueOrDefault());
                        }
                    }
                }
            }

            if ((newOwner.Clan?.Kingdom is not null || oldOwner.Clan?.Kingdom is not null) && newOwner.Clan?.Kingdom != oldOwner.Clan?.Kingdom)
            {
                KingdomDistanceMatrix = new DistanceMatrixImplementation <Kingdom>();
            }
        }
Пример #2
0
 private void InitializeOnLoad(CampaignGameStarter gameStarterObject)
 {
     SettlementDistanceMatrix = new DistanceMatrixImplementation <Settlement>();
     ClanDistanceMatrix       = new DistanceMatrixImplementation <Clan>();
     KingdomDistanceMatrix    = new DistanceMatrixImplementation <Kingdom>();
 }