本文整理汇总了C#中WhiteCore.Framework.Services.ClassHelpers.Inventory.InventoryItemBase.FromOSD方法的典型用法代码示例。如果您正苦于以下问题:C# InventoryItemBase.FromOSD方法的具体用法?C# InventoryItemBase.FromOSD怎么用?C# InventoryItemBase.FromOSD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhiteCore.Framework.Services.ClassHelpers.Inventory.InventoryItemBase
的用法示例。
在下文中一共展示了InventoryItemBase.FromOSD方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromOSD
public override void FromOSD(OSDMap map)
{
OSDArray items = (OSDArray) map["Items"];
Items = items.ConvertAll<InventoryItemBase>((osd) =>
{
InventoryItemBase item = new InventoryItemBase();
item.FromOSD((OSDMap) osd);
return item;
}
);
OSDArray folders = (OSDArray) map["Folders"];
Folders = folders.ConvertAll<InventoryFolderBase>((osd) =>
{
InventoryFolderBase folder =
new InventoryFolderBase();
folder.FromOSD((OSDMap) osd);
return folder;
}
);
UserID = map["UserID"];
FolderID = map["FolderID"];
}
示例2: CopyWearablesAndAttachments
AvatarAppearance CopyWearablesAndAttachments (UUID destination, UUID source,
AvatarAppearance avatarAppearance,
InventoryFolderBase destinationFolder, UUID agentid,
OSDMap itemsMap,
out List<InventoryItemBase> items)
{
items = new List<InventoryItemBase> ();
if (destinationFolder == null) {
MainConsole.Instance.Error ("[Avatar Archiver]: Cannot locate folder(s) for copying wearables!");
return avatarAppearance;
}
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 ("[Avatar Archiver]: Loading item " + item.ID);
litems.Add (item);
}
// Wearables
AvatarWearable [] wearables = avatarAppearance.Wearables;
MainConsole.Instance.InfoFormat ("[Avatar Archiver] Adding {0} wearables", wearables.Length);
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 ("[Avatar Archiver]: 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 ("[Avatar Archiver]: Unable to transfer {0} to folder {1}",
wearable [ii].ItemID, destinationFolder.ID);
}
}
}
}
// Attachments
List<AvatarAttachment> attachments = avatarAppearance.GetAttachments ();
MainConsole.Instance.InfoFormat ("[Avatar Archiver] Adding {0} attachments", attachments.Count);
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) {
//Attempt to get from the map if it doesn't already exist on the grid
item = litems.First ((itm) => itm.ID == itemID);
}
if (item != null) {
InventoryItemBase destinationItem = inventoryService.InnerGiveInventoryItem (destination,
destination, item,
destinationFolder.ID,
false, false);
items.Add (destinationItem);
MainConsole.Instance.DebugFormat ("[Avatar Archiver]: Added item {0} to folder {1}", destinationItem.ID,
destinationFolder.ID);
// Attach item
avatarAppearance.SetAttachment (attachpoint, destinationItem.ID, destinationItem.AssetID);
MainConsole.Instance.DebugFormat ("[Avatar Archiver]: Attached {0}", destinationItem.ID);
} else {
MainConsole.Instance.WarnFormat ("[Avatar Archiver]: Error transferring {0} to folder {1}", itemID,
destinationFolder.ID);
}
}
}
return avatarAppearance;
}