コード例 #1
0
 public static void IsOpened(CraftingPiece craftingPiece, ref bool __result)
 {
     if (BannerlordCheatsSettings.Instance.UnlockAllParts)
     {
         __result = true;
     }
 }
コード例 #2
0
        private static bool Prefix(CraftingCampaignBehavior __instance)
        {
            if (!ForgeOverhaulConfig.ConfigSettings.RestrictPartUnlockPerCategoryEnabled)             //meh code
            {
                return(true);
            }
            Traverse.Create(__instance).Method("EnsureParts").GetValue();
            var           allParts          = (CraftingPiece[])Traverse.Create(__instance).Field("_allCraftingParts").GetValue();
            var           openedParts       = (List <CraftingPiece>)Traverse.Create(__instance).Field("_openedParts").GetValue();
            int           totalPartCount    = allParts.Length;
            int           unlockedPartCount = openedParts.Count;
            SmithingModel smithingModel     = Campaign.Current.Models.SmithingModel;

            CraftingPiece[] array = (from x in allParts
                                     where !openedParts.Contains(x) && RememberLastDesignFix.LastWeaponCrafted.WeaponDesign.Template.Pieces.Contains(x)
                                     select x).ToArray <CraftingPiece>();
            if (array.Length != 0)
            {
                CraftingPiece craftingPiece = MBRandom.ChooseWeighted <CraftingPiece>(array, (CraftingPiece x) => smithingModel.GetProbabalityToOpenPart(x));
                if (craftingPiece != null)
                {
                    Traverse.Create(__instance).Method("OpenPart", craftingPiece).GetValue();
                }
            }
            return(false);
        }
コード例 #3
0
        public static void GetCraftingPartDifficulty(CraftingPiece craftingPiece, ref int __result)
        {
            if (BannerlordCheatsSettings.Instance.SmithingDifficultyPercentage < 100)
            {
                var factor = BannerlordCheatsSettings.Instance.SmithingDifficultyPercentage / 100f;

                var newValue = (int)Math.Round(factor * __result);

                __result = newValue;
            }
        }
コード例 #4
0
 public static void IsOpened(CraftingPiece craftingPiece, ref bool __result)
 {
     try
     {
         if (BannerlordCheatsSettings.Instance?.UnlockAllParts == true)
         {
             __result = true;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(UnlockAllParts));
     }
 }
コード例 #5
0
        public static void GetCraftingPartDifficulty(CraftingPiece craftingPiece, ref int __result)
        {
            try
            {
                if (BannerlordCheatsSettings.Instance?.SmithingDifficultyPercentage < 100f)
                {
                    var factor = BannerlordCheatsSettings.Instance.SmithingDifficultyPercentage / 100f;

                    var newValue = (int)Math.Round(factor * __result);

                    __result = newValue;
                }
            }
            catch (Exception e)
            {
                SubModule.LogError(e, typeof(SmithingDifficultyPercentage));
            }
        }