public void Startup(ConfigurationLoader loader)
        {
            IConfig config = loader.Config.Configs[GetType().FullName];
            string  inventoryTransferTransactionServiceName = config.GetString("InventoryTransferTransactionService");

            m_InventoryTransferTransactionService = loader.GetService <InventoryTransferTransactionServiceInterface>(inventoryTransferTransactionServiceName);
            m_SrcAgent = new UGUI(config.GetString("SrcAgent"));
            m_DstAgent = new UGUI(config.GetString("DstAgent"));
            m_Log.Info("Src " + m_SrcAgent.ToString());
        }
Exemplo n.º 2
0
            public override void AssetTransferComplete()
            {
                AssetData          data;
                List <ObjectGroup> objgroups;

                try
                {
                    data = m_Scene.AssetService[AssetID];
                }
                catch (Exception e)
                {
                    m_Log.Error(string.Format("Failed to rez attachment from asset {0}", AssetID), e);
                    SendAlertMessage("ALERT: CantFindObject");
                    return;
                }

#if DEBUG
                m_Log.DebugFormat("Deserializing object asset {0} for agent {1}", data.ID, m_RezzingAgent.ToString());
#endif
                try
                {
                    objgroups = ObjectXML.FromAsset(data, m_RezzingAgent);
                }
                catch (Exception e)
                {
                    m_Log.WarnFormat("Deserialization error for object asset {0} for agent {1}: {2}: {3}",
                                     data.ID, m_RezzingAgent.ToString(), e.GetType().FullName, e.ToString());
                    SendAlertMessage("ALERT: InvalidObjectParams");
                    return;
                }

                if (objgroups.Count != 1)
                {
                    SendAlertMessage("ALERT: InvalidObjectParams");
                    return;
                }

                ObjectGroup grp = objgroups[0];

                bool attachPointChanged = false;

                foreach (var part in grp.Values)
                {
                    if (part.Shape.PCode == PrimitiveCode.Grass ||
                        part.Shape.PCode == PrimitiveCode.Tree ||
                        part.Shape.PCode == PrimitiveCode.NewTree)
                    {
                        SendAlertMessage("ALERT: WhyAreYouTryingToWearShrubbery");
                        return;
                    }
                }

                var attachAt = m_AttachPoint & AttachmentPoint.PositionMask;
                if (attachAt != AttachmentPoint.Default && attachAt != grp.AttachPoint)
                {
                    grp.AttachedPos    = Vector3.Zero;
                    grp.AttachedRot    = Quaternion.Identity;
                    attachPointChanged = true;
                }

                if (attachAt == AttachmentPoint.Default)
                {
                    attachAt = grp.AttachPoint;

                    if (attachAt == AttachmentPoint.NotAttached)
                    {
                        grp.AttachPoint = AttachmentPoint.LeftHand;
                        grp.AttachedPos = Vector3.Zero;
                        grp.AttachedRot = Quaternion.Identity;
                    }
                }

                grp.Owner            = m_RezzingAgent;
                grp.FromItemID       = m_SourceItem.ID;
                grp.IsAttached       = true;
                grp.Position         = grp.AttachedPos;
                grp.Rotation         = grp.AttachedRot;
                grp.IsChangedEnabled = true;

                if (attachPointChanged)
                {
                    grp.AttachPoint = attachAt;
                }

#if DEBUG
                m_Log.DebugFormat("Adding attachment asset {0} at {4} for agent {1}", data.ID, m_RezzingAgent.ToString());
#endif
                try
                {
                    m_Scene.RezObject(grp, m_RezzingAgent, m_SourceItem);
                    m_AttachmentsList.Add(grp.AttachPoint, grp);
                }
                catch
                {
                    SendAlertMessage("ALERT: RezAttemptFailed");
                    return;
                }
                grp.PostEvent(new AttachEvent {
                    ObjectID = grp.Owner.ID
                });
            }
