public override float CalculateFinalSpeed(MobileParty mobileParty, float baseSpeed, StatExplainer explanation)
        {
            try
            {
                PartyBase       party           = mobileParty.Party;
                ExplainedNumber explainedNumber = new ExplainedNumber(baseSpeed, explanation, null);
                explainedNumber.LimitMin(1f);
                string key = CampaignUtils.IsolateMobilePartyStringID(mobileParty); //TODO if this is non-trivial make it more efficient
                if (partyIDToBaseSpeed.ContainsKey(key) && partyIDToBaseSpeed[key] != float.MinValue)
                {
                    float bs = partyIDToBaseSpeed[key];
                    explainedNumber.Add(bs - explainedNumber.ResultNumber, explanationText);
                }
                else if (partyIDToExtraSpeed.ContainsKey(key))
                {
                    float extra = partyIDToExtraSpeed[key];
                    explainedNumber.Add(extra, explanationText);
                }
                TerrainType faceTerrainType = Campaign.Current.MapSceneWrapper.GetFaceTerrainType(mobileParty.CurrentNavigationFace);
                float       num             = explainedNumber.ResultNumber;
                if (partyIDToMinimumSpeed.ContainsKey(key))//minimum adjustment
                {
                    num = Math.Max(num, partyIDToMinimumSpeed[key]);
                }
                else
                {
                    explainedNumber.LimitMin(1f);
                }

                if (partyIDToMaximumSpeed.ContainsKey(key))//maximum adjustment
                {
                    num = Math.Min(num, partyIDToMaximumSpeed[key]);
                }

                explainedNumber.Add(num - explainedNumber.ResultNumber, new TextObject("Custom Spawns final modification"));
                if (faceTerrainType == TerrainType.Forest)
                {
                    explainedNumber.AddFactor(-0.3f, _movingInForest);
                    PerkHelper.AddFeatBonusForPerson(DefaultFeats.Cultural.BattanianForestAgility, mobileParty.Leader, ref explainedNumber);
                }
                else if (faceTerrainType == TerrainType.Water || faceTerrainType == TerrainType.River || faceTerrainType == TerrainType.Bridge || faceTerrainType == TerrainType.ShallowRiver)
                {
                    explainedNumber.AddFactor(-0.3f, _fordEffect);
                }
                if (Campaign.Current.IsNight)
                {
                    explainedNumber.AddFactor(-0.25f, _night);
                }
                if (faceTerrainType == TerrainType.Snow)
                {
                    explainedNumber.AddFactor(-0.1f, _snow);
                    if (party.Leader != null)
                    {
                        PerkHelper.AddFeatBonusForPerson(DefaultFeats.Cultural.SturgianSnowAgility, party.Leader, ref explainedNumber);
                    }
                }
                return(explainedNumber.ResultNumber);
            }
            catch (Exception e)
            {
                ErrorHandler.HandleException(e, " MOBILE PARTY FINAL SPEED CALCULATION ");
                return(1f);
            }
        }
