Exemplo n.º 1
0
        private void Spawn(Vec2 position, TroopRoster party, TroopRoster prisoners)
        {
            var partyClan = GetMostPrevalent(party) ?? Clan.BanditFactions.First();

            MobileParty = ModBanditMilitiaPartyComponent.CreateBanditParty(partyClan);
            MobileParty.InitializeMobilePartyAroundPosition(party, prisoners, position, 0);
            PartyMilitiaMap.Add(MobileParty, this);
            PartyImageMap.Add(MobileParty, new ImageIdentifierVM(Banner));
            var leaderHero = MobileParty.MemberRoster.GetTroopRoster().ToListQ()[0].Character.HeroObject;

            MobileParty.PartyComponent.ChangePartyLeader(leaderHero);
            Hero      = MobileParty.LeaderHero;
            Hero.Gold = Convert.ToInt32(MobileParty.Party.TotalStrength * Globals.GoldMap[Globals.Settings.GoldReward.SelectedValue]);
            if (MobileParty.ActualClan.Leader is null)
            {
                MobileParty.ActualClan.SetLeader(Hero);
            }
            if (MobileParty.MemberRoster.GetTroopRoster().Any(t => t.Character.IsMounted))
            {
                var mount = Mounts.GetRandomElement();
                Hero.BattleEquipment[10] = new EquipmentElement(mount);
                if (mount.HorseComponent.Monster.MonsterUsage == "camel")
                {
                    Hero.BattleEquipment[11] = new EquipmentElement(Saddles.Where(saddle =>
                                                                                  saddle.Name.ToString().ToLower().Contains("camel")).ToList().GetRandomElement());
                }
                else
                {
                    Hero.BattleEquipment[11] = new EquipmentElement(Saddles.Where(saddle =>
                                                                                  !saddle.Name.ToString().ToLower().Contains("camel")).ToList().GetRandomElement());
                }
            }

            var getLocalizedText = AccessTools.Method(typeof(MBTextManager), "GetLocalizedText");

            Name = (string)getLocalizedText.Invoke(null, new object[] { $"{Possess(Hero.FirstName.ToString())} Bandit Militia" });
            MobileParty.SetCustomName(new TextObject(Name));
            MobileParty.LeaderHero.StringId    += "Bandit_Militia";
            MobileParty.ShouldJoinPlayerBattles = true;
            var tracker = Globals.MobilePartyTrackerVM?.Trackers?.FirstOrDefault(t => t.TrackedParty == MobileParty);

            if (Globals.Settings.Trackers &&
                tracker is null &&
                MobileParty.MemberRoster.TotalManCount >= Globals.Settings.TrackedSizeMinimum)
            {
                tracker = new MobilePartyTrackItemVM(MobileParty, MapScreen.Instance.MapCamera, null);
                Globals.MobilePartyTrackerVM?.Trackers?.Add(tracker);
            }