private void RemoveItem(PathTuple <TConfigType> itemTuple)
 {
     ItemsByPath.Remove(itemTuple.Path);
     ItemsByFolder.Remove(Path.GetDirectoryName(itemTuple.Path));
     Items.Remove(itemTuple);
     OnRemoveItem?.Invoke(itemTuple);
 }
Esempio n. 2
0
        public void Broadcast(BroadcastEventType e,
                              AddItemEventArgs aea             = null,
                              RemoveItemEventArgs rea          = null,
                              SwapItemsEventArgs sea           = null,
                              SwapItemsTrhuInvEventArgs siea   = null,
                              UseItemEventArgs uea             = null,
                              DropItemEventArgs dea            = null,
                              InitializeInventoryEventArgs iea = null)
        {
            //Debug.Log($"Broadcasting event {e}");
            switch (e)
            {
            case BroadcastEventType.AddItem:
                OnAddItem?.Invoke(this, aea);
                OnChange?.Invoke(this, aea);
                break;

            case BroadcastEventType.RemoveItem:
                OnRemoveItem?.Invoke(this, rea);
                OnChange?.Invoke(this, rea);
                break;

            case BroadcastEventType.SwapItem:
                OnSwapItem?.Invoke(this, sea);
                OnChange?.Invoke(this, sea);
                break;

            case BroadcastEventType.SwapTrhuInventory:
                OnSwapTrhuInventory?.Invoke(this, siea);
                OnChange?.Invoke(this, siea);
                break;

            case BroadcastEventType.UseItem:
                OnUseItem?.Invoke(this, uea);
                OnChange?.Invoke(this, uea);
                break;

            case BroadcastEventType.DropItem:
                OnDropItem?.Invoke(this, dea);
                OnChange?.Invoke(this, dea);
                break;

            case BroadcastEventType.PickUpItem:
                OnPickUpItem?.Invoke(this, aea);
                OnChange?.Invoke(this, aea);
                break;

            case BroadcastEventType.InitializeInventory:
                OnInitializeInventory?.Invoke(this, iea);
                OnChange?.Invoke(this, iea);
                break;

            default:
                break;
            }
            if (autoSaveOnChange)
            {
                InventoryController.SaveInventoryData();
            }
        }
Esempio n. 3
0
        void DestroyItemAt(int index)
        {
            if (itemsAtSlot.TryGetValue(index, out TGameObject viewItem))
            {
                itemsAtSlot.Remove(index);
                OnItemRemoved(viewItem, DataSource[index]);
                OnRemoveItem?.Invoke(viewItem, DataSource[index]);

                Pool.Destroy(viewItem);
            }
        }
Esempio n. 4
0
        public void DestroyAllItems()
        {
            foreach (KeyValuePair <int, TGameObject> itemInSlot in itemsAtSlot)
            {
                OnItemRemoved(itemInSlot.Value, DataSource[itemInSlot.Key]);
                OnRemoveItem?.Invoke(itemInSlot.Value, DataSource[itemInSlot.Key]);
                Pool.Destroy(itemInSlot.Value);
            }

            itemsAtSlot.Clear();
        }
Esempio n. 5
0
        /// <summary>
        /// Удалить оружие из выбранного
        /// </summary>
        /// <param name="weaponType"></param>
        void RemoveWeaponHandler(DataTableItems.ItemTypes weaponType)
        {
            for (int i = 0; i < DataManager.Instance.PlayerAccount.Inventory.SelectedWeapon.Count; i++)
            {
                if (DataManager.Instance.PlayerAccount.Inventory.SelectedWeapon[i].Equals(weaponType))
                {
                    DataManager.Instance.PlayerAccount.Inventory.SelectedWeapon[i] = account.Account.AccountInventory.DEFAULT_ITEM;
                }
            }

            OnRemoveItem?.Invoke(DataManager.Instance.PlayerAccount.Inventory.SelectedWeapon.ToArray());
        }
    public override bool SetItem(Item targetItem, out Item previousItem)
    {
        previousItem = _item;

        _item       = targetItem;
        _icon.color = targetItem.color;
        _title.text = targetItem.itemName;

        OnRemoveItem?.Invoke(previousItem);
        OnEquipItem?.Invoke(targetItem);
        Debug.Log($"{targetItem.itemName} put on.");

        return(true);
    }
Esempio n. 7
0
    void Drop(string strItem, int quantity)
    {
        ItemName item = Parse(strItem);

        if (quantity < 1)
        {
            Debug.LogWarning($"{quantity} is less than 1");
            return;
        }
        if (!inventory.ContainsKey(item))
        {
            Debug.LogWarning($"I don't have {item.ToString()}");
            return;
        }
        ItemData data = itemDictionary[item];

        inventory[item]--;
        OnRemoveItem?.Invoke(data);
        MainSingleton.Instance.notification.Notify($"Dropped {item.ToString()} from inventory");
    }
Esempio n. 8
0
    public override bool SetItem(Item targetItem, out Item previousItem)
    {
        bool nonRequireItemType = _type != targetItem.type && targetItem.type != ItemType.Empty;

        previousItem = null;

        if (nonRequireItemType)
        {
            return(false);
        }

        previousItem = _item;
        RenderItem(targetItem);

        OnRemoveItem?.Invoke(previousItem);
        OnEquipItem?.Invoke(targetItem);
        Debug.Log($"{targetItem.itemName} put on in equip.");

        return(true);
    }
