本文整理汇总了C#中WhiteCore.Framework.Services.ClassHelpers.Inventory.InventoryItemBase类的典型用法代码示例。如果您正苦于以下问题:C# InventoryItemBase类的具体用法?C# InventoryItemBase怎么用?C# InventoryItemBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InventoryItemBase类属于WhiteCore.Framework.Services.ClassHelpers.Inventory命名空间,在下文中一共展示了InventoryItemBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCacheItemAsync
public void AddCacheItemAsync(InventoryItemBase item)
{
if (item == null)
return;
lock (_tempItemCache)
{
if (!_tempItemCache.ContainsKey(item.ID))
_tempItemCache.Add(item.ID, item);
}
//_addInventoryItemQueue.Add(item.Owner, new AddInventoryItemStore(item, success));
}
示例2: Deserialize
/// <summary>
/// Deserialize item
/// </summary>
/// <param name="serialization"></param>
/// <returns></returns>
/// <exception cref="System.Xml.XmlException"></exception>
public static InventoryItemBase Deserialize(byte[] serialization)
{
InventoryItemBase item = new InventoryItemBase();
StringReader reader = new StringReader(Encoding.ASCII.GetString(serialization, 0, serialization.Length));
XmlReader xtr = XmlReader.Create(reader);
//Uses byte[] directly... should be used once issues with it are fixed
//MemoryStream mr = new MemoryStream (serialization);
//StreamReader sr = new StreamReader (mr, Encoding.ASCII);
//XmlReader xtr = XmlTextReader.Create (sr);
xtr.ReadStartElement("InventoryItem");
item.Name = xtr.ReadElementString("Name");
item.ID = UUID.Parse(xtr.ReadElementString("ID"));
item.InvType = Convert.ToInt32(xtr.ReadElementString("InvType"));
item.CreatorId = xtr.ReadElementString("CreatorUUID");
try
{
item.CreatorData = xtr.ReadElementString("CreatorData");
}
catch
{
}
item.CreationDate = Convert.ToInt32(xtr.ReadElementString("CreationDate"));
item.Owner = UUID.Parse(xtr.ReadElementString("Owner"));
item.Description = xtr.ReadElementString("Description");
item.AssetType = Convert.ToInt32(xtr.ReadElementString("AssetType"));
item.AssetID = UUID.Parse(xtr.ReadElementString("AssetID"));
item.SaleType = Convert.ToByte(xtr.ReadElementString("SaleType"));
item.SalePrice = Convert.ToInt32(xtr.ReadElementString("SalePrice"));
item.BasePermissions = Convert.ToUInt32(xtr.ReadElementString("BasePermissions"));
item.CurrentPermissions = Convert.ToUInt32(xtr.ReadElementString("CurrentPermissions"));
item.EveryOnePermissions = Convert.ToUInt32(xtr.ReadElementString("EveryOnePermissions"));
item.NextPermissions = Convert.ToUInt32(xtr.ReadElementString("NextPermissions"));
item.Flags = Convert.ToUInt32(xtr.ReadElementString("Flags"));
item.GroupID = UUID.Parse(xtr.ReadElementString("GroupID"));
item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned"));
xtr.ReadEndElement();
xtr.Close();
return item;
}
示例3: 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"];
}
示例4: UpdateItem
public virtual bool UpdateItem(InventoryItemBase item)
{
object remoteValue = DoRemoteByURL("InventoryServerURI", item);
if (remoteValue != null || m_doRemoteOnly)
return remoteValue == null ? false : (bool) remoteValue;
if (!m_AllowDelete) //Initial item MUST be created as a link or link folder
if (item.AssetType == (sbyte) AssetType.Link || item.AssetType == (sbyte) AssetType.LinkFolder)
return false;
m_Database.IncrementFolder(item.Folder);
return m_Database.StoreItem(item);
}
示例5: Serialize
public static string Serialize(InventoryItemBase inventoryItem)
{
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw) {Formatting = Formatting.Indented};
writer.WriteStartDocument();
writer.WriteStartElement("InventoryItem");
writer.WriteStartElement("Name");
writer.WriteString(inventoryItem.Name);
writer.WriteEndElement();
writer.WriteStartElement("ID");
writer.WriteString(inventoryItem.ID.ToString());
writer.WriteEndElement();
writer.WriteStartElement("InvType");
writer.WriteString(inventoryItem.InvType.ToString());
writer.WriteEndElement();
writer.WriteStartElement("CreatorUUID");
writer.WriteString(inventoryItem.CreatorId);
writer.WriteEndElement();
writer.WriteStartElement("CreatorData");
writer.WriteString(inventoryItem.CreatorData);
writer.WriteEndElement();
writer.WriteStartElement("CreationDate");
writer.WriteString(inventoryItem.CreationDate.ToString());
writer.WriteEndElement();
writer.WriteStartElement("Owner");
writer.WriteString(inventoryItem.Owner.ToString());
writer.WriteEndElement();
writer.WriteStartElement("Description");
writer.WriteString(inventoryItem.Description);
writer.WriteEndElement();
writer.WriteStartElement("AssetType");
writer.WriteString(inventoryItem.AssetType.ToString());
writer.WriteEndElement();
writer.WriteStartElement("AssetID");
writer.WriteString(inventoryItem.AssetID.ToString());
writer.WriteEndElement();
writer.WriteStartElement("SaleType");
writer.WriteString(inventoryItem.SaleType.ToString());
writer.WriteEndElement();
writer.WriteStartElement("SalePrice");
writer.WriteString(inventoryItem.SalePrice.ToString());
writer.WriteEndElement();
writer.WriteStartElement("BasePermissions");
writer.WriteString(inventoryItem.BasePermissions.ToString());
writer.WriteEndElement();
writer.WriteStartElement("CurrentPermissions");
writer.WriteString(inventoryItem.CurrentPermissions.ToString());
writer.WriteEndElement();
writer.WriteStartElement("EveryOnePermissions");
writer.WriteString(inventoryItem.EveryOnePermissions.ToString());
writer.WriteEndElement();
writer.WriteStartElement("NextPermissions");
writer.WriteString(inventoryItem.NextPermissions.ToString());
writer.WriteEndElement();
writer.WriteStartElement("Flags");
writer.WriteString(inventoryItem.Flags.ToString());
writer.WriteEndElement();
writer.WriteStartElement("GroupID");
writer.WriteString(inventoryItem.GroupID.ToString());
writer.WriteEndElement();
writer.WriteStartElement("GroupOwned");
writer.WriteString(inventoryItem.GroupOwned.ToString());
writer.WriteEndElement();
writer.WriteEndElement();
writer.Close();
return sw.ToString();
}
示例6: HandleFetchInventory
/// <summary>
/// Handle a fetch inventory request from the client
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="ownerID"></param>
protected void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
{
//MainConsole.Instance.Warn("[Scene.PacketHandler]: Deprecated UDP Inventory request!");
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item);
if (item != null)
{
remoteClient.SendInventoryItemDetails(ownerID, item);
}
// else shouldn't we send an alert message?
}
示例7: 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;
}
示例8: RezMultipleObjectsFromInventory
private List<ISceneEntity> RezMultipleObjectsFromInventory(XmlNodeList nodes, UUID itemId,
IClientAPI remoteClient, Vector3 pos,
bool RezSelected,
InventoryItemBase item, UUID RayTargetID,
byte BypassRayCast, bool RayEndIsIntersection,
Vector3 RayEnd, Vector3 RayStart,
byte bRayEndIsIntersection)
{
Vector3 OldMiddlePos = Vector3.Zero;
List<ISceneEntity> NewGroup = new List<ISceneEntity>();
foreach (XmlNode aPrimNode in nodes)
{
if (aPrimNode.OuterXml.StartsWith("<middle>"))
{
string Position = aPrimNode.OuterXml.Remove(0, 13);
Position = Position.Remove(Position.Length - 16, 16);
string[] XYZ = Position.Split(' ');
OldMiddlePos = new Vector3(float.Parse(XYZ[0]), float.Parse(XYZ[1]), float.Parse(XYZ[2]));
continue;
}
ISceneEntity group
= SceneEntitySerializer.SceneObjectSerializer.FromOriginalXmlFormat(aPrimNode.OuterXml, m_scene);
if (group == null)
return null;
group.IsDeleted = false;
foreach (ISceneChildEntity part in group.ChildrenEntities())
{
part.IsLoading = false;
}
NewGroup.Add(group);
string reason;
if (!m_scene.Permissions.CanRezObject(
group.ChildrenEntities().Count, remoteClient.AgentId, pos, out reason))
{
// The client operates in no fail mode. It will
// have already removed the item from the folder
// if it's no copy.
// Put it back if it's not an attachment
//
if (((item.CurrentPermissions & (uint) PermissionMask.Copy) == 0))
remoteClient.SendBulkUpdateInventory(item);
return null;
}
if (RezSelected)
group.RootChild.AddFlag(PrimFlags.CreateSelected);
// If we're rezzing an attachment then don't ask AddNewSceneObject() to update the client since
// we'll be doing that later on. Scheduling more than one full update during the attachment
// process causes some clients to fail to display the attachment properly.
m_scene.SceneGraph.AddPrimToScene(group);
// MainConsole.Instance.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
// if attachment we set it's asset id so object updates can reflect that
// if not, we set it's position in world.
float offsetHeight = 0;
pos = m_scene.SceneGraph.GetNewRezLocation(
RayStart, RayEnd, RayTargetID, Quaternion.Identity,
BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
pos.Z += offsetHeight;
//group.AbsolutePosition = pos;
// MainConsole.Instance.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
ISceneChildEntity rootPart = group.GetChildPart(group.UUID);
// Since renaming the item in the inventory does not affect the name stored
// in the serialization, transfer the correct name from the inventory to the
// object itself before we rez.
if (NewGroup.Count == 1)
{
//Only do this to the first object, as it is the only one that will need to be renamed
rootPart.Name = item.Name;
rootPart.Description = item.Description;
}
List<ISceneChildEntity> partList = group.ChildrenEntities();
group.SetGroup(remoteClient.ActiveGroupId, remoteClient.AgentId, false);
item.Owner = remoteClient.AgentId;
if (rootPart.OwnerID != item.Owner)
{
//Need to kill the for sale here
rootPart.ObjectSaleType = 0;
rootPart.SalePrice = 10;
if (m_scene.Permissions.PropagatePermissions())
{
if ((item.CurrentPermissions & 8) != 0)
{
foreach (ISceneChildEntity part in partList)
{
part.EveryoneMask = item.EveryOnePermissions;
part.NextOwnerMask = item.NextPermissions;
part.GroupMask = 0; // DO NOT propagate here
}
}
group.ApplyNextOwnerPermissions();
//.........这里部分代码省略.........
示例9: CreateObjectFromInventory
protected virtual ISceneEntity CreateObjectFromInventory(InventoryItemBase item, IClientAPI remoteClient,
UUID itemID, out XmlDocument doc)
{
UUID itemId = UUID.Zero;
// If we have permission to copy then link the rezzed object back to the user inventory
// item that it came from. This allows us to enable 'save object to inventory'
if (!m_scene.Permissions.BypassPermissions())
{
if ((item.CurrentPermissions & (uint) PermissionMask.Copy) == (uint) PermissionMask.Copy)
{
itemId = item.ID;
}
}
else
{
// Brave new fullperm world
//
itemId = item.ID;
}
return CreateObjectFromInventory(remoteClient, itemId, item.AssetID, out doc, item);
}
示例10: DeleteToInventory
/// <summary>
/// Delete a scene object from a scene and place in the given avatar's inventory.
/// Returns the UUID of the newly created asset.
/// </summary>
/// <param name="action"></param>
/// <param name="folderID"></param>
/// <param name="objectGroups"></param>
/// <param name="agentId"></param>
/// <param name="itemID"></param>
public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
List<ISceneEntity> objectGroups, UUID agentId, out UUID itemID)
{
itemID = UUID.Zero;
if (objectGroups.Count == 0)
return UUID.Zero;
// Get the user info of the item destination
//
IScenePresence SP = m_scene.GetScenePresence(agentId);
UUID userID = UUID.Zero;
if (action == DeRezAction.Take || action == DeRezAction.AcquireToUserInventory ||
action == DeRezAction.SaveToExistingUserInventoryItem)
{
// Take or take copy require a taker
// Saving changes requires a local user
//
if (SP == null || SP.ControllingClient == null)
return UUID.Zero;
userID = agentId;
}
else
{
// All returns / deletes go to the object owner
//
userID = objectGroups[0].OwnerID;
}
if (userID == UUID.Zero) // Can't proceed
{
return UUID.Zero;
}
// If we're returning someone's item, it goes back to the
// owner's Lost And Found folder.
// Delete is treated like return in this case
// Deleting your own items makes them go to trash
//
InventoryFolderBase folder = null;
InventoryItemBase item = null;
if (DeRezAction.SaveToExistingUserInventoryItem == action)
{
item = m_scene.InventoryService.GetItem(userID, objectGroups[0].RootChild.FromUserInventoryItemID);
//item = userInfo.RootFolder.FindItem(
// objectGroup.RootPart.FromUserInventoryItemID);
if (null == item)
{
MainConsole.Instance.DebugFormat(
"[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
objectGroups[0].Name, objectGroups[0].UUID);
return UUID.Zero;
}
}
else
{
// Folder magic
//
if (action == DeRezAction.Delete)
{
// Deleting someone else's item
//
if (SP == null || SP.ControllingClient == null ||
objectGroups[0].OwnerID != agentId)
{
folder = m_scene.InventoryService.GetFolderForType(userID, InventoryType.Unknown,
AssetType.LostAndFoundFolder);
}
else
{
folder = m_scene.InventoryService.GetFolderForType(userID, InventoryType.Unknown,
AssetType.TrashFolder);
}
}
else if (action == DeRezAction.Return)
{
// Dump to lost + found unconditionally
//
folder = m_scene.InventoryService.GetFolderForType(userID, InventoryType.Unknown,
AssetType.LostAndFoundFolder);
}
if (folderID == UUID.Zero && folder == null)
{
//.........这里部分代码省略.........
示例11: AddInventoryItem
/// <summary>
/// Add an inventory item to a prim in this group.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="localID"></param>
/// <param name="item"></param>
/// <param name="copyItemID">The item UUID that should be used by the new item.</param>
/// <returns></returns>
public bool AddInventoryItem(IClientAPI remoteClient, uint localID,
InventoryItemBase item, UUID copyItemID)
{
UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID;
SceneObjectPart part = (SceneObjectPart) GetChildPart(localID);
if (part != null)
{
TaskInventoryItem taskItem = new TaskInventoryItem
{
ItemID = newItemId,
AssetID = item.AssetID,
Name = item.Name,
Description = item.Description,
OwnerID = part.OwnerID,
CreatorID = item.CreatorIdAsUuid,
Type = item.AssetType,
InvType = item.InvType
};
// Transfer ownership
if (remoteClient != null &&
remoteClient.AgentId != part.OwnerID &&
m_scene.Permissions.PropagatePermissions())
{
taskItem.BasePermissions = item.BasePermissions &
item.NextPermissions;
taskItem.CurrentPermissions = item.CurrentPermissions &
item.NextPermissions;
taskItem.EveryonePermissions = item.EveryOnePermissions &
item.NextPermissions;
taskItem.GroupPermissions = item.GroupPermissions &
item.NextPermissions;
taskItem.NextPermissions = item.NextPermissions;
// We're adding this to a prim we don't own. Force
// owner change
taskItem.CurrentPermissions |= 16; // Slam
}
else
{
taskItem.BasePermissions = item.BasePermissions;
taskItem.CurrentPermissions = item.CurrentPermissions;
taskItem.EveryonePermissions = item.EveryOnePermissions;
taskItem.GroupPermissions = item.GroupPermissions;
taskItem.NextPermissions = item.NextPermissions;
}
taskItem.Flags = item.Flags;
taskItem.SalePrice = item.SalePrice;
taskItem.SaleType = item.SaleType;
taskItem.CreationDate = (uint) item.CreationDate;
bool addFromAllowedDrop = false;
if (remoteClient != null)
{
addFromAllowedDrop = remoteClient.AgentId != part.OwnerID;
}
part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
return true;
}
MainConsole.Instance.ErrorFormat(
"[PRIM INVENTORY]: " +
"Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}",
localID, Name, UUID, newItemId);
return false;
}
示例12: AddItem
public virtual bool AddItem(InventoryItemBase item, bool doParentFolderCheck)
{
if (doParentFolderCheck)
{
InventoryFolderBase folder = GetFolder(new InventoryFolderBase(item.Folder));
if (folder == null || folder.Owner != item.Owner)
{
MainConsole.Instance.DebugFormat ("[InventoryService]: Aborting adding item as folder {0} does not exist or is not the owner's",folder);
return false;
}
}
m_Database.IncrementFolder(item.Folder);
bool success = m_Database.StoreItem(item);
if (!success)
MainConsole.Instance.DebugFormat ("[InventoryService]: Failed to save item {0} in folder {1}",item.Name,item.Folder);
else
MainConsole.Instance.DebugFormat ("[InventoryService]: Saved item {0} in folder {1}",item.Name,item.Folder);
return success;
}
示例13: InnerGiveInventoryItem
public InventoryItemBase InnerGiveInventoryItem(
UUID recipient, UUID senderId, InventoryItemBase item, UUID recipientFolderId, bool doOwnerCheck, bool checkTransferPermission)
{
if (item == null)
{
MainConsole.Instance.Info("[InventoryService]: Could not find item to give to " + recipient);
return null;
}
if (!doOwnerCheck || item.Owner == senderId)
{
if (checkTransferPermission)
{
if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
{
MainConsole.Instance.WarnFormat (
"[InventoryService]: Inventory copy of {0} aborted due to permissions: Sender {1}, recipient {2}",
item.AssetID, senderId, recipient);
return null;
}
}
// Insert a copy of the item into the recipient
InventoryItemBase itemCopy = new InventoryItemBase
{
Owner = recipient,
CreatorId = item.CreatorId,
CreatorData = item.CreatorData,
ID = UUID.Random(),
AssetID = item.AssetID,
Description = item.Description,
Name = item.Name,
AssetType = item.AssetType,
InvType = item.InvType,
Folder = recipientFolderId
};
if (recipient != senderId)
{
// Trying to do this right this time. This is evil. If
// you believe in Good, go elsewhere. Vampires and other
// evil creatores only beyond this point. You have been
// warned.
// We're going to mask a lot of things by the next perms
// Tweak the next perms to be nicer to our data
//
// In this mask, all the bits we do NOT want to mess
// with are set. These are:
//
// Transfer
// Copy
// Modufy
const uint permsMask = ~((uint) PermissionMask.Copy |
(uint) PermissionMask.Transfer |
(uint) PermissionMask.Modify);
// Now, reduce the next perms to the mask bits
// relevant to the operation
uint nextPerms = permsMask | (item.NextPermissions &
((uint) PermissionMask.Copy |
(uint) PermissionMask.Transfer |
(uint) PermissionMask.Modify));
// nextPerms now has all bits set, except for the actual
// next permission bits.
// This checks for no mod, no copy, no trans.
// This indicates an error or messed up item. Do it like
// SL and assume trans
if (nextPerms == permsMask)
nextPerms |= (uint) PermissionMask.Transfer;
// Inventory owner perms are the logical AND of the
// folded perms and the root prim perms, however, if
// the root prim is mod, the inventory perms will be
// mod. This happens on "take" and is of little concern
// here, save for preventing escalation
// This hack ensures that items previously permalocked
// get unlocked when they're passed or rezzed
uint basePerms = item.BasePermissions |
(uint) PermissionMask.Move;
uint ownerPerms = item.CurrentPermissions;
// If this is an object, root prim perms may be more
// permissive than folded perms. Use folded perms as
// a mask
if (item.InvType == (int) InventoryType.Object)
{
// Create a safe mask for the current perms
uint foldedPerms = (item.CurrentPermissions & 7) << 13;
foldedPerms |= permsMask;
bool isRootMod = (item.CurrentPermissions &
(uint) PermissionMask.Modify) != 0;
// Mask the owner perms to the folded perms
ownerPerms &= foldedPerms;
basePerms &= foldedPerms;
//.........这里部分代码省略.........
示例14: AvatarIsWearing
/// <summary>
/// Update what the avatar is wearing using an item from their inventory.
/// </summary>
/// <param name="client"></param>
/// <param name="e"></param>
public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
{
IScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
MainConsole.Instance.WarnFormat("[AvatarFactory]: AvatarIsWearing unable to find presence for {0}",
client.AgentId);
return;
}
MainConsole.Instance.DebugFormat("[AvatarFactory]: AvatarIsWearing called for {0}", client.AgentId);
// operate on a copy of the appearance so we don't have to lock anything
IAvatarAppearanceModule appearance = sp.RequestModuleInterface<IAvatarAppearanceModule>();
AvatarAppearance avatAppearance = new AvatarAppearance(appearance.Appearance, false);
#region Teen Mode Stuff
IOpenRegionSettingsModule module = m_scene.RequestModuleInterface<IOpenRegionSettingsModule>();
bool NeedsRebake = false;
if (module != null && module.EnableTeenMode)
{
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
{
if (wear.Type == 10 & wear.ItemID == UUID.Zero && module.DefaultUnderpants != UUID.Zero)
{
NeedsRebake = true;
wear.ItemID = module.DefaultUnderpants;
InventoryItemBase item = new InventoryItemBase(UUID.Random())
{
InvType = (int)InventoryType.Wearable,
AssetType = (int)AssetType.Clothing,
Name = "Default Underpants",
Folder =
m_scene.InventoryService.GetFolderForType(client.AgentId,
InventoryType.
Wearable,
AssetType.
Clothing).ID,
Owner = client.AgentId,
CurrentPermissions = 0,
CreatorId = UUID.Zero.ToString(),
AssetID = module.DefaultUnderpants
};
//Locked
client.SendInventoryItemCreateUpdate(item, 0);
}
else if (wear.Type == 10 & wear.ItemID == UUID.Zero)
{
NeedsRebake = true;
InventoryItemBase item = new InventoryItemBase(UUID.Random())
{
InvType = (int)InventoryType.Wearable,
AssetType = (int)AssetType.Clothing,
Name = "Default Underpants",
Folder =
m_scene.InventoryService.GetFolderForType(client.AgentId,
InventoryType.
Wearable,
AssetType.
Clothing).ID,
Owner = client.AgentId,
CurrentPermissions = 0
};
//Locked
if (m_underPantsUUID == UUID.Zero)
{
m_underPantsUUID = UUID.Random();
AssetBase asset = new AssetBase(m_underPantsUUID, "Default Underpants", AssetType.Clothing,
UUID.Zero) { Data = Utils.StringToBytes(m_defaultUnderPants) };
asset.ID = m_scene.AssetService.Store(asset);
m_underPantsUUID = asset.ID;
}
item.CreatorId = UUID.Zero.ToString();
item.AssetID = m_underPantsUUID;
m_scene.InventoryService.AddItemAsync(item, null);
client.SendInventoryItemCreateUpdate(item, 0);
wear.ItemID = item.ID;
}
if (wear.Type == 11 && wear.ItemID == UUID.Zero && module.DefaultUndershirt != UUID.Zero)
{
NeedsRebake = true;
wear.ItemID = module.DefaultUndershirt;
InventoryItemBase item = new InventoryItemBase(UUID.Random())
{
InvType = (int)InventoryType.Wearable,
AssetType = (int)AssetType.Clothing,
Name = "Default Undershirt",
Folder =
m_scene.InventoryService.GetFolderForType(client.AgentId,
InventoryType.
Wearable,
AssetType.
Clothing).ID,
//.........这里部分代码省略.........
示例15: AddItem
public virtual bool AddItem(InventoryItemBase item, bool doParentFolderCheck)
{
if (doParentFolderCheck)
{
InventoryFolderBase folder = GetFolder(new InventoryFolderBase(item.Folder));
if (folder == null || folder.Owner != item.Owner)
return false;
}
m_Database.IncrementFolder(item.Folder);
return m_Database.StoreItem(item);
}