Ejemplo n.º 2
0
        // Token: 0x06000138 RID: 312 RVA: 0x00004210 File Offset: 0x00002410
        public override float CalculateFinalSpeed(MobileParty mobileParty, float baseSpeed, StatExplainer explanation)
        {
            PartyBase       party           = mobileParty.Party;
            ExplainedNumber explainedNumber = new ExplainedNumber(baseSpeed, explanation, null);
            TerrainType     faceTerrainType = Campaign.Current.MapSceneWrapper.GetFaceTerrainType(mobileParty.CurrentNavigationFace);
            bool            flag            = faceTerrainType == TerrainType.Forest;

            if (flag)
            {
                explainedNumber.AddFactor(-0.3f, KaosPartySpeed._movingInForest);
                PerkHelper.AddFeatBonusForPerson(DefaultFeats.Cultural.BattanianForestAgility, mobileParty.Leader, ref explainedNumber);
            }
            else
            {
                bool flag2 = faceTerrainType == TerrainType.Water || faceTerrainType == TerrainType.River || faceTerrainType == TerrainType.Bridge || faceTerrainType == TerrainType.ShallowRiver;
                if (flag2)
                {
                    explainedNumber.AddFactor(-0.3f, KaosPartySpeed._fordEffect);
                }
            }
            bool isNight = Campaign.Current.IsNight;

            if (isNight)
            {
                explainedNumber.AddFactor(-0.25f, KaosPartySpeed._night);
            }
            bool flag3 = faceTerrainType == TerrainType.Snow;

            if (flag3)
            {
                explainedNumber.AddFactor(-0.1f, KaosPartySpeed._snow);
                bool flag4 = party.Leader != null;
                if (flag4)
                {
                    PerkHelper.AddFeatBonusForPerson(DefaultFeats.Cultural.SturgianSnowAgility, party.Leader, ref explainedNumber);
                }
            }
            bool isActive = mobileParty.IsActive;

            if (isActive)
            {
                bool partyTypeFound = false;
                bool flag5          = mobileParty.StringId.Contains("looter") && ModSettings.Instance.looterSpeedReductiontEnabled;
                if (flag5)
                {
                    explainedNumber.Add(ModSettings.Instance.caravanSpeedReductionAmount, KaosPartySpeed._slowMessage);
                    partyTypeFound = true;
                }
                bool flag6 = mobileParty.StringId.Contains("caravan");
                if (flag6)
                {
                    bool flag7 = mobileParty.StringId.Contains("elite") && ModSettings.Instance.eliteCaravanSpeedReductiontEnabled;
                    if (flag7)
                    {
                        explainedNumber.Add(ModSettings.Instance.eliteCaravanSpeedReductionAmount, KaosPartySpeed._slowCaravansMessage);
                    }
                    else
                    {
                        bool caravanSpeedReductiontEnabled = ModSettings.Instance.caravanSpeedReductiontEnabled;
                        if (caravanSpeedReductiontEnabled)
                        {
                            explainedNumber.Add(ModSettings.Instance.caravanSpeedReductionAmount, KaosPartySpeed._slowCaravansMessage);
                        }
                    }
                    partyTypeFound = true;
                }
                bool flag8 = mobileParty.StringId.Contains("desert") && ModSettings.Instance.desertSpeedReductiontEnabled;
                if (flag8)
                {
                    explainedNumber.Add(ModSettings.Instance.desertSpeedReductionAmount, KaosPartySpeed._slowMessage);
                    partyTypeFound = true;
                }
                bool flag9 = mobileParty.StringId.Contains("forest") && ModSettings.Instance.forestSpeedReductiontEnabled;
                if (flag9)
                {
                    explainedNumber.Add(ModSettings.Instance.forestSpeedReductionAmount, KaosPartySpeed._slowMessage);
                    partyTypeFound = true;
                }
                bool flag10 = mobileParty.StringId.Contains("mountain") && ModSettings.Instance.mountainSpeedReductiontEnabled;
                if (flag10)
                {
                    explainedNumber.Add(ModSettings.Instance.mountainSpeedReductionAmount, KaosPartySpeed._slowMessage);
                    partyTypeFound = true;
                }
                bool flag11 = mobileParty.StringId.Contains("raider") && ModSettings.Instance.seaRaiderSpeedReductiontEnabled;
                if (flag11)
                {
                    explainedNumber.Add(ModSettings.Instance.seaRaiderSpeedReductionAmount, KaosPartySpeed._slowMessage);
                    partyTypeFound = true;
                }
                bool flag12 = mobileParty.StringId.Contains("steppe") && ModSettings.Instance.steppeSpeedReductiontEnabled;
                if (flag12)
                {
                    explainedNumber.Add(ModSettings.Instance.steppeSpeedReductionAmount, KaosPartySpeed._slowMessage);
                    partyTypeFound = true;
                }
                bool flag13 = mobileParty.StringId.Contains("villager") && ModSettings.Instance.villagerSpeedReductiontEnabled;
                if (flag13)
                {
                    explainedNumber.Add(ModSettings.Instance.villagerSpeedReductionAmount, KaosPartySpeed._slowVillagerMessage);
                    partyTypeFound = true;
                }
                bool flag14 = mobileParty.StringId.Contains("lord_") && ModSettings.Instance.kingdomSpeedReductiontEnabled;
                if (flag14)
                {
                    explainedNumber.Add(ModSettings.Instance.kingdomSpeedReductionAmount, KaosPartySpeed._slowKingdomMessage);
                    partyTypeFound = true;
                }
                bool flag15 = mobileParty.StringId.Contains("troops_of") && ModSettings.Instance.otherKingdomSpeedReductionEnabled;
                if (flag15)
                {
                    explainedNumber.Add(ModSettings.Instance.otherKingdomSpeedReductionAmount, KaosPartySpeed._slowMinorMessage);
                    partyTypeFound = true;
                }
                bool flag16 = mobileParty.IsMainParty && ModSettings.Instance.playerSpeedReductiontEnabled;
                if (flag16)
                {
                    explainedNumber.Add(ModSettings.Instance.playerSpeedReductionAmount, KaosPartySpeed._slowPlayerMessage);
                    partyTypeFound = true;
                }
                bool flag17 = !mobileParty.IsMainParty && !mobileParty.StringId.Contains("player_") && !mobileParty.StringId.Contains("militias_") && !mobileParty.StringId.Contains("garrison_");
                if (flag17)
                {
                    bool flag18 = !partyTypeFound && !mobileParty.IsLeaderless;
                    if (flag18)
                    {
                        Hero hero   = mobileParty.LeaderHero;
                        bool flag19 = hero != null;
                        if (flag19)
                        {
                            Clan clan       = hero.Clan;
                            Clan playerClan = Clan.PlayerClan;
                            bool flag20     = clan == playerClan && ModSettings.Instance.playerCompanionSpeedReductiontEnabled;
                            if (flag20)
                            {
                                explainedNumber.Add(ModSettings.Instance.playerCompanionSpeedReductionAmount, KaosPartySpeed._slowPlayerClanMessage);
                            }
                            else
                            {
                                bool otherKingdomSpeedReductionEnabled = ModSettings.Instance.otherKingdomSpeedReductionEnabled;
                                if (otherKingdomSpeedReductionEnabled)
                                {
                                    explainedNumber.Add(ModSettings.Instance.otherKingdomSpeedReductionAmount, KaosPartySpeed._slowMinorMessage);
                                }
                            }
                        }
                    }
                }
            }
            explainedNumber.LimitMin(ModSettings.Instance.kaosesmininumSpeedAmount);
            return(explainedNumber.ResultNumber);
        }