public bool IsAttached(InventoryItem item) { List<Primitive> myAtt = client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.ParentID == client.Self.LocalID); foreach (Primitive prim in myAtt) { if (prim.NameValues == null) continue; UUID invID = UUID.Zero; for (int i = 0; i < prim.NameValues.Length; i++) { if (prim.NameValues[i].Name == "AttachItemID") { invID = (UUID)prim.NameValues[i].Value.ToString(); break; } } if (invID == item.UUID) { lock (attachments) { AttachmentInfo inf = new AttachmentInfo(); inf.InventoryID = item.UUID; inf.Item = item; inf.MarkedAttached = true; inf.Prim = prim; inf.PrimID = prim.ID; attachments[invID] = inf; } return true; } } return false; }
public bool AllowDetach(AttachmentInfo a) { if (!Enabled || a == null) return true; if (rules.FindAll((RLVRule r) => { return r.Behaviour == "detach" && r.Sender == a.Prim.ID; }).Count > 0) { return false; } return true; }
void Objects_AttachmentUpdate(object sender, PrimEventArgs e) { Primitive prim = e.Prim; if (client.Self.LocalID == 0 || prim.ParentID != client.Self.LocalID || prim.NameValues == null) return; for (int i = 0; i < prim.NameValues.Length; i++) { if (prim.NameValues[i].Name == "AttachItemID") { AttachmentInfo attachment = new AttachmentInfo(); attachment.Prim = prim; attachment.InventoryID = new UUID(prim.NameValues[i].Value.ToString()); attachment.PrimID = prim.ID; lock (attachments) { // Add new attachment info if (!attachments.ContainsKey(attachment.InventoryID)) { attachments.Add(attachment.InventoryID, attachment); } else { attachment = attachments[attachment.InventoryID]; if (attachment.Prim == null) { attachment.Prim = prim; } } // Don't update the tree yet if we're still updating invetory tree from server if (!TreeUpdateInProgress) { if (Inventory.Contains(attachment.InventoryID)) { if (attachment.Item == null) { InventoryItem item = (InventoryItem)Inventory[attachment.InventoryID]; attachment.Item = item; } if (!attachment.MarkedAttached) { attachment.MarkedAttached = true; UpdateNodeLabel(attachment.InventoryID); } } else { client.Inventory.RequestFetchInventory(attachment.InventoryID, client.Self.AgentID); } } } break; } } }
void Objects_AttachmentUpdate(object sender, PrimEventArgs e) { Primitive prim = e.Prim; if (client.Self.LocalID == 0 || prim.ParentID != client.Self.LocalID || prim.NameValues == null) return; for (int i = 0; i < prim.NameValues.Length; i++) { if (prim.NameValues[i].Name == "AttachItemID") { AttachmentInfo attachment = new AttachmentInfo(); attachment.Prim = prim; attachment.InventoryID = new UUID(prim.NameValues[i].Value.ToString()); attachment.PrimID = prim.ID; lock (attachments) { // Do we have attachmetns already on this spot? AttachmentInfo oldAttachment = null; UUID oldAttachmentUUID = UUID.Zero; foreach (KeyValuePair<UUID, AttachmentInfo> att in attachments) { if (att.Value.Point == prim.PrimData.AttachmentPoint) { oldAttachment = att.Value; oldAttachmentUUID = att.Key; break; } } if (oldAttachment != null && oldAttachment.InventoryID != attachment.InventoryID) { attachments.Remove(oldAttachmentUUID); if (oldAttachment.Item != null) { attachment.MarkedAttached = false; Inventory_InventoryObjectUpdated(this, new InventoryObjectUpdatedEventArgs(oldAttachment.Item, oldAttachment.Item)); } } // Add new attachment info if (!attachments.ContainsKey(attachment.InventoryID)) { attachments.Add(attachment.InventoryID, attachment); } else { attachment = attachments[attachment.InventoryID]; if (attachment.Prim == null) { attachment.Prim = prim; } } // Don't update the tree yet if we're still updating invetory tree from server if (!TreeUpdateInProgress) { if (Inventory.Contains(attachment.InventoryID)) { if (attachment.Item == null) { InventoryItem item = (InventoryItem)Inventory[attachment.InventoryID]; attachment.Item = item; } if (!attachment.MarkedAttached) { attachment.MarkedAttached = true; Inventory_InventoryObjectUpdated(this, new InventoryObjectUpdatedEventArgs(attachments[attachment.InventoryID].Item, attachments[attachment.InventoryID].Item)); } } else { client.Inventory.RequestFetchInventory(attachment.InventoryID, client.Self.AgentID); } } } break; } } }