Beispiel #1
0
 private static void NoblePatch(BannerInvestigationQuestBehavior __instance)
 {
     if (CSCharCreationOption.CSGameOption == 1)
     {
         __instance.GetType().GetField("_allNoblesDead", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, true);
     }
     if (CSCharCreationOption.CSGameOption == 2)
     {
         CampaignEvents.RemoveListeners(__instance);
     }
 }
Beispiel #2
0
 private static bool Prefix(MainStoryLine __instance, bool isSkipped)
 {
     __instance.TutorialPhase.GetType().GetMethod("CompleteTutorial", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance.TutorialPhase, new object[] { isSkipped });
     CSOnStoryModeEnded();
     __instance.GetType().GetProperty("FirstPhase").SetValue(__instance, new FirstPhase());
     //Combining multiple cleanup/complete logics that do not get called if you dont leave tutorial manually.
     CampaignEvents.RemoveListeners(Campaign.Current.GetCampaignBehavior <TutorialPhaseCampaignBehavior>());
     StoryModeEvents.RemoveListeners(Campaign.Current.GetCampaignBehavior <TutorialPhaseCampaignBehavior>());
     //if(StoryMode.StoryModeObjects.StoryModeHeroes. != null ){
     //StoryMode.StoryMode.Current.MainStoryLine.Brother.ChangeState(Hero.CharacterStates.Disabled);
     //}
     return(false);
 }
Beispiel #3
0
        private void OnHourlyTick()
        {
            foreach (Hero hero in Hero.All)
            {
                if (!hero.IsTemplate && hero.IsAlive &&
                    hero.Mother != null && hero.Father != null &&
                    !hero.CharacterObject.IsOriginalCharacter)
                {
                    FixAdoptBastard(hero);
                    FixBastardOccupation(hero);
                }
            }

            CampaignEvents.RemoveListeners(this);
        }
Beispiel #4
0
        private TaskStatus NHLBehavior <AddType, RemoveType>(Campaign campaign, TaskMode mode)
            where RemoveType : CampaignBehaviorBase
            where AddType : CampaignBehaviorBase, new()
        {
            CampaignBehaviorManager cbm = (CampaignBehaviorManager)campaign.CampaignBehaviorManager;

            if (mode != TaskMode.Add)
            {
                var cgb = campaign.GetCampaignBehavior <RemoveType>();
                CampaignEvents.RemoveListeners(cgb);
                cbm.RemoveBehavior <RemoveType>();
            }
            if (mode != TaskMode.Remove)
            {
                cbm.AddBehavior(new AddType());
            }
            return(TaskStatus.Completed);
        }
 public void OnClose()
 {
     Events.RemoveListeners(this);
     CampaignEvents.RemoveListeners(this);
 }
        private void OnChangeClanLeader(float dt)
        {
            MobileParty leaderParty    = leader.PartyBelongedTo;
            MobileParty newLeaderParty = newLeader.PartyBelongedTo;

            Utils.Print($"[OnChangeClanLeader] current leader {leader.Name} new leader {newLeader.Name}");

            if (leader == null || newLeader == null || leaderParty == null || newLeaderParty == null)
            {
                return;
            }

            if (newLeader.GovernorOf != null)
            {
                ChangeGovernorAction.ApplyByGiveUpCurrent(newLeader);
            }
            if (leader.GovernorOf != null)
            {
                ChangeGovernorAction.ApplyByGiveUpCurrent(leader);
            }

            string evt;

            while ((evt = newLeader.GetHeroOccupiedEvents().FirstOrDefault()) != default)
            {
                newLeader.RemoveEventFromOccupiedHero(evt);
            }
            while ((evt = leader.GetHeroOccupiedEvents().FirstOrDefault()) != default)
            {
                leader.RemoveEventFromOccupiedHero(evt);
            }

            GiveGoldAction.ApplyBetweenCharacters(leader, newLeader, leader.Gold, true);

            leader.Clan.SetLeader(newLeader);

            Settlement currentSettlement = newLeaderParty.CurrentSettlement;

            ChangePlayerCharacterAction.Apply(newLeader);

            if (newLeaderParty != leaderParty)
            {
                if (newLeaderParty.CurrentSettlement == null)
                {
                    EnterSettlementAction.ApplyForParty(newLeaderParty, currentSettlement);
                }

                foreach (var troop in leaderParty.MemberRoster.GetTroopRoster())
                {
                    if (troop.Character == leader.CharacterObject)
                    {
                        continue;
                    }

                    leaderParty.MemberRoster.AddToCounts(troop.Character, -troop.Number);
                    newLeaderParty.MemberRoster.AddToCounts(troop.Character, troop.Number);
                }

                foreach (var troop in leaderParty.PrisonRoster.GetTroopRoster())
                {
                    if (troop.Character == leader.CharacterObject)
                    {
                        continue;
                    }

                    leaderParty.PrisonRoster.AddToCounts(troop.Character, -troop.Number);
                    newLeaderParty.PrisonRoster.AddToCounts(troop.Character, troop.Number);
                }

                ItemRosterElement i;
                while (leaderParty.ItemRoster.Count() > 0)
                {
                    i = leaderParty.ItemRoster.First();
                    leaderParty.ItemRoster.AddToCounts(i.EquipmentElement, -i.Amount);
                    newLeaderParty.ItemRoster.AddToCounts(i.EquipmentElement, i.Amount);
                }

                leaderParty.RemoveParty();
                AddHeroToPartyAction.Apply(leader, newLeaderParty);
            }
            else
            {
                leaderParty.Party.Owner = newLeader;
                var partyList = leaderParty.Party.MemberRoster;
                partyList.RemoveTroop(newLeader.CharacterObject);
                partyList.AddToCounts(newLeader.CharacterObject, 1, true);
                var newPartyName = new TextObject("{=shL0WElC}{TROOP.NAME}'s Party");
                newPartyName.SetCharacterProperties("TROOP", newLeader.CharacterObject);
                leaderParty.SetCustomName(newPartyName);
            }

            leader.HasMet = true;

            newLeader.Clan.Influence = Math.Max(0, newLeader.Clan.Influence - 100);

            HeroFixHelper.FixHeroStats(newLeader);
            HeroFixHelper.FixEquipment(newLeader);

            newLeaderParty.Party.Visuals.SetMapIconAsDirty();
            CampaignEventDispatcher.Instance.OnArmyOverlaySetDirty();

            newLeader = null;
            leader    = null;
            CampaignEvents.RemoveListeners(this);
            Utils.Print($"[OnChangeClanLeader] changed over");
        }
