本文整理汇总了C#中InventoryItemBase.FromOSD方法的典型用法代码示例。如果您正苦于以下问题:C# InventoryItemBase.FromOSD方法的具体用法?C# InventoryItemBase.FromOSD怎么用?C# InventoryItemBase.FromOSD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryItemBase
的用法示例。
在下文中一共展示了InventoryItemBase.FromOSD方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyWearablesAndAttachments
private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source,
AvatarAppearance avatarAppearance,
InventoryFolderBase destinationFolder, UUID agentid,
OSDMap itemsMap,
out List<InventoryItemBase> items)
{
if (destinationFolder == null)
throw new Exception("Cannot locate folder(s)");
items = new List<InventoryItemBase>();
List<InventoryItemBase> litems = new List<InventoryItemBase>();
foreach (KeyValuePair<string, OSD> kvp in itemsMap)
{
InventoryItemBase item = new InventoryItemBase();
item.FromOSD((OSDMap)kvp.Value);
MainConsole.Instance.Info("[AvatarArchive]: Loading item " + item.ID.ToString());
litems.Add(item);
}
// Wearables
AvatarWearable[] wearables = avatarAppearance.Wearables;
for (int i = 0; i < wearables.Length; i++)
{
AvatarWearable wearable = wearables[i];
for (int ii = 0; ii < wearable.Count; ii++)
{
if (wearable[ii].ItemID != UUID.Zero)
{
// Get inventory item and copy it
InventoryItemBase item = InventoryService.GetItem(UUID.Zero, wearable[ii].ItemID);
if (item == null)
{
//Attempt to get from the map if it doesn't already exist on the grid
item = litems.First((itm) => itm.ID == wearable[ii].ItemID);
}
if (item != null)
{
InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination,
destination,
item,
destinationFolder
.ID,
false, false);
items.Add(destinationItem);
MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}",
destinationItem.ID, destinationFolder.ID);
// Wear item
AvatarWearable newWearable = new AvatarWearable();
newWearable.Wear(destinationItem.ID, destinationItem.AssetID);
avatarAppearance.SetWearable(i, newWearable);
}
else
{
MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}",
wearable[ii].ItemID, destinationFolder.ID);
}
}
}
}
// Attachments
List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
foreach (AvatarAttachment attachment in attachments)
{
int attachpoint = attachment.AttachPoint;
UUID itemID = attachment.ItemID;
if (itemID != UUID.Zero)
{
// Get inventory item and copy it
InventoryItemBase item = InventoryService.GetItem(UUID.Zero, itemID);
if (item != null)
{
InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination,
destination, item,
destinationFolder.ID,
false, false);
items.Add(destinationItem);
MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID,
destinationFolder.ID);
// Attach item
avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
}
else
{
MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID,
destinationFolder.ID);
}
}
}
return avatarAppearance;
}
示例2: LoadItems
private void LoadItems(OSDMap items, UUID OwnerID, InventoryFolderBase folderForAppearance,
out List<InventoryItemBase> litems)
{
litems = new List<InventoryItemBase>();
foreach (KeyValuePair<string, OSD> kvp in items)
{
InventoryItemBase item = new InventoryItemBase();
item.FromOSD((OSDMap)kvp.Value);
MainConsole.Instance.Info("[AvatarArchive]: Loading item " + item.ID.ToString());
item = GiveInventoryItem(item.CreatorIdAsUuid, OwnerID, item, folderForAppearance);
litems.Add(item);
}
}