Ejemplo n.º 1
0
        static bool ModExt_NewPropsUI2(CtrlMedicine __instance, CharacterMapping mapping)
        {
            var map = Traverse.Create(__instance).Field("mapping");

            if (mapping != map.GetValue <CharacterMapping>())
            {
                map.SetValue(mapping);
                __instance.OnShow();
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static bool ModExt_NewPropsUI(CtrlMedicine __instance)
        {
            var mapping = Traverse.Create(__instance).Field("mapping");
            var sort    = Traverse.Create(__instance).Field("sort").GetValue <List <PropsInfo> >();

            mapping.SetValue(GlobalLib.GetUICharacterMapping());
            sort.Clear();
            foreach (KeyValuePair <string, InventoryData> keyValuePair in Game.GameData.Inventory)
            {
                string key   = keyValuePair.Key;
                Props  props = Game.Data.Get <Props>(key);
                if (props != null && props.PropsType == PropsType.Medicine)
                {
                    bool show = false;
                    if (props.CanUseID != null && props.CanUseID.Count > 0)
                    {
                        for (int i = 0; i < props.CanUseID.Count; i++)
                        {
                            string text = props.CanUseID[i];
                            if (!text.IsNullOrEmpty() && text == mapping.GetValue <CharacterMapping>().Id)
                            {
                                show = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        show = true;
                        if (props.PropsCategory >= PropsCategory.Fist_Secret_Scroll && props.PropsCategory <= PropsCategory.Throw_Secret_Scroll && key.StartsWith("p_scroll"))
                        {
                            foreach (var pe in props.PropsEffect)
                            {
                                if (pe is PropsLearnSkill pls)
                                {
                                    PropsCategory skillType = Game.Data.Get <Skill>(pls.Id).Type;
                                    if (!GlobalLib.HasSkillType(mapping.GetValue <CharacterMapping>().InfoId, skillType))
                                    {
                                        show = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (show)
                    {
                        PropsInfo propsInfo = new PropsInfo(key)
                        {
                            ConditionStatus = ((props.UseTime == PropsUseTime.Battle) ? PropsInfo.PropsConditionStatus.UseTimeFail_Battle : PropsInfo.PropsConditionStatus.AllPass)
                        };
                        sort.Add(propsInfo);
                    }
                }
            }
            var view = Traverse.Create(__instance).Field("view").GetValue <UIMedicine>();

            view.UpdateProps(sort.Count);
            if (sort.Count <= 0)
            {
                view.UpdatePropsIntroduction(null);
            }
            return(false);
        }