Exemplo n.º 3
0
 public void Write(ushort tlvId, UGUI value) =>
 Write_Blob(tlvId, EntryType.UGUI, value.ToString().ToUTF8Bytes());
Exemplo n.º 4
0
        public void LoadFromCurrentOutfit(UGUI principal, InventoryServiceInterface inventoryService, AssetServiceInterface assetService, Action <string> logOutput = null)
        {
            lock (m_Lock)
            {
                if (CurrentOutfitFolderID == UUID.Zero)
                {
                    InventoryFolder folder;
                    if (!inventoryService.Folder.TryGetValue(principal.ID, AssetType.CurrentOutfitFolder, out folder))
                    {
                        throw new BakeErrorException("Outfit folder missing");
                    }
                    CurrentOutfitFolderID = folder.ID;
                }

                InventoryFolderContent folderContent = inventoryService.Folder.Content[principal.ID, CurrentOutfitFolderID];
                AppearanceSerial = folderContent.Version;

                var items     = new List <InventoryItem>();
                var itemlinks = new List <UUID>();
                foreach (var item in folderContent.Items)
                {
                    if (item.AssetType == AssetType.Link &&
                        item.InventoryType == InventoryType.Wearable)
                    {
                        items.Add(item);
                        itemlinks.Add(item.AssetID);
                    }
                }

                var actualItems       = itemlinks.Count != 0 ? inventoryService.Item[principal.ID, itemlinks] : new List <InventoryItem>();
                var actualItemsInDict = new Dictionary <UUID, InventoryItem>();
                foreach (var item in actualItems)
                {
                    actualItemsInDict.Add(item.ID, item);
                }

                var outfitItems = new Dictionary <UUID, OutfitItem>();

                logOutput?.Invoke(string.Format("Processing assets for baking agent {0}", principal.ToString()));

                AvatarWearables.Clear();

                foreach (var linkItem in items)
                {
                    InventoryItem actualItem;
                    if (actualItemsInDict.TryGetValue(linkItem.AssetID, out actualItem))
                    {
                        AssetData outfitData;
                        Wearable  wearableData;
                        if (assetService.TryGetValue(actualItem.AssetID, out outfitData))
                        {
#if DEBUG
                            logOutput?.Invoke(string.Format("Using item {0} {1} ({2}): asset {3}", actualItem.AssetType.ToString(), actualItem.Name, actualItem.ID, actualItem.AssetID));
#endif
                            try
                            {
                                wearableData = new Wearable(outfitData);
                            }
                            catch (Exception e)
                            {
                                string info = string.Format("Asset {0} for agent {1} ({2}) failed to decode as wearable", actualItem.AssetID, principal.ToString(), principal.ID);
                                m_Log.ErrorFormat(info, e);
                                throw new BakeErrorException(info, e);
                            }

                            var oitem = new OutfitItem(LinkDescriptionToInt(linkItem.Description), wearableData);
                            outfitItems.Add(linkItem.AssetID, oitem);
                            List <AgentWearables.WearableInfo> wearables;
                            if (!AvatarWearables.TryGetValue(wearableData.Type, out wearables))
                            {
                                wearables = new List <AgentWearables.WearableInfo>();
                                AvatarWearables.Add(wearableData.Type, wearables);
                            }
                            wearables.Add(new AgentWearables.WearableInfo(linkItem.AssetID, actualItem.AssetID));
                        }
                        else
                        {
                            logOutput?.Invoke(string.Format("Missing asset {0} for inventory item {1} ({2})", actualItem.AssetID, actualItem.Name, actualItem.ID));
                        }
                    }
                    else
                    {
                        logOutput?.Invoke(string.Format("Missing inventory item {0} for link {1} ({2}", linkItem.AssetID, linkItem.Name, linkItem.ID));
                    }
                }

                logOutput?.Invoke(string.Format("Setting current outfit for baking agent {0}", principal.ToString()));
                SetCurrentOutfit(outfitItems);
            }
        }