using BlazorApp1.Models; using Microsoft.AspNetCore.Components; namespace BlazorApp1.Components { public partial class InventoryItem { [Parameter] public int Index { get; set; } [Parameter] public Item Item { get; set; } [Parameter] public bool NoDrop { get; set; } [CascadingParameter] public InventoryComponent Parent { get; set; } internal void OnDragEnter() { if (NoDrop) { return; } Parent.Actions.Add(new CraftingAction { Action = "Drag Enter", Item = this.Item, Index = this.Index }); } internal void OnDragLeave() { if (NoDrop) { return; } Parent.Actions.Add(new CraftingAction { Action = "Drag Leave", Item = this.Item, Index = this.Index }); } internal void OnDrop() { Item CurrentHoldItem = new Item();//A remplir avec les valeurs de CurrentDragItem //CurrentHoldItem = Parent.CurrentDragItem; if (NoDrop) { return; } if (this.Item != null) { if (this.Item.Name == CurrentHoldItem.Name) { CurrentHoldItem.Stack = CurrentHoldItem.Stack + this.Item.Stack; this.Item = CurrentHoldItem; } else { return; } } else { this.Item = CurrentHoldItem; Parent.Actions.Add(new CraftingAction { Action = "Drop", Item = this.Item, Index = this.Index }); } } private void OnDragStart() { Parent.CurrentDragItem = this.Item; Parent.Actions.Add(new CraftingAction { Action = "Drag Start", Item = this.Item, Index = this.Index }); } } }