当前位置: 首页>>代码示例>>C#>>正文


C# IWindow.MoveToAlternateArea方法代码示例

本文整理汇总了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;
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:83,代码来源:Window.cs


注:本文中的IWindow.MoveToAlternateArea方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。