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


C# InventoryManager.GiveItem方法代码示例

本文整理汇总了C#中InventoryManager.GiveItem方法的典型用法代码示例。如果您正苦于以下问题:C# InventoryManager.GiveItem方法的具体用法?C# InventoryManager.GiveItem怎么用?C# InventoryManager.GiveItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InventoryManager的用法示例。


在下文中一共展示了InventoryManager.GiveItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 2)
            {
                return "Usage: give <agent uuid> itemname";
            }
            UUID dest;
            if (!UUID.TryParse(args[0], out dest))
            {
                return "First argument expected agent UUID.";
            }
            Manager = Client.Inventory;
            Inventory = Manager.Store;
            string ret = "";
            string nl = "\n";

            string target = String.Empty;
            for (int ct = 0; ct < args.Length; ct++)
                target = target + args[ct] + " ";
            target = target.TrimEnd();

            string inventoryName = target;
            // WARNING: Uses local copy of inventory contents, need to download them first.
            List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
            bool found = false;
            foreach (InventoryBase b in contents)
            {
                if (inventoryName == b.Name || inventoryName == b.UUID.ToString())
                {
                    found = true;
                    if (b is InventoryItem)
                    {
                        InventoryItem item = b as InventoryItem;
                        Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true);
                        ret += "Gave " + item.Name + " (" + item.AssetType + ")" + nl;
                    }
                    else
                    {
                        ret += "Unable to give folder " + b.Name + nl;
                    }
                }
            }
            if (!found)
                ret += "No inventory item named " + inventoryName + " found." + nl;

            return ret;
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:47,代码来源:GiveItemCommand.cs

示例2: Execute

 public override string Execute(string[] args, Guid fromAgentID)
 {
     if (args.Length < 2)
     {
         return "Usage: give <agent Guid> <item1> [item2] [item3] [...]";
     }
     Guid dest;
     if (!GuidExtensions.TryParse(args[0], out dest))
     {
         return "First argument expected agent Guid.";
     }
     Manager = Client.Inventory;
     Inventory = Manager.Store;
     string ret = "";
     string nl = "\n";
     for (int i = 1; i < args.Length; ++i)
     {
         string inventoryName = args[i];
         // WARNING: Uses local copy of inventory contents, need to download them first.
         List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
         bool found = false;
         foreach (InventoryBase b in contents)
         {
             if (inventoryName == b.Name || inventoryName == b.Guid.ToString())
             {
                 found = true;
                 if (b is InventoryItem)
                 {
                     InventoryItem item = b as InventoryItem;
                     Manager.GiveItem(item.Guid, item.Name, item.AssetType, dest, true);
                     ret += "Gave " + item.Name + nl;
                 }
                 else
                 {
                     ret += "Unable to give folder " + b.Name + nl;
                 }
             }
         }
         if (!found)
             ret += "No inventory item named " + inventoryName + " found." + nl;
     }
     return ret;
 }
开发者ID:RavenB,项目名称:gridsearch,代码行数:43,代码来源:GiveItemCommand.cs


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