Example #1
0
        private static void Postfix(BuildingWindow __instance)
        {
            if (!Main.Enabled ||
                __instance.readBookId <= 0 ||
                !Main.settings.HomeSystemAutoAccessories)
            {
                return;
            }

            if (CallByPatch)
            {
                CallByPatch = false;
                return;
            }

            int aptitudeType;

            if (__instance.studySkillTyp < 17)
            {
                // 技藝
                aptitudeType = AptitudeTypeHelper.GetAptitudeTypeBySkillType(__instance.studySkillTyp);
            }
            else
            {
                // 功法
                aptitudeType = AptitudeTypeHelper.GetAptitudeTypeByBookId(__instance.readBookId);
            }

            var items = ItemHelper.GetAptitudeUpOrComprehensionUpAccessories(aptitudeType);

            if (Main.settings.AdvancedReadBookMode &&
                BuildingWindow_GetNeedInt_Patch.LastNeedInt <= 50)
            {
                // 如果開了進階閱讀模式, 閱讀難度小於等於50時, 悟性優先
                items = from item in items
                        orderby item.ComprehensionUp descending
                        select item;
            }
            else
            {
                // 否則資質優先
                items = from item in items
                        orderby item.AptitudeUp descending, item.ComprehensionUp descending
                select item;
            }

            StateManager.EquipAccessories(items);
            // 重新整理
            CallByPatch = true;
            __instance.UpdateReadBookWindow();
        }