You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.9 KiB

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 });
}
}
}