|
|
@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
using Blazor.Models;
|
|
|
|
|
|
|
|
using Blazorise.Extensions;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Blazor.Components
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public partial class ItemInventory
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
|
|
public bool NoDrop { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
|
|
public InventoryItem Items { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
|
|
public int Index { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[CascadingParameter]
|
|
|
|
|
|
|
|
public Inventory Parent { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnDragStart()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!NoDrop)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Parent.CurrentDragItem = null;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Parent.CurrentDragItem = this.Items;
|
|
|
|
|
|
|
|
Parent.inventory.inventoryItems[this.Index] = null;
|
|
|
|
|
|
|
|
this.NoDrop = false;
|
|
|
|
|
|
|
|
Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this));
|
|
|
|
|
|
|
|
Parent.update();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnDrop()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!NoDrop)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.Items = Parent.CurrentDragItem;
|
|
|
|
|
|
|
|
NoDrop = true;
|
|
|
|
|
|
|
|
Parent.CurrentDragItem = null;
|
|
|
|
|
|
|
|
Parent.Actions.Add(new InventoryAction("On Drop",this.Index,this));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(Parent.CurrentDragItem == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Parent.CurrentDragItem.item.Id != this.Items.item.Id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.Items = Parent.CurrentDragItem;
|
|
|
|
|
|
|
|
this.NoDrop= true;
|
|
|
|
|
|
|
|
Parent.CurrentDragItem = null;
|
|
|
|
|
|
|
|
Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int total = Parent.CurrentDragItem.Stack + this.Items.Stack;
|
|
|
|
|
|
|
|
if (total >this.Items.item.StackSize)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.Items.Stack = this.Items.item.StackSize;
|
|
|
|
|
|
|
|
Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.Items.Stack = total;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
internal void OnDragEnter()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Parent.Actions.Add(new InventoryAction("Drag Enter",this.Index,this));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal void OnDragLeave()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Parent.Actions.Add(new InventoryAction("Drag Leave",this.Index,this));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|