コード例 #1
0
        public void OpenUI(BaseBag bag)
        {
            Type bagType = UICache.ContainsKey(bag.GetType()) ? bag.GetType() : bag.GetType().BaseType;

            bag.UI    = (IBagPanel)Activator.CreateInstance(UICache[bagType]);
            bag.UI.ID = bag.ID;

            BaseElement element = (BaseElement)bag.UI;

            element.Activate();

            if (Main.LocalPlayer.GetModPlayer <PSPlayer>().UIPositions.TryGetValue(bag.ID, out Vector2 position))
            {
                element.HAlign   = element.VAlign = 0;
                element.Position = position;
            }

            Append(element);
            ContainerLibrary.ContainerLibrary.ItemHandlerUI.Add((IItemHandlerUI)element);

            Main.PlaySound(bag.OpenSound);
        }