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; } [Parameter] public int Stack { 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() { if (NoDrop) { return; } if (this.Item != null) { if (this.Item.Name == Parent.CurrentDragItem.Name) { this.Stack = this.Stack + 1; } else { return; } } else { this.Item = Parent.CurrentDragItem; 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 }); } } }