private void OnItemDropped(ISlot from, List <GameObject> objectsHit) { // Outside inventory if (objectsHit.Count == 0) { OnItemRemove?.Invoke(from.StoredItem, from.SlotCount); from.DropAll(); return; } for (int i = 0, n = objectsHit.Count; i < n; i++) { // Dropped on the inventory grid if (objectsHit[i].TryGetComponent(out IInventorySystem _)) { return; } // Dropped on inventory slot if (objectsHit[i].TryGetComponent(out ISlot to)) { MoveItem(from, to); return; } } // Outside inventory from.DropAll(); OnItemRemove?.Invoke(from.StoredItem, from.SlotCount); }
public async Task RemoveItem(TodoItem item) { await CreateConnection(); await connection.DeleteAsync(item); OnItemRemove?.Invoke(this, item); }
private async Task RemoveSelectedClicked(TModel item) { // Remove item from selected Selected.Remove(item); // Invoke events await SelectedChanged.InvokeAsync(Selected); await OnItemRemove.InvokeAsync(item); }
protected override void ClearItems() { if (OnItemRemove != null) { foreach (var item in this) { OnItemRemove?.Invoke(item); } } base.ClearItems(); }
private void OnRemoveEntity(EntityEventArgs args) { var physItem = args.Entity as PhysicalItem; if (physItem != null && physItem.IsValid && physItem.Item?.Purchaser?.Hero?.Handle == MyHero.Handle) { MyHero.DroppedItems.Remove(physItem.Item); return; } var ability = args.Entity as Ability; if (ability != null && ability.IsValid) { var isMine = ability.Owner?.Handle == MyHero.Handle; if (isMine) { MyHero.RemoveAbility(ability); var usableAbility = MyHero.UsableAbilities.FirstOrDefault(x => x.Handle == ability.Handle); if (usableAbility != null) { MyHero.UsableAbilities.Remove(usableAbility); } } OnAbilityRemove?.Invoke(null, new AbilityEventArgs(ability, isMine)); } var item = args.Entity as Item; if (item != null && item.IsValid) { var isMine = item.Purchaser?.Hero?.Handle == MyHero.Handle; if (isMine) { MyHero.RemoveItem(item); } OnItemRemove?.Invoke(null, new ItemEventArgs(item, isMine)); return; } var unit = args.Entity as Unit; if (unit != null && unit.IsValid && unit.IsRealUnit()) { Units.Remove(unit); OnUnitRemove?.Invoke(null, new UnitEventArgs(unit)); } }
private void Remove_AtAllClients(NameNetworkData data) { // if (!NetworkMagic.IsServer) // return; if (!itemListServer.Contains(data.Name)) { DebugLog.Warning($"Tried to remove an item from empty list."); } itemListServer.Remove(data.Name); OnItemRemove?.Invoke(data.Name); }
/// <summary> /// Removes an entity from the inventory /// </summary> /// <param name="obj">The entity to remove</param> /// <param name="amount">The amount to remove</param> public void Remove(Entity obj, int amount) { var index = entities.IndexOf(obj); if (index > -1) { quantities[index] -= amount; if (quantities[index] < 1) { quantities.RemoveAt(index); entities.RemoveAt(index); } OnItemRemove?.Invoke(obj, amount); } }
/// <summary> /// Removes an item from the inventory /// </summary> /// <param name="name">The name of the item</param> /// <param name="amount">The amount to remove</param> public void Remove(string name, int amount) { var index = entities.FindIndex(e => e.name == name); if (index > -1) { var entity = entities[index]; quantities[index] -= amount; if (quantities[index] < 1) { quantities.RemoveAt(index); entities.RemoveAt(index); } OnItemRemove?.Invoke(entity, amount); } }
public bool RemoveItem(ItemStats item) { for (int i = 0, n = slots.Count; i < n; i++) { if (slots[i].IsEmpty) { continue; } if (slots[i].StoredItem.Type != item.Type) { continue; } slots[i].RemoveStackPortion(1); OnItemRemove?.Invoke(item, 1); return(true); } return(false); }
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (OnItemRemove != null && e.OldItems != null) { foreach (var item in e.OldItems.Cast <TItem>()) { OnItemRemove?.Invoke(item); } } if (OnItemAdd != null && e.NewItems != null) { foreach (var item in e.NewItems.Cast <TItem>()) { OnItemAdd?.Invoke(item); } } if (!SuppressNotification) { base.OnCollectionChanged(e); } }