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(); } }
private void Take(ItemName item, int quantity, bool silent = false) { if (quantity < 1) { Debug.LogWarning($"{quantity} is less than 1"); return; } if (inventory.Count >= MAX_ITEMS) { MainSingleton.Instance.notification.Notify("Inventory full"); return; } ItemData data = itemDictionary[item]; if (inventory.ContainsKey(item)) { inventory[item] += quantity; } else { inventory.Add(item, quantity); } OnAddItem?.Invoke(data); if (!silent) { MainSingleton.Instance.notification.Notify($"Added {item.ToString()} to inventory"); } }
public void Add(InventoryItem item) { items.Add(item); SaveLoadManager.Instance.Data.Inventory = GetSerializableInventory(); SaveLoadManager.Instance.Save(); onAddItem?.Invoke(item); }
public void AddItemAt(int x, int y, BattleMapObj item) { BeforeAddItem?.Invoke(x, y, item); Map.SetObjAt(x, y, item); OnAddItem?.Invoke(x, y, item); AfterAddItem?.Invoke(x, y, item); }
private void btnAdd_Click(object sender, EventArgs e) { int index = lbxCollection.SelectedIndex; if (index < 0) { index = lbxCollection.Items.Count; } object element = null; OnAddItem?.Invoke(index, element, insertItem); }
//Method to add item to inventory public void GiveItem(Item item) { if (CheckFreeSpace() == false) { return; } characterItems.Add(item); inventoryUI.AddNewItem(item); item.gameObject.SetActive(false); if (debug) { Debug.Log("Added item: " + item.title); } //Events item.onPickupEvent.Invoke(); onAddItem.Invoke(); }
private void AddItem(PathTuple <TConfigType> itemTuple) { // Check for existing item. bool alreadyHasItem = ItemsByPath.TryGetValue(itemTuple.Path, out var existing); ItemsByPath[itemTuple.Path] = itemTuple; ItemsByFolder[Path.GetDirectoryName(itemTuple.Path)] = itemTuple; if (alreadyHasItem) { // Sometimes you might get directory, then file notification, so we might get a duplicate. // We hackily filter out this duplicate here. var index = Items.IndexOf(existing); Items[index] = itemTuple; } else { Items.Add(itemTuple); OnAddItem?.Invoke(itemTuple); } }
public void TriggerActions(List <DialogueAction> actions) { actions.ForEach(action => { switch (action.actionKey) { /* Note: At present you can skip ahead if in the right scene, may want * to prevent this by adding 'must happen before' restrictions on * chat nodes */ case DialogueConsts.CANCEL_CONVERSATION: OnCancelConversation?.Invoke(); break; case DialogueConsts.ADD_KEY_ITEM: OnAddItem?.Invoke(action.actionValue); break; case DialogueConsts.OPEN_SHOP: OnOpenShop?.Invoke(action.actionValue); break; case DialogueConsts.ADD_LOG_ENTRY: OnAddLogEntry?.Invoke(action.actionValue); break; case DialogueConsts.INVALIDATE_CONVERSATION: dialogueService.SetValidationOnConvo(action.actionValue, false); break; case DialogueConsts.VALIDATE_CONVERSATION: dialogueService.SetValidationOnConvo(action.actionValue, true); break; case DialogueConsts.TEST_ACTION: Log("This is a test action, it does nothing special."); break; } }); }
public void AddItem(ItemInst item) { BaseInst.Add(item.BaseInst); item.OnSetAmount += Item_OnSetAmount; OnAddItem?.Invoke(item); }