Beispiel #7
0
        private void OnChangeClanLeader(float dt)
        {
            MobileParty leaderParty    = leader.PartyBelongedTo;
            MobileParty newLeaderParty = newLeader.PartyBelongedTo;

            if (leader == null || newLeader == null || leaderParty == null || newLeaderParty == null || leaderParty == newLeaderParty)
            {
                return;
            }

            if (newLeader.GovernorOf != null)
            {
                ChangeGovernorAction.ApplyByGiveUpCurrent(newLeader);
            }
            if (leader.GovernorOf != null)
            {
                ChangeGovernorAction.ApplyByGiveUpCurrent(leader);
            }

            var qm = Campaign.Current.QuestManager;

            if (qm != null)
            {
                QuestBase q;
                while ((q = qm.Quests.FirstOrDefault(s => !s.IsSpecialQuest)) != null)
                {
                    q.CompleteQuestWithFail();
                }
            }

            string evt;

            while ((evt = newLeader.GetHeroOccupiedEvents().FirstOrDefault()) != default)
            {
                newLeader.RemoveEventFromOccupiedHero(evt);
            }
            while ((evt = leader.GetHeroOccupiedEvents().FirstOrDefault()) != default)
            {
                leader.RemoveEventFromOccupiedHero(evt);
            }

            GiveGoldAction.ApplyBetweenCharacters(leader, newLeader, leader.Gold, true);

            leader.Clan.SetLeader(newLeader);
            ChangePlayerCharacterAction.Apply(newLeader);

            TroopRosterElement t;

            while (leaderParty.MemberRoster.Count(x => x.Character != leader.CharacterObject) > 0)
            {
                t = leaderParty.MemberRoster.First(x => x.Character != leader.CharacterObject);
                leaderParty.MemberRoster.AddToCounts(t.Character, -t.Number);
                newLeaderParty.MemberRoster.AddToCounts(t.Character, t.Number);
            }

            while (leaderParty.PrisonRoster.Count() > 0)
            {
                t = leaderParty.PrisonRoster.First();
                leaderParty.PrisonRoster.AddToCounts(t.Character, -t.Number);
                newLeaderParty.PrisonRoster.AddToCounts(t.Character, t.Number);
            }

            ItemRosterElement i;

            while (leaderParty.ItemRoster.Count() > 0)
            {
                i = leaderParty.ItemRoster.First();
                leaderParty.ItemRoster.AddToCounts(i.EquipmentElement, -i.Amount);
                newLeaderParty.ItemRoster.AddToCounts(i.EquipmentElement, i.Amount);
            }

            leaderParty.RemoveParty();
            AddHeroToPartyAction.Apply(leader, newLeaderParty);

            newLeader.Clan.Influence = Math.Max(0, newLeader.Clan.Influence - 100);

            HeroFixHelper.FixHeroStats(newLeader);
            HeroFixHelper.FixEquipment(newLeader);

            newLeader = null;
            leader    = null;
            CampaignEvents.RemoveListeners(this);
        }
Beispiel #8
0
 public override void OnGameInitializationFinished(Game game)
 {
     base.OnGameInitializationFinished(game);
     CampaignEvents.RemoveListeners((object)Campaign.Current.GetCampaignBehavior <DesertionCampaignBehavior>());
 }