using System; using System.Collections.Generic; namespace ET { [FriendClass(typeof(Menu))] public static class MenuHelper { public static async ETTask GetMenu(Unit unit) { try { M2C_GetMenu resp = await unit.ZoneScene().GetComponent().Session.Call(new C2M_GetMenu() { }) as M2C_GetMenu; if (resp.Error != ErrorCode.ERR_Success) { Log.Error(resp.Error.ToString()); return resp.Error; } MenuComponent menuComponent = unit.GetOrAddComponent(); menuComponent.Dispose(); menuComponent = unit.GetOrAddComponent(); foreach (var v in resp.MenuList) { Menu menu = menuComponent.AddChildWithId(v.ConfigId); menu.FromMessage(v); } } catch (Exception e) { Console.WriteLine(e); throw; } await ETTask.CompletedTask; return ErrorCode.ERR_Success; } public static List GetUnlockedMenuWithType(Unit unit, int type) { List result = new List(); MenuComponent menuComponent = unit.GetOrAddComponent(); foreach (var v in menuComponent.Children.Values) { Menu menu = (Menu)v; SynthesisConfig synthesisConfig = SynthesisConfigCategory.Instance.Get(menu.ConfigId); AllItemConfig allItemConfig = AllItemConfigCategory.Instance.Get(synthesisConfig.MixtureID); CuisineConfig cuisineConfig = CuisineConfigCategory.Instance.Get(allItemConfig.RelatedId); if(cuisineConfig.Type == type) { result.Add(menu); } } return result; } } }