Exemplo n.º 1
0
 private void DailyMakeSureNoKingdom(Clan c)
 {
     if (c == null || DiplomacyUtils.GetHardCodedExceptionClans().Contains(c.StringId))
     {
         return;
     }
     try
     {
         if (dataManager == null)
         {
             GetData();
         }
         if (dataManager.Data.ContainsKey(c.StringId))
         {
             if (dataManager.Data[c.StringId].ForceNoKingdom && c.Kingdom != null)
             {
                 ChangeKingdomAction.ApplyByLeaveKingdom(c, false);
                 ModDebug.ShowMessage(c.StringId + " has forcefully been removed from parent kingdom", DebugMessageType.Diplomacy);
             }
         }
     }
     catch (Exception e)
     {
         ErrorHandler.HandleException(e, "daily make sure no kingdom process");
     }
 }
Exemplo n.º 2
0
        private void DailyClanBehaviour(Clan c)
        {
            if (c == null || DiplomacyUtils.GetHardCodedExceptionClans().Contains(c.StringId))
            {
                return;
            }
            try
            {
                if (dataManager == null)
                {
                    GetData();
                }
                if (dataManager.Data.ContainsKey(c.StringId) && dataManager.Data[c.StringId].ForcedWarPeaceDataInstance != null)
                {
                    var forcedWarPeaceInstance = dataManager.Data[c.StringId].ForcedWarPeaceDataInstance;
                    foreach (Clan declared in Clan.All)
                    {
                        if (declared == null || DiplomacyUtils.GetHardCodedExceptionClans().Contains(declared.StringId) || declared == c ||
                            (declared.Kingdom == c.Kingdom && c.Kingdom != null))
                        {
                            continue;
                        }
                        if (forcedWarPeaceInstance.atWarClans.Contains(declared))
                        {
                            if (declared == null)
                            {
                                continue;
                            }
                            if (declared.Kingdom != null)
                            {//we deal with kingdom
                                if (!forcedWarPeaceInstance.exceptionKingdoms.Contains(declared.Kingdom))
                                {
                                    if (!FactionManager.IsAtWarAgainstFaction(c, declared.Kingdom))
                                    {
                                        DiplomacyUtils.DeclareWar(declared.Kingdom, c);
                                        DiplomacyUtils.ApplyExtremeHatred(declared.Kingdom, c);
                                    }
                                }
                            }
                            else
                            {
                                if (!FactionManager.IsAtWarAgainstFaction(c, declared))
                                {
                                    DiplomacyUtils.DeclareWar(declared, c);
                                    DiplomacyUtils.ApplyExtremeHatred(declared, c);
                                }
                            }
                        }
                        else
                        {
                            //what if clan left kingdom, and it was in but ?
                            if (declared.Kingdom == null && !FactionManager.IsNeutralWithFaction(c, declared))
                            {
                                DiplomacyUtils.SetNeutral(c, declared);
                            }
                        }
                    }

                    foreach (var k in forcedWarPeaceInstance.exceptionKingdoms)
                    {
                        if (k == null)
                        {
                            return;
                        }
                        if (!FactionManager.IsNeutralWithFaction(c, k))
                        {
                            DiplomacyUtils.SetNeutral(c, k);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorHandler.HandleException(e, " daily clan behaviour processing of ForcedWarPeaceBehaviour.cs ");
            }
        }