Esempio n. 9
0
 public void RemoveOnRemoveItemListener(UnityAction <Item, IBackpack> listener)
 {
     OnRemoveItem.RemoveListener(listener);
 }
Esempio n. 10
0
 public void AddOnRemoveItemListener(UnityAction <Item, IBackpack> listener)
 {
     OnRemoveItem.AddListener(listener);
 }
Esempio n. 11
0
 public virtual void RemoveItem(Item item)
 {
     items.Remove(item);
     OnRemoveItem?.Invoke(item, this);
 }
Esempio n. 12
0
 public static void RemoveItem(int index) => OnRemoveItem?.Invoke(index);
Esempio n. 13
0
 private void OnDisable()
 {
     OnAddItem.RemoveAllListeners();
     OnRemoveItem.RemoveAllListeners();
 }
 private void cmdRemoveItem_Click(object sender, EventArgs e)
 {
     OnRemoveItem?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 15
0
 public void RemoveItem(ItemInst item)
 {
     BaseInst.Remove(item.BaseInst);
     item.OnSetAmount -= Item_OnSetAmount;
     OnRemoveItem?.Invoke(item);
 }
Esempio n. 16
0
 private void OnEnable()
 {
     ResetSpawnPoints();
     OnAddItem.AddListener(AddSpawnPoint);
     OnRemoveItem.AddListener(RemoveSpawnPoint);
 }
Esempio n. 17
0
 public static void RaiseRemoveItem(CacheArgs args)
 {
     OnRemoveItem?.Invoke(null, args);
 }
Esempio n. 18
0
        private void DisplayOneItem(Object toDisplay, string nameInListPath, int index, float width, bool disable)
        {
            if (toDisplay == null && string.IsNullOrEmpty(nameInListPath))
            {
                return;
            }

            if (toDisplay == null && !UnityEssentialsPreferences.GetBool(UnityEssentialsPreferences.SHOW_GAMEOBJECTS_FROM_OTHER_SCENE, true))
            {
                return;
            }

            GUI.color = (PeekSerializeObject.LastSelectedObject == toDisplay && toDisplay != null) ? Color.green : Color.white;

            EditorGUI.BeginDisabledGroup(disable);
            {
                using (HorizontalScope horizontalScope = new HorizontalScope(GUILayout.Width(width), GUILayout.Height(_heightLine)))
                {
                    float widthExtent = CalculateWidthExtentOptions.CalculateWidthExtent(width, index, ListToDisplay.arraySize);
                    float widthButtonWithoutExtent = CalculateWidthExtentOptions.CalculateButtonWidthWithoutExtent(widthExtent, _heightLine, _margin);

                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                    //display bookmark button
                    bool clicOnBookMark = BookMarkButtonOptions.ButtonImageWithHover(WIDTH_BUTTON_HOVER, toDisplay != null, _heightLine);
                    if (clicOnBookMark)
                    {
                        OnBookMarkClic?.Invoke(index);
                        return;
                    }
                    //display main logo
                    DisplayLogoByTypeOfObject(toDisplay, _heightLine);
                    if (!disable && !_dragSettings.IsDragging)
                    {
                        Rect logoContent = GUILayoutUtility.GetLastRect();
                        if (logoContent.Contains(Event.current.mousePosition))
                        {
                            EditorGUIUtility.AddCursorRect(logoContent, MouseCursor.MoveArrow);
                            if (Event.current.type == EventType.MouseDown)
                            {
                                _listToDisplayCopy = ListToDisplay.ToObjectList();
                                _dragSettings.StartDragging(index, logoContent);
                                Event.current.Use();
                            }
                        }
                    }
                    //display main button
                    EditorGUI.BeginDisabledGroup(toDisplay == null);
                    {
                        string nameObjectToSelect;
                        if (toDisplay == null)
                        {
                            nameObjectToSelect = !string.IsNullOrEmpty(nameInListPath) ? ObjectNames.NicifyVariableName(nameInListPath) : " --- not found --- ";
                        }
                        else
                        {
                            nameObjectToSelect = ObjectNames.NicifyVariableName(toDisplay.name);
                        }


                        GUIContent buttonSelectContent = ShortenNameIfNeeded(nameObjectToSelect, width, widthButtonWithoutExtent);
                        buttonSelectContent.tooltip = "Clic to select, Right clic to Pin only";
                        if (GUILayout.Button(buttonSelectContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(true), GUILayout.Height(_heightLine)))
                        {
                            if (Event.current.button == 0)
                            {
                                OnSelectItem?.Invoke(index);
                            }
                            else
                            {
                                OnPinItem?.Invoke(index);
                            }
                            return;
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    //display special scene buttons
                    if (toDisplay == null && OnInfoItem != null)
                    {
                        bool selectScene = false;
                        bool goToScene   = false;

                        DisplaySpecialSceneSettings(ref selectScene, ref goToScene);
                        if (goToScene)
                        {
                            OnInfoForceItem?.Invoke(index);
                            return;
                        }
                        else if (selectScene)
                        {
                            OnInfoItem?.Invoke(index);
                            return;
                        }
                    }

                    //display delete button
                    GUIContent buttonDeletContent = EditorGUIUtility.IconContent(DELETE_ICON);
                    buttonDeletContent.tooltip = "Remove from list";
                    if (GUILayout.Button(buttonDeletContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(false), GUILayout.MaxWidth(WIDTH_BUTTON_HOVER), GUILayout.Height(_heightLine)) &&
                        Event.current.button == 0)
                    {
                        OnRemoveItem?.Invoke(index);
                        return;
                    }
                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
        }