本文整理汇总了C#中IWindow.MoveToAlternateArea方法的典型用法代码示例。如果您正苦于以下问题:C# IWindow.MoveToAlternateArea方法的具体用法?C# IWindow.MoveToAlternateArea怎么用?C# IWindow.MoveToAlternateArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWindow
的用法示例。
在下文中一共展示了IWindow.MoveToAlternateArea方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleClickPacket
public static void HandleClickPacket(ClickWindowPacket packet, IWindow window, ref ItemStack itemStaging)
{
if (packet.SlotIndex >= window.Length || packet.SlotIndex < 0)
return;
var existing = window[packet.SlotIndex];
if (window.ReadOnlySlots.Contains(packet.SlotIndex))
{
if (itemStaging.ID == existing.ID || itemStaging.Empty)
{
if (itemStaging.Empty)
itemStaging = existing;
else
itemStaging.Count += existing.Count;
window[packet.SlotIndex] = ItemStack.EmptyStack;
}
return;
}
if (itemStaging.Empty) // Picking up something
{
if (packet.Shift)
{
window.MoveToAlternateArea(packet.SlotIndex);
}
else
{
if (packet.RightClick)
{
sbyte mod = (sbyte)(existing.Count % 2);
existing.Count /= 2;
itemStaging = existing;
itemStaging.Count += mod;
window[packet.SlotIndex] = existing;
}
else
{
itemStaging = window[packet.SlotIndex];
window[packet.SlotIndex] = ItemStack.EmptyStack;
}
}
}
else // Setting something down
{
if (existing.Empty) // Replace empty slot
{
if (packet.RightClick)
{
var newItem = (ItemStack)itemStaging.Clone();
newItem.Count = 1;
itemStaging.Count--;
window[packet.SlotIndex] = newItem;
}
else
{
window[packet.SlotIndex] = itemStaging;
itemStaging = ItemStack.EmptyStack;
}
}
else
{
if (existing.CanMerge(itemStaging)) // Merge items
{
// TODO: Consider the maximum stack size
if (packet.RightClick)
{
existing.Count++;
itemStaging.Count--;
window[packet.SlotIndex] = existing;
}
else
{
existing.Count += itemStaging.Count;
window[packet.SlotIndex] = existing;
itemStaging = ItemStack.EmptyStack;
}
}
else // Swap items
{
window[packet.SlotIndex] = itemStaging;
itemStaging = existing;
}
}
}
}