Exemplo n.º 1
0
        static bool Prefix(CraftingCampaignBehavior __instance)
        {
            try
            {
                IDictionary records = (IDictionary)(typeof(CraftingCampaignBehavior).GetField("_heroCraftingRecords", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(__instance));
                foreach (Hero hero in records.Keys)
                {
                    int curCraftingStamina = __instance.GetHeroCraftingStamina(hero);

                    if (curCraftingStamina < Settings.Instance.MaxCraftingStamina)
                    {
                        int staminaGainAmount = Settings.Instance.CraftingStaminaGainAmount;

                        if (Settings.Instance.CraftingStaminaGainOutsideSettlementMultiplier < 1 && hero.PartyBelongedTo?.CurrentSettlement == null)
                        {
                            staminaGainAmount = (int)Math.Ceiling(staminaGainAmount * Settings.Instance.CraftingStaminaGainOutsideSettlementMultiplier);
                        }

                        int diff = Settings.Instance.MaxCraftingStamina - curCraftingStamina;
                        if (diff < staminaGainAmount)
                        {
                            staminaGainAmount = diff;
                        }

                        __instance.SetHeroCraftingStamina(hero, Math.Min(Settings.Instance.MaxCraftingStamina, curCraftingStamina + staminaGainAmount));
                        //MessageBox.Show($"Hero: {hero.Name}\n\nCrafting Stamina: {__instance.GetHeroCraftingStamina(hero)}");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An exception happened during the HourlyTick patch:\n\n{ex.Message}\n\n{ex.InnerException?.Message}", "Exception");
            }
            return(false);
        }
        static bool Prefix(CraftingCampaignBehavior __instance)
        {
            if (recordsInfo == null)
            {
                GetRecordsInfo();
            }
            //Get the list of hero records
            IDictionary records = (IDictionary)recordsInfo.GetValue(__instance);

            foreach (Hero hero in records.Keys)
            {
                int curCraftingStamina = __instance.GetHeroCraftingStamina(hero);

                if (curCraftingStamina < Settings.Instance.MaxCraftingStamina)
                {
                    int staminaGainAmount = Settings.Instance.CraftingStaminaGainAmount;

                    if (Settings.Instance.CraftingStaminaGainOutsideSettlementMultiplier < 1 && hero.PartyBelongedTo?.CurrentSettlement == null)
                    {
                        staminaGainAmount = (int)Math.Ceiling(staminaGainAmount * Settings.Instance.CraftingStaminaGainOutsideSettlementMultiplier);
                    }

                    int diff = Settings.Instance.MaxCraftingStamina - curCraftingStamina;
                    if (diff < staminaGainAmount)
                    {
                        staminaGainAmount = diff;
                    }

                    __instance.SetHeroCraftingStamina(hero, Math.Min(Settings.Instance.MaxCraftingStamina, curCraftingStamina + staminaGainAmount));
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        static bool Prefix(CraftingCampaignBehavior __instance)
        {
            Hero hero = PartyBase.MainParty.LeaderHero;

            if (hero != null)
            {
                int heroCraftingStamina = __instance.GetHeroCraftingStamina(hero);
                int maxCraftingStamina  = __instance.GetMaxHeroCraftingStamina(hero);

                int newStamina = Math.Min(maxCraftingStamina, heroCraftingStamina + SMITHING_STAMINA_GAIN);

                __instance.SetHeroCraftingStamina(hero, newStamina);
            }
            return(true);
        }
Exemplo n.º 4
0
        public static void Prefix(CraftingCampaignBehavior __instance)
        {
            XmlNode settings   = ClanTweakerSubModule.settings.xmlSettings.ChildNodes[1].SelectSingleNode("CraftingSettings");
            int     maxStamina = int.Parse(settings.SelectSingleNode("MaxStamina").InnerText);
            int     hourlyGain = int.Parse(settings.SelectSingleNode("StaminaGain").InnerText);

            IDictionary dictionary = (IDictionary)typeof(CraftingCampaignBehavior).GetField("_heroCraftingRecords", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);

            foreach (object obj in dictionary.Keys)
            {
                Hero hero = (Hero)obj;
                int  heroCraftingStamina = __instance.GetHeroCraftingStamina(hero);
                if (heroCraftingStamina < maxStamina)
                {
                    if (((hero.PartyBelongedTo != null) ? hero.PartyBelongedTo.CurrentSettlement : null) != null)
                    {
                        __instance.SetHeroCraftingStamina(hero, Math.Min(maxStamina, heroCraftingStamina + hourlyGain));
                    }
                }
            }
        }