public DetachmentManager(Team team)
 {
     this._detachments         = new List <IDetachment>();
     this.Detachments          = this._detachments.GetReadOnlyList <IDetachment>();
     this.team                 = team;
     team.OnFormationsChanged += new Action <Team, Formation>(this.Team_OnFormationsChanged);
 }
 private BannerManager()
 {
     this._bannerIconGroups    = new List <BannerIconGroup>();
     this._colorPalette        = new Dictionary <int, BannerColor>();
     this.BannerIconGroups     = this._bannerIconGroups.GetReadOnlyList <BannerIconGroup>();
     this.ReadOnlyColorPalette = this._colorPalette.GetReadOnlyDictionary <int, BannerColor>();
 }
Esempio n. 3
0
        public static void RemoveExSpouses(Hero hero, bool completelyRemove = false)
        {
            FieldInfo             _exSpouses     = AccessTools.Field(typeof(Hero), "_exSpouses");
            List <Hero>           _exSpousesList = (List <Hero>)_exSpouses.GetValue(hero);
            FieldInfo             ExSpouses      = AccessTools.Field(typeof(Hero), "ExSpouses");
            MBReadOnlyList <Hero> ExSpousesReadOnlyList;

            if (completelyRemove)
            {
                // Remove exspouse completely from list
                _exSpousesList = _exSpousesList.ToList();
                List <Hero> exSpouses = _exSpousesList.Where(exSpouse => exSpouse.IsAlive).ToList();
                foreach (Hero exSpouse in exSpouses)
                {
                    _exSpousesList.Remove(exSpouse);
                }
            }
            else
            {
                // Standard remove duplicates spouse
                // Get exspouse list without duplicates
                _exSpousesList = _exSpousesList.Distinct().ToList();
                // If exspouse is already a spouse, then remove it
                if (_exSpousesList.Contains(hero.Spouse))
                {
                    _exSpousesList.Remove(hero.Spouse);
                }
            }
            ExSpousesReadOnlyList = new MBReadOnlyList <Hero>(_exSpousesList);
            _exSpouses.SetValue(hero, _exSpousesList);
            ExSpouses.SetValue(hero, ExSpousesReadOnlyList);
        }
Esempio n. 4
0
 public SiegeWeaponController(Mission mission, Team team)
 {
     this._mission         = mission;
     this._team            = team;
     this._selectedWeapons = new List <SiegeWeapon>();
     this.SelectedWeapons  = new MBReadOnlyList <SiegeWeapon>(this._selectedWeapons);
     this.InitializeWeaponsForDeployment();
 }
        protected override void OnWrite()
        {
            GameNetworkMessage.WriteNetworkPeerReferenceToPacket(this.Peer);
            GameNetworkMessage.WriteIntToPacket((int)this.VotedType, CompressionMission.TeamSideCompressionInfo);
            MBReadOnlyList <BasicCultureObject> objectTypeList = MBObjectManager.Instance.GetObjectTypeList <BasicCultureObject>();

            GameNetworkMessage.WriteIntToPacket(this.VotedCulture == null ? -1 : objectTypeList.IndexOf(this.VotedCulture), CompressionBasic.CultureIndexCompressionInfo);
        }
        // Token: 0x06000004 RID: 4 RVA: 0x0000215C File Offset: 0x0000035C
        public override void OnGameInitializationFinished(Game game)
        {
            base.OnGameInitializationFinished(game);
            bool flag = !(game.GameType is Campaign);

            if (!flag)
            {
                Campaign campaign = game.GameType as Campaign;
                bool     flag2    = campaign != null;
                if (flag2)
                {
                    bool flag3 = MBObjectManager.Instance.GetObjectTypeList <PartyTemplateObject>() != null;
                    if (flag3)
                    {
                        MBReadOnlyList <PartyTemplateObject> partyTemplateList = MBObjectManager.Instance.GetObjectTypeList <PartyTemplateObject>();
                        for (int index = 0; index < partyTemplateList.Count; index++)
                        {
                            PartyTemplateObject pt = partyTemplateList[index];
                            new PartyTemplateSizes(pt);
                        }
                    }
                    bool bPrintTroopLimits = ModSettings.Instance.bPrintTroopLimits;
                    if (bPrintTroopLimits)
                    {
                        bool flag4 = MBObjectManager.Instance.GetObjectTypeList <PartyTemplateObject>() != null;
                        if (flag4)
                        {
                            MBReadOnlyList <PartyTemplateObject> partyTemplateList2 = MBObjectManager.Instance.GetObjectTypeList <PartyTemplateObject>();
                            Logging.lm("-------------------------------------------");
                            Logging.lm("Printing Party Template Troop Limits ");
                            for (int index2 = 0; index2 < partyTemplateList2.Count; index2++)
                            {
                                Logging.lm("");
                                PartyTemplateObject pt2 = partyTemplateList2[index2];
                                Logging.lm("Party String Id: " + pt2.StringId.ToString());
                                foreach (PartyTemplateStack ps in pt2.Stacks)
                                {
                                    string[] array = new string[6];
                                    array[0] = "Character: ";
                                    array[1] = ps.Character.StringId.ToString();
                                    array[2] = " Min: ";
                                    int num  = 3;
                                    int num2 = ps.MinValue;
                                    array[num] = num2.ToString();
                                    array[4]   = " Max: ";
                                    int num3 = 5;
                                    num2        = ps.MaxValue;
                                    array[num3] = num2.ToString();
                                    Logging.lm(string.Concat(array));
                                }
                                Logging.lm("");
                            }
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public static void SetupKingdomParties(MBReadOnlyList <MobileParty> mobileParties)
        {
            if (mobileParties == null)
            {
                return;
            }

            Dictionary <string, MobileParty> existingParties = new Dictionary <string, MobileParty>();
            List <MobileParty> tempList = mobileParties.ToList();

            tempList.ForEach(p =>
            {
                // Campaign.Current.MobileParties can have some invalid entries, make sure only valid MobileParties get added for processing
                if (p.Leader?.Name != null && !existingParties.ContainsKey(p.Leader.Name.ToString()))
                {
                    existingParties.Add(p.Leader.Name.ToString(), p);
                }
            });

            if (existingParties.Count > 0 && KingdomConfigs.Any())
            {
                KingdomConfigs.ForEach(kC =>
                {
                    Dictionary <string, KingdomLocation> lordLocations = LoadLocationsForKingdomConfiguration(kC);
                    if (!lordLocations.IsEmpty() && lordLocations.Count > 0)
                    {
                        string[] names = new string[lordLocations.Count];
                        lordLocations.Keys.CopyTo(names, 0);
                        List <string> lordsToAdd = names.ToList();

                        lordsToAdd.ForEach(lord =>
                        {
                            if (existingParties.ContainsKey(lord))
                            {
                                MobileParty p = existingParties[lord];
                                if (p?.Leader?.Name != null)
                                {
                                    KingdomLocation location    = lordLocations[lord];
                                    Settlement targetSettlement = Settlement.Find(location.SettlementName);

                                    // Here we assign ownership of the targetSettlement to the KingdomLeaderId defined in config.xml
                                    if (p.Leader.StringId.Equals(kC.kingdomLeaderId))
                                    {
                                        TaleWorlds.CampaignSystem.Actions.ChangeOwnerOfSettlementAction.ApplyByDefault(p.LeaderHero, targetSettlement);
                                    }
                                    // Move the party's position, use the XOffset and YOffset from the relevant locations.xml
                                    p.Position2D = new Vec2(targetSettlement.Position2D.X + location.XOffset, targetSettlement.Position2D.Y + location.YOffset);
                                    // Make them patrol around their location
                                    p.SetMovePatrolAroundSettlement(targetSettlement);
                                }
                            }
                        });
                    }
                });
            }
        }
 public TeamAISiegeAttacker(
     Mission currentMission,
     Team currentTeam,
     float thinkTimerTime,
     float applyTimerTime)
     : base(currentMission, currentTeam, thinkTimerTime, applyTimerTime)
 {
     this._archerPositions = currentMission.Scene.FindEntitiesWithTag("archer_position_attacker").Select <GameEntity, ArcherPosition>((Func <GameEntity, ArcherPosition>)(ap => new ArcherPosition(ap, TeamAISiegeComponent.QuerySystem))).ToList <ArcherPosition>();
     this.ArcherPositions  = this._archerPositions.GetReadOnlyList <ArcherPosition>();
     Mission.Current.GetMissionBehaviour <SiegeMissionController>().PlayerDeploymentFinish += new CampaignSiegeMissionEvent(this.OnDeploymentFinished);
 }
Esempio n. 9
0
 public override void OnClearScene()
 {
     this.AllCapturePoints = new MBReadOnlyList <FlagCapturePoint>(Mission.Current.MissionObjects.FindAllWithType <FlagCapturePoint>().ToListQ <FlagCapturePoint>());
     foreach (FlagCapturePoint allCapturePoint in this.AllCapturePoints)
     {
         allCapturePoint.ResetPointAsServer(4284111450U, uint.MaxValue);
         this._capturePointOwners[allCapturePoint.FlagIndex] = (Team)null;
     }
     this._morale = 0.0f;
     this._nextTimeToCheckForMorales      = float.MinValue;
     this._nextTimeToCheckForPointRemoval = float.MinValue;
     this._flagRemovalOccured             = false;
 }
Esempio n. 10
0
 public override void OnBehaviourInitialize()
 {
     base.OnBehaviourInitialize();
     this._gameModeFlagDominationClient = Mission.Current.GetMissionBehaviour <MissionMultiplayerGameModeFlagDominationClient>();
     this._morale             = 0.0f;
     this._capturePointOwners = new Team[3];
     this.AllCapturePoints    = new MBReadOnlyList <FlagCapturePoint>(Mission.Current.MissionObjects.FindAllWithType <FlagCapturePoint>().ToListQ <FlagCapturePoint>());
     foreach (FlagCapturePoint allCapturePoint in this.AllCapturePoints)
     {
         allCapturePoint.SetTeamColorsWithAllSynched(4284111450U, uint.MaxValue);
         this._capturePointOwners[allCapturePoint.FlagIndex] = (Team)null;
     }
 }
Esempio n. 11
0
 private static void FindSides(CampaignWar campaignWar, Kingdom kingdom, out MBReadOnlyList <IFaction> kingdomSide, out MBReadOnlyList <IFaction> oppositionSide)
 {
     if (campaignWar.Side1.Contains(kingdom))
     {
         kingdomSide    = campaignWar.Side1;
         oppositionSide = campaignWar.Side2;
     }
     else
     {
         kingdomSide    = campaignWar.Side2;
         oppositionSide = campaignWar.Side1;
     }
 }
        private static bool MockedGetSettlementAll(ref MBReadOnlyList <Settlement> __result)
        {
            var settlement = (Settlement)FormatterServices.GetUninitializedObject(typeof(Settlement));
            var village    = (Village)FormatterServices.GetSafeUninitializedObject(typeof(Village));

            SymbolExtensions2.GetPropertyInfo((Settlement s) => s.Id).SetValue(settlement, new MBGUID(1));
            SymbolExtensions2.GetPropertyInfo((Settlement s) => s.IsInitialized).SetValue(settlement, true);
            SymbolExtensions2.GetFieldInfo((Settlement s) => s.Village).SetValue(settlement, village);

            __result = new MBReadOnlyList <Settlement>(new List <Settlement> {
                settlement
            });
            return(false);
        }
        protected override bool OnRead()
        {
            bool bufferReadValid = true;

            this.Peer      = GameNetworkMessage.ReadNetworkPeerReferenceFromPacket(ref bufferReadValid);
            this.VotedType = (CultureVoteTypes)GameNetworkMessage.ReadIntFromPacket(CompressionMission.TeamSideCompressionInfo, ref bufferReadValid);
            int index = GameNetworkMessage.ReadIntFromPacket(CompressionBasic.CultureIndexCompressionInfo, ref bufferReadValid);

            if (bufferReadValid)
            {
                MBReadOnlyList <BasicCultureObject> objectTypeList = MBObjectManager.Instance.GetObjectTypeList <BasicCultureObject>();
                this.VotedCulture = index < 0 ? (BasicCultureObject)null : objectTypeList[index];
            }
            return(bufferReadValid);
        }
Esempio n. 14
0
        private void AddScaHeroesToWorld(MBReadOnlyList <MobileParty> mobileParties)
        {
            if (mobileParties == null)
            {
                InformationManager.DisplayMessage(new InformationMessage("SCA3: mobileParties was null! Abandoning SCA3 party setup...", Color.FromUint(4278255360U)));
                return;
            }

            var parties = mobileParties.ToList();

            InformationManager.DisplayMessage(
                new InformationMessage($"SCA3: Mobile parties has {parties.Count } parties in it. Filtering for SCA heroes...", Color.FromUint(4278255360U)));

            foreach (var scaHero in _heroLocations)
            {
                InformationManager.DisplayMessage(
                    new InformationMessage($"SCA3: Looping through SCA hero list. We see { scaHero.HeroName}.", Color.FromUint(4278255360U)));

                try
                {
                    var party = parties
                                .Where(p => p.Leader?.Name != null && p.Leader.Name.ToString() == scaHero.HeroName)
                                .SingleOrDefault();

                    if (party == null)
                    {
                        InformationManager.DisplayMessage(
                            new InformationMessage($"SCA3: party lead by SCA hero '{scaHero.HeroName} ({scaHero.HeroId})' not found in mobileParties! Skipping hero.", Color.FromUint(4278255360U)));
                        continue;
                    }

                    InformationManager.DisplayMessage(
                        new InformationMessage($"SCA3: Found party lead by SCA hero {scaHero.HeroName}! (It is {party.Id})", Color.FromUint(4278255360U)));

                    var settlement = Settlement.Find(scaHero.SettlementId);
                    ChangeOwnerOfSettlementAction.ApplyByDefault(party.LeaderHero, settlement);
                    party.Position2D = new Vec2(
                        settlement.Position2D.X + scaHero.XOffset,
                        settlement.Position2D.Y + scaHero.YOffset);
                    party.SetMovePatrolAroundSettlement(settlement);
                }
                catch (Exception ex)
                {
                    InformationManager.DisplayMessage(
                        new InformationMessage($"SCA3: Error looping through hero locations on hero: {scaHero.HeroName}! Message: {ex.Message}"));
                }
            }
        }
        public override void OnAgentRemoved(
            Agent affectedAgent,
            Agent affectorAgent,
            AgentState agentState,
            KillingBlow killingBlow)
        {
            if (affectorAgent == null || affectedAgent == null || (!affectorAgent.IsHuman || !affectedAgent.IsHuman) || agentState != AgentState.Killed && agentState != AgentState.Unconscious)
            {
                return;
            }
            bool flag1 = affectorAgent != null && affectorAgent.Team.IsPlayerTeam;
            bool flag2 = affectorAgent != null && affectorAgent.IsMainAgent;

            HighlightsController.Highlight highlight = new HighlightsController.Highlight();
            highlight.Start = Mission.Current.Time;
            highlight.End   = Mission.Current.Time;
            bool flag3 = false;

            if (flag2 | flag1 && (killingBlow.WeaponRecordWeaponFlags.HasAllFlags <WeaponFlags>(WeaponFlags.Burning) || killingBlow.WeaponRecordWeaponFlags.HasAllFlags <WeaponFlags>(WeaponFlags.AffectsArea)))
            {
                highlight.HighlightType = this._highlightsController.GetHighlightTypeWithId("hlid_wall_break_kill");
                flag3 = true;
            }
            MBReadOnlyList <Agent> teamAgents1 = affectedAgent.Team?.TeamAgents;
            bool flag4 = teamAgents1 == null || teamAgents1.Any <Agent>((Func <Agent, bool>)(agent => agent.State != AgentState.Killed && agent.State != AgentState.Unconscious));

            if (!flag4 && flag2 | flag1)
            {
                highlight.HighlightType = this._highlightsController.GetHighlightTypeWithId("hlid_kill_last_enemy_on_battlefield");
                flag3 = true;
            }
            if (flag2)
            {
                MBReadOnlyList <Agent> teamAgents2 = affectorAgent.Team?.TeamAgents;
                if ((teamAgents2 == null ? 1 : (teamAgents2.Any <Agent>((Func <Agent, bool>)(agent => !agent.IsMainAgent && agent.State != AgentState.Killed && agent.State != AgentState.Unconscious)) ? 1 : 0)) == 0 && !flag4)
                {
                    highlight.HighlightType = this._highlightsController.GetHighlightTypeWithId("hlid_win_battle_as_last_man_standing");
                    flag3 = true;
                }
            }
            if (!flag3)
            {
                return;
            }
            this._highlightsController.SaveHighlight(highlight, affectedAgent.Position);
        }
Esempio n. 16
0
        public static void InitializeVartsDto()
        {
            _all = new HashSet <VartsDto>();
            foreach (var villageDto in VillageDto.AllVillageDto)
            {
                _all.Add(villageDto);
            }

            foreach (var townDto in TownDto.AllTownDto)
            {
                _all.Add(townDto);
            }

            var list = _all.ToList();

            list = list.OrderBy(o => o.Name.ToLower().ToString()).ToList();
            All  = new MBReadOnlyList <VartsDto>(list);
        }
Esempio n. 17
0
        public static void DisplayChargeToFormationMessage(MBReadOnlyList <Formation> selectedFormations,
                                                           Formation targetFormation)
        {
            // From MissionOrderVM.OnOrder
            var formationNames = new List <TextObject>();

            foreach (var formation in selectedFormations)
            {
                formationNames.Add(GameTexts.FindText("str_formation_class_string", formation.PrimaryClass.GetName()));
            }

            if (!formationNames.IsEmpty())
            {
                var message = new TextObject("{=ApD0xQXT}{STR1}: {STR2}");
                message.SetTextVariable("STR1", GameTexts.MergeTextObjectsWithComma(formationNames, false));
                message.SetTextVariable("STR2",
                                        GameTexts.FindText("str_formation_ai_sergeant_instruction_behavior_text",
                                                           nameof(BehaviorTacticalCharge))
                                        .SetTextVariable("TARGET_FORMATION", GameTexts.FindText("str_troop_group_name", ((int)targetFormation.PrimaryClass).ToString())));
                MissionSharedLibrary.Utilities.Utility.DisplayMessage(message.ToString());
            }
        }
Esempio n. 18
0
        public string Export(Hero hero)
        {
            Helper.Log("Export " + hero.Name);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("# BaseHitpoint is character's max HP before perk bonus added.");
            stringBuilder.AppendLine("# IMPORTANT! If you ever change BaseHitpoint, you shouldn't delete this file or character BaseHitPoint will be reverted to 100 (Bannerlord default)");
            stringBuilder.AddItem("BaseHitPoint", 100);
            stringBuilder.AddItem("CurrentHitPoint", hero.HitPoints);
            stringBuilder.AddItem("Gold", hero.Gold);
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("# Appearances");
            stringBuilder.AddItem("BodyProperties", Helper.HeroBodyPropertiesToString(hero));
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("# Attributes");
            for (int i = 0; i < 6; i++)
            {
                stringBuilder.AddItem(Enum.GetName(typeof(CharacterAttributesEnum), i), hero.GetAttributeValue((CharacterAttributesEnum)i));
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("# Skills");
            MBReadOnlyList <SkillObject> skillList = Game.Current.SkillList;

            for (int j = 0; j < skillList.Count; j++)
            {
                SkillObject skillObject = skillList[j];
                stringBuilder.AddItem(skillObject.StringId, hero.GetSkillValue(skillObject));
                stringBuilder.AddItem(skillObject.StringId + ".focus", hero.HeroDeveloper.GetFocus(skillObject));
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("# Perks (set value to 1 to learn)");
            foreach (PerkObject perkObject in PerkObject.All)
            {
                stringBuilder.AddItem(perkObject.StringId, hero.GetPerkValue(perkObject) ? 1 : 0);
            }
            Helper.WriteAllText(Helper.GetFilename(hero), stringBuilder.ToString());
            return(null);
        }
Esempio n. 19
0
 public static void RemoveRepeatExspouses(Hero hero, Hero target)
 {
     if (Hero.MainHero.ExSpouses.Count > 0)
     {
         FieldInfo fieldInfo  = hero.GetType().GetField("_exSpouses", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
         FieldInfo fieldInfo2 = hero.GetType().GetField("ExSpouses", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
         if (null == fieldInfo || null == fieldInfo2)
         {
             return;
         }
         List <Hero>           heroes  = (List <Hero>)fieldInfo.GetValue(hero);
         MBReadOnlyList <Hero> heroes2 = (MBReadOnlyList <Hero>)fieldInfo2.GetValue(hero);
         //heroes.D
         heroes = heroes.Distinct(new DistinctSpouse <Hero>()).ToList();
         if (heroes.Contains(target))
         {
             heroes.Remove(target);
         }
         fieldInfo.SetValue(hero, heroes);
         heroes2 = new MBReadOnlyList <Hero>(heroes);
         fieldInfo2.SetValue(hero, heroes2);
     }
 }
Esempio n. 20
0
        public static int GetMinimumTroopCost(BasicCultureObject culture = null)
        {
            MBReadOnlyList <MultiplayerClassDivisions.MPHeroClass> mpHeroClasses = MultiplayerClassDivisions.GetMPHeroClasses();

            return(culture != null?mpHeroClasses.Where <MultiplayerClassDivisions.MPHeroClass>((Func <MultiplayerClassDivisions.MPHeroClass, bool>)(c => c.Culture == culture)).Min <MultiplayerClassDivisions.MPHeroClass>((Func <MultiplayerClassDivisions.MPHeroClass, int>)(troop => troop.TroopCost)) : mpHeroClasses.Min <MultiplayerClassDivisions.MPHeroClass>((Func <MultiplayerClassDivisions.MPHeroClass, int>)(troop => troop.TroopCost)));
        }
Esempio n. 21
0
 internal MessengerManager()
 {
     _messengers = new List <Messenger>();
     Messengers  = new MBReadOnlyList <Messenger>(_messengers);
 }
Esempio n. 22
0
            private static Tuple <float, float> CalculateWarScore(CampaignWar campaignWar, MBReadOnlyList <IFaction> kingdomSide, MBReadOnlyList <IFaction> oppositionSide)
            {
                var kingdomWarScore    = CalculateWarScoreForSideAgainst(campaignWar, kingdomSide, oppositionSide);
                var oppositionWarScore = CalculateWarScoreForSideAgainst(campaignWar, oppositionSide, kingdomSide);

                return(Tuple.Create(kingdomWarScore, oppositionWarScore));
            }
Esempio n. 23
0
            private static float CalculateWarScoreForSideAgainst(CampaignWar campaignWar, MBReadOnlyList <IFaction> kingdomSide, MBReadOnlyList <IFaction> oppositionSide)
            {
                var warScore = 0.0f;

                var factionCasualties = 0;

                foreach (var faction in kingdomSide)
                {
                    // Each point of renown is 1 point.
                    var factionRenown = campaignWar.GetWarScoreOfFaction(faction);
                    warScore += factionRenown * 1f;

                    // Each raid counts as 50 points.
                    var factionRaids = campaignWar.GetSuccessfulRaidsOfFaction(faction);
                    warScore += factionRaids * 50f;

                    // Each siege counts as 300 points.
                    var factionSieges = campaignWar.GetSuccessfulSiegesOfFaction(faction);
                    warScore += factionSieges * 300f;

                    // Track, but do not add, the number of allies killed.
                    factionCasualties += campaignWar.GetCasualtiesOfFaction(faction);
                }

                // Each enemy casualty is 1 point.
                var oppositionCasualties = 0;

                foreach (var faction in oppositionSide)
                {
                    oppositionCasualties += campaignWar.GetCasualtiesOfFaction(faction);
                }
                warScore += oppositionCasualties * 1f;

                // Scale the score by the a multiplier reflecting how many
                // of the total losses are on the opponent's side.
                var totalCasualties = factionCasualties + oppositionCasualties;
                var casualtyMult    = (totalCasualties > 0) ? (oppositionCasualties / (float)totalCasualties) : 1;

                warScore *= casualtyMult;

                return(warScore);
            }
        // Token: 0x0600013D RID: 317 RVA: 0x00004860 File Offset: 0x00002A60
        private void OnDailyTick()
        {
            try
            {
                bool flag = MBObjectManager.Instance.GetObjectTypeList <Clan>() != null;
                if (flag)
                {
                    bool bLogPartySpawns = ModSettings.Instance.bLogPartySpawns;
                    if (bLogPartySpawns)
                    {
                        Logging.lm("-------------------------------------------");
                        Logging.lm(" Logging Party Spawns to File");
                        Logging.lm("ToDays : " + CampaignTime.Now.ToDays.ToString());
                        Logging.lm("Now : " + CampaignTime.Now.ToString());
                        Logging.lm("NumberOfMaximumLooterParties :  " + Campaign.Current.Models.BanditDensityModel.NumberOfMaximumLooterParties.ToString());
                        Logging.lm("NumberOfMinimumBanditPartiesInAHideoutToInfestIt :  " + Campaign.Current.Models.BanditDensityModel.NumberOfMinimumBanditPartiesInAHideoutToInfestIt.ToString());
                        Logging.lm("NumberOfMaximumBanditPartiesInEachHideout :  " + Campaign.Current.Models.BanditDensityModel.NumberOfMaximumBanditPartiesInEachHideout.ToString());
                        Logging.lm("NumberOfMaximumBanditPartiesAroundEachHideout :  " + Campaign.Current.Models.BanditDensityModel.NumberOfMaximumBanditPartiesAroundEachHideout.ToString());
                        Logging.lm("NumberOfMaximumHideoutsAtEachBanditFaction :  " + Campaign.Current.Models.BanditDensityModel.NumberOfMaximumHideoutsAtEachBanditFaction.ToString());
                        Logging.lm("NumberOfInitialHideoutsAtEachBanditFaction :  " + Campaign.Current.Models.BanditDensityModel.NumberOfInitialHideoutsAtEachBanditFaction.ToString());
                        MBReadOnlyList <Clan> clanList = MBObjectManager.Instance.GetObjectTypeList <Clan>();
                        foreach (Clan clan in clanList)
                        {
                            bool flag2 = clan.Culture != null;
                            if (flag2)
                            {
                                Logging.lm("------");
                                bool flag3 = this.clanPartyCount.ContainsKey(clan.StringId);
                                if (flag3)
                                {
                                    int oldNumber = this.clanPartyCount[clan.StringId];
                                    Logging.lm(string.Concat(new string[]
                                    {
                                        "Clan Name: ",
                                        clan.Name.ToString(),
                                        "  StringId: ",
                                        clan.StringId.ToString(),
                                        "Culture Name: ",
                                        clan.Culture.Name.ToString(),
                                        "    Parties Count: ",
//										clan.Parties.Count<MobileParty>().ToString(),
                                        clan.AllParties.Count <MobileParty>().ToString(),
                                        "  Last Count: ",
                                        oldNumber.ToString()
                                    }));
                                    this.clanPartyCount[clan.StringId] = clan.AllParties.Count <MobileParty>();
                                }
                                else
                                {
                                    Logging.lm(string.Concat(new string[]
                                    {
                                        "Clan Name: ",
                                        clan.Name.ToString(),
                                        "  StringId: ",
                                        clan.StringId.ToString(),
                                        "Culture Name: ",
                                        clan.Culture.Name.ToString(),
                                        "    Parties Count: ",
                                        clan.AllParties.Count <MobileParty>().ToString()
                                    }));
                                    this.clanPartyCount.Add(clan.StringId, clan.AllParties.Count <MobileParty>());
                                }
                                Logging.lm("");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Ux.ShowMessageError("Kaoses Parties Exception in OnDailyTick Events : " + e.ToString());
            }
        }
Esempio n. 25
0
 internal void Sync()
 {
     Messengers = new MBReadOnlyList <Messenger>(_messengers);
 }
        private void CalculateReward(MBReadOnlyList <MapEventParty> defeatedParties, MapEventParty mapEventPlayerParty)
        {
            foreach (var party in defeatedParties)
            {
                var moneyAmount     = 0;
                var renownAmount    = 0;
                var influenceAmount = 0;
                var partyRewards    = XmlRewardData.GetInstance().PartyRewards;
                var partyReward     = partyRewards.FirstOrDefault(el => party.Party.Id.Contains(el.PartyId));
                if (partyReward != null)
                {
                    foreach (var reward in partyReward.Rewards)
                    {
                        switch (reward.Type)
                        {
                        case RewardType.Influence:
                            if (reward.RenownInfluenceMoneyAmount != null)
                            {
                                influenceAmount = Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                                mapEventPlayerParty.GainedInfluence += Convert.ToSingle(reward.RenownInfluenceMoneyAmount);
                            }
                            break;

                        case RewardType.Money:
                            if (reward.RenownInfluenceMoneyAmount != null)
                            {
                                moneyAmount = Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                                mapEventPlayerParty.PlunderedGold += Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                            }
                            break;

                        case RewardType.Item:
                            if (reward.ItemId != null)
                            {
                                var itemToAdd = Items.All.FirstOrDefault(obj => obj.StringId == reward.ItemId);
                                if (reward.Chance != null)
                                {
                                    if (IsItemGiven(Convert.ToDecimal(reward.Chance)))
                                    {
                                        mapEventPlayerParty.RosterToReceiveLootItems.Add(new ItemRosterElement(itemToAdd, 1));
                                    }
                                }
                            }
                            break;

                        case RewardType.Renown:
                            if (reward.RenownInfluenceMoneyAmount != null)
                            {
                                renownAmount = Convert.ToInt32(reward.RenownInfluenceMoneyAmount);
                                mapEventPlayerParty.GainedRenown += Convert.ToSingle(reward.RenownInfluenceMoneyAmount);
                            }
                            break;
                        }
                    }

                    InformationManager.DisplayMessage(
                        new InformationMessage(
                            $"{mapEventPlayerParty.Party?.LeaderHero?.Name.ToString() ?? Agent.Main.Name} defeated {party.Party.Name} gaining {moneyAmount} denars, {renownAmount} renown and {influenceAmount} influence",
                            Colors.Green
                            )
                        );
                }
            }
        }