Exemple #1
0
    public List <WearableItem> GetWearablesReplacedBy(WearableItem wearableItem)
    {
        List <WearableItem> wearablesToReplace = new List <WearableItem>();

        HashSet <string> categoriesToReplace = new HashSet <string>(wearableItem.GetReplacesList(model.bodyShape.id) ?? new string[0]);

        int wearableCount = model.wearables.Count;

        for (int i = 0; i < wearableCount; i++)
        {
            var wearable = model.wearables[i];
            if (wearable == null)
            {
                continue;
            }

            if (categoriesToReplace.Contains(wearable.category))
            {
                wearablesToReplace.Add(wearable);
            }
            else
            {
                //For retrocompatibility's sake we check current wearables against new one (compatibility matrix is symmetrical)
                HashSet <string> replacesList = new HashSet <string>(wearable.GetReplacesList(model.bodyShape.id) ?? new string[0]);
                if (replacesList.Contains(wearableItem.category))
                {
                    wearablesToReplace.Add(wearable);
                }
            }
        }

        return(wearablesToReplace);
    }
Exemple #2
0
 public void Setup(WearableItem currentItem, WearableItemInventory currentScrollList)
 {
     item = currentItem;
     //iconImage.sprite = item.icon;
     itemStats.text = "";
     scrollList     = currentScrollList;
 }
Exemple #3
0
    public void AddItemToggle(WearableItem item, int amount)
    {
        if (item == null)
        {
            return;
        }
        if (itemToggles.ContainsKey(item.id))
        {
            return;
        }

        ItemToggle newToggle;

        if (item.IsCollectible())
        {
            newToggle = itemToggleFactory.CreateItemToggleFromRarity(item.rarity, itemContainer);
            newToggle.transform.SetAsFirstSibling();
        }
        else
        {
            newToggle = itemToggleFactory.CreateBaseWearable(itemContainer);
        }

        newToggle.Initialize(item, false, amount);
        newToggle.OnClicked     += ToggleClicked;
        newToggle.OnSellClicked += SellClicked;
        itemToggles.Add(item.id, newToggle);

        bool active = string.IsNullOrEmpty(currentBodyShape) || item.SupportsBodyShape(currentBodyShape);

        newToggle.gameObject.SetActive(active);
    }
        public IEnumerator FailsGracefully_EmptyContent()
        {
            //Arrange
            WearableItem fakeWearable = new WearableItem
            {
                category        = WearableLiterals.Categories.EYES,
                baseUrl         = "http://nothing_here.nope",
                representations = new []
                {
                    new WearableItem.Representation
                    {
                        bodyShapes = new [] { WearableLiterals.BodyShapes.FEMALE },
                        contents   = new ContentServerUtils.MappingPair[0],
                    }
                }
            };
            FacialFeatureController controller = new FacialFeatureController(fakeWearable, new Material(Shader.Find("DCL/Toon Shader")));

            //Act
            controller.Load(bodyShapeController, Color.red);
            yield return(new WaitUntil(() => controller.isReady));

            //Assert
            Assert.Null(controller.mainTexture);
            Assert.Null(controller.maskTexture);
        }
 protected WearableController(WearableController original)
 {
     wearable       = original.wearable;
     loader         = original.loader;
     bodyShapeId    = original.bodyShapeId;
     assetRenderers = original.assetRenderers;
 }
Exemple #6
0
        private void AddWearableController(WearableItem wearable)
        {
            if (wearable == null)
            {
                return;
            }
            switch (wearable.category)
            {
            case Categories.EYES:
                eyesController = new FacialFeatureController(wearable, eyeMaterial);
                break;

            case Categories.EYEBROWS:
                eyebrowsController = new FacialFeatureController(wearable, eyebrowMaterial);
                break;

            case Categories.MOUTH:
                mouthController = new FacialFeatureController(wearable, mouthMaterial);
                break;

            case Categories.BODY_SHAPE:
                break;

            default:
                var wearableController = new WearableController(wearable, bodyShapeController.id);
                wearableControllers.Add(wearable, wearableController);
                break;
            }
        }
Exemple #7
0
    private void EquipBodyShape(WearableItem bodyShape)
    {
        if (bodyShape.category != Categories.BODY_SHAPE)
        {
            Debug.LogError($"Item ({bodyShape.id} is not a body shape");
            return;
        }

        if (model.bodyShape == bodyShape)
        {
            return;
        }

        model.bodyShape = bodyShape;
        view.UpdateSelectedBody(bodyShape);

        int wearablesCount = model.wearables.Count;

        for (var i = wearablesCount - 1; i >= 0; i--)
        {
            UnequipWearable(model.wearables[i]);
        }

        var defaultWearables = WearableLiterals.DefaultWearables.GetDefaultWearables(bodyShape.id);

        for (var i = 0; i < defaultWearables.Length; i++)
        {
            if (catalog.TryGetValue(defaultWearables[i], out var wearable))
            {
                EquipWearable(wearable);
            }
        }
    }
Exemple #8
0
        public IEnumerator FailsGracefully()
        {
            //Arrange
            WearableItem unexistentWearableItem = new WearableItem
            {
                representations = new [] { new WearableItem.Representation
                                           {
                                               mainFile = "NothingHere",
                                               contents = new [] { new ContentServerUtils.MappingPair {
                                                                       file = "NothingHere", hash = "NothingHere"
                                                                   } },
                                               bodyShapes = new [] { WearableLiterals.BodyShapes.FEMALE, WearableLiterals.BodyShapes.MALE }
                                           } }
            };
            WearableController wearable = new WearableController(unexistentWearableItem);

            toCleanUp.Add(wearable);

            //Act
            bool succeeded = false;
            bool failed    = false;

            RendereableAssetLoadHelper.LoadingType cacheLoadingType = RendereableAssetLoadHelper.loadingType;
            RendereableAssetLoadHelper.loadingType = RendereableAssetLoadHelper.LoadingType.ASSET_BUNDLE_ONLY;
            wearable.Load(WearableLiterals.BodyShapes.FEMALE, wearableHolder, x => succeeded = true, x => failed = true);
            yield return(new WaitUntil(() => succeeded || failed));

            RendereableAssetLoadHelper.loadingType = cacheLoadingType;

            //Assert
            Assert.IsFalse(succeeded);
            Assert.IsTrue(failed);
        }
Exemple #9
0
    public int?UnequipItem(WearableItemType itemType)
    {
        int?itemId = null;

        switch (itemType)
        {
        case WearableItemType.Weapon:
            itemId = weapon.id;
            weapon = null;
            break;

        case WearableItemType.Armor:
            itemId = armor.id;
            armor  = null;
            break;

        case WearableItemType.Shield:
            itemId = shield.id;
            shield = null;
            break;

        case WearableItemType.Jewelry:
            itemId  = jewelry.id;
            jewelry = null;
            break;

        default:
            break;
        }

        UpdateStats();

        return(itemId);
    }
Exemple #10
0
    public int?EquipItem(int itemId)
    {
        WearableItem item           = wearableDB.wearableItemDatabase.First(x => x.id == itemId);
        int?         unequippedItem = null;

        switch (item.wearableType)
        {
        case WearableItemType.Weapon:
            unequippedItem = UnequipItem(item.wearableType);
            weapon         = item;
            break;

        case WearableItemType.Armor:
            unequippedItem = UnequipItem(item.wearableType);
            armor          = item;
            break;

        case WearableItemType.Shield:
            unequippedItem = UnequipItem(item.wearableType);
            shield         = item;
            break;

        case WearableItemType.Jewelry:
            unequippedItem = UnequipItem(item.wearableType);
            jewelry        = item;
            break;

        default:
            break;
        }

        UpdateStats();

        return(unequippedItem);
    }
Exemple #11
0
    public void AddWearableToCatalog(string payload)
    {
        Item item = JsonUtility.FromJson <Item>(payload);

        if (VERBOSE)
        {
            Debug.Log("add wearable: " + payload);
        }

        switch (item.type)
        {
        case "wearable":
        {
            WearableItem wearableItem = JsonUtility.FromJson <WearableItem>(payload);
            wearableCatalog.Add(wearableItem.id, wearableItem);
            break;
        }

        case "item":
        {
            itemCatalog.Add(item.id, item);
            break;
        }

        default:
        {
            Debug.LogError("Bad type in item, will not be added to catalog");
            break;
        }
        }
    }
Exemple #12
0
    public void WearableItemAquired(string itemName)
    {
        WearableItem itemType = WorldManager.instance.GetWearableItemByName(itemName);

        // TODO: get image texture from somewhere

        ui.StartItemAquiredSequence(itemType.verboseName, tempTex);
    }
Exemple #13
0
 /// <summary>
 /// This method applies blendshape to the player model.
 /// </summary>
 /// <param name="item">The item from which the blendshape will be applied,
 ///                    of type WearableItem</param>
 /// <param name="weight">The amount of blendshape to apply, of type float</param>
 private void SetWearableItemBlendShape(WearableItem item, float weight)
 {
     // Condition to apply a blendshape
     if (item.BlendShapeType != MeshShapeType.None)
     {
         SkinnedMesh.SetBlendShapeWeight((int)item.BlendShapeType, weight);
     }
 }
Exemple #14
0
 private void UnequipWearable(WearableItem wearable)
 {
     if (model.wearables.Contains(wearable))
     {
         model.wearables.Remove(wearable);
         view.UnselectWearable(wearable);
     }
 }
    void AddWearableItem()
    {
        WearableItem newItem = new WearableItem();

        newItem.itemName = "New Item";
        WearableItemDatabase.wearableItemDatabase.Add(newItem);
        viewIndex = WearableItemDatabase.wearableItemDatabase.Count;
    }
    public List <WearableItem> GetWearableItems()
    {
        if (wearables == null || wearables.Count == 0)
        {
            return(null);
        }

        List <WearableItem> result = new List <WearableItem>();

        foreach (var wearableData in wearables)
        {
            // Populate new WearableItem with fetched data
            WearableItem wearable = new WearableItem()
            {
                id          = wearableData.id,
                baseUrl     = WEARABLES_CONTENT_BASE_URL,
                thumbnail   = wearableData.thumbnail,
                rarity      = wearableData.rarity,
                description = wearableData.description,
                i18n        = wearableData.i18n,
                data        = new WearableItem.Data()
                {
                    category = wearableData.data.category,
                    tags     = wearableData.data.tags
                }
            };

            List <WearableItem.Representation> wearableRepresentations = new List <WearableItem.Representation>();
            foreach (var wearableDataRepresentation in wearableData.data.representations)
            {
                WearableItem.Representation wearableRepresentation = new WearableItem.Representation()
                {
                    bodyShapes       = wearableDataRepresentation.bodyShapes,
                    overrideHides    = wearableDataRepresentation.overrideHides,
                    overrideReplaces = wearableDataRepresentation.overrideReplaces,
                    mainFile         = wearableDataRepresentation.mainFile
                };

                List <WearableItem.MappingPair> contentMappingPairs = new List <WearableItem.MappingPair>();
                foreach (var content in wearableDataRepresentation.contents)
                {
                    contentMappingPairs.Add(new WearableItem.MappingPair()
                    {
                        key  = content.key,
                        hash = content.url.Substring(content.url.LastIndexOf("/") + 1)
                    });
                }

                wearableRepresentation.contents = contentMappingPairs.ToArray();
                wearableRepresentations.Add(wearableRepresentation);
            }

            wearable.data.representations = wearableRepresentations.ToArray();
            result.Add(wearable);
        }

        return(result);
    }
        private GameObject GetMount(WearableItem item)
        {
            if (Mounts.Any(x => x.MountType == item.WearableLocation))
            {
                return(Mounts.First(x => x.MountType == item.WearableLocation).GameObject);
            }

            throw new Exception("This mount has not been set up correctly: " + item.WearableLocation);
        }
Exemple #18
0
        public void CreateNFTsButtonsByRarityCorrectly(string rarity)
        {
            WearableItem dummyItem = CreateDummyNFT(rarity);

            var selector         = controller.myView.selectorsByCategory[dummyItem.data.category];
            var itemToggleObject = selector.itemToggles[dummyItem.id].gameObject;

            var originalName = selector.itemToggleFactory.nftDictionary[rarity].prefab.name;

            Assert.IsTrue(itemToggleObject.name.Contains(originalName)); //Comparing names because PrefabUtility.GetOutermostPrefabInstanceRoot(itemToggleObject) is returning null
        }
    public virtual void Initialize(WearableItem w, bool isSelected, int amount)
    {
        wearableItem = w;
        selected     = isSelected;
        amountContainer.gameObject.SetActive(amount > 1);
        amountText.text = $"x{amount.ToString()}";

        if (gameObject.activeInHierarchy)
        {
            GetThumbnail();
        }
    }
Exemple #20
0
        public void FillNFTInfoPanelCorrectly()
        {
            WearableItem dummyItem = CreateDummyNFT(WearableLiterals.ItemRarity.EPIC);

            var itemToggle = controller.myView.selectorsByCategory[dummyItem.data.category].itemToggles[dummyItem.id];
            var nftInfo    = (itemToggle as NFTItemToggle)?.nftItemInfo;

            Assert.NotNull(nftInfo);
            Assert.AreEqual(dummyItem.GetName(), nftInfo.name.text);
            Assert.AreEqual(dummyItem.description, nftInfo.description.text);
            Assert.AreEqual($"{dummyItem.issuedId} / {dummyItem.GetIssuedCountFromRarity(dummyItem.rarity)}", nftInfo.minted.text);
        }
Exemple #21
0
        public bool SaveAvatarArchive(string fileName, UUID principalID, string folderName, UUID snapshotUUID, bool isPublic)
        {
            UserAccount account = UserAccountService.GetUserAccount(null, principalID);

            if (account == null)
            {
                MainConsole.Instance.Error("[AvatarArchive]: User not found!");
                return(false);
            }

            AvatarAppearance appearance = AvatarService.GetAppearance(account.PrincipalID);

            if (appearance == null)
            {
                MainConsole.Instance.Error("[AvatarArchive] Appearance not found!");
                return(false);
            }
            AvatarArchive archive = new AvatarArchive();

            archive.AssetsMap  = new OSDMap();
            archive.BodyMap    = appearance.Pack();
            archive.Appearance = appearance;
            archive.ItemsMap   = new OSDMap();

            foreach (AvatarWearable wear in appearance.Wearables)
            {
                for (int i = 0; i < wear.Count; i++)
                {
                    WearableItem w = wear[i];
                    if (w.AssetID != UUID.Zero)
                    {
                        SaveItem(w.ItemID, ref archive);
                        SaveAsset(w.AssetID, ref archive);
                    }
                }
            }
            List <AvatarAttachment> attachments = appearance.GetAttachments();

            foreach (AvatarAttachment a in attachments.Where(a => a.AssetID != UUID.Zero))
            {
                SaveItem(a.ItemID, ref archive);
                SaveAsset(a.AssetID, ref archive);
            }

            archive.FolderName = folderName;
            archive.Snapshot   = snapshotUUID;
            archive.IsPublic   = isPublic;

            File.WriteAllText(fileName, OSDParser.SerializeLLSDXmlString(archive.ToOSD()));
            MainConsole.Instance.Info("[AvatarArchive] Saved archive to " + fileName);

            return(true);
        }
Exemple #22
0
    public void AddWearablesToCatalog(string payload)
    {
        WearablesRequestResponse request = JsonUtility.FromJson <WearablesRequestResponse>(payload);

        if (VERBOSE)
        {
            Debug.Log("add wearables: " + payload);
        }

        for (int i = 0; i < request.wearables.Length; i++)
        {
            switch (request.wearables[i].type)
            {
            case "wearable":
            {
                WearableItem wearableItem = request.wearables[i];

                if (!wearableCatalog.ContainsKey(wearableItem.id))
                {
                    wearableCatalog.Add(wearableItem.id, wearableItem);
                    wearablesInUseCounters.Add(wearableItem.id, 1);
                    ResolvePendingWearablePromise(wearableItem.id, wearableItem);
                    pendingWearableRequestedTimes.Remove(wearableItem.id);
                }

                break;
            }

            case "item":
            {
                if (!itemCatalog.ContainsKey(request.wearables[i].id))
                {
                    itemCatalog.Add(request.wearables[i].id, (Item)request.wearables[i]);
                }

                break;
            }

            default:
            {
                Debug.LogError("Bad type in item, will not be added to catalog");
                break;
            }
            }
        }

        if (!string.IsNullOrEmpty(request.context))
        {
            ResolvePendingWearablesByContextPromise(request.context, request.wearables);
            pendingWearablesByContextRequestedTimes.Remove(request.context);
        }
    }
    private WearableItem CreateMockWearableByRarity(string rarity)
    {
        var wearable = new WearableItem()
        {
            id       = rarity,
            rarity   = rarity,
            tags     = new string[] { },
            category = WearableLiterals.Categories.UPPER_BODY
        };

        CatalogController.wearableCatalog.Add(rarity, wearable);
        return(wearable);
    }
    public static FacialFeatureController CreateDefaultFacialFeature(string bodyShape, string category, Material material)
    {
        string       defaultId = WearableLiterals.DefaultWearables.GetDefaultWearable(bodyShape, category);
        WearableItem wearable  = CatalogController.wearableCatalog.GetOrDefault(defaultId);

        if (wearable == null)
        {
            Debug.LogError($"Couldn't resolve wearable {defaultId}");
            return(null);
        }

        return(new FacialFeatureController(wearable, material));
    }
        public void BeRetrievedProperly()
        {
            WearableItem wearableItem = new WearableItem
            {
                replaces = new [] { "category1", "category2", "category3" }
            };

            var replaces = wearableItem.GetReplacesList(null);

            Assert.AreEqual("category1", replaces[0]);
            Assert.AreEqual("category2", replaces[1]);
            Assert.AreEqual("category3", replaces[2]);
        }
Exemple #26
0
 internal void SetWearableLoadingSpinner(WearableItem wearable, bool isActive)
 {
     selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, isActive);
     collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, isActive);
     if (isActive)
     {
         wearablesWithLoadingSpinner.Add(wearable);
     }
     else
     {
         wearablesWithLoadingSpinner.Remove(wearable);
     }
 }
    public void Initialize(WearableItem collectible)
    {
        this.collectible = collectible;

        if (this.collectible == null)
        {
            return;
        }

        if (gameObject.activeInHierarchy)
        {
            GetThumbnail();
        }
    }
 private void RemoveWearable(string id, WearableItem wearable)
 {
     if (wearablesByCategory.ContainsKey(wearable.category))
     {
         if (wearablesByCategory[wearable.category].Remove(wearable))
         {
             if (wearablesByCategory[wearable.category].Count == 0)
             {
                 wearablesByCategory.Remove(wearable.category);
             }
         }
     }
     view.RemoveWearable(wearable);
 }
Exemple #29
0
    private void AddWearable(string id, WearableItem wearable)
    {
        if (!wearable.tags.Contains("base-wearable") && userProfile.GetItemAmount(id) == 0)
        {
            return;
        }

        if (!wearablesByCategory.ContainsKey(wearable.category))
        {
            wearablesByCategory.Add(wearable.category, new List <WearableItem>());
        }

        wearablesByCategory[wearable.category].Add(wearable);
        view.AddWearable(wearable, userProfile.GetItemAmount(id));
    }
Exemple #30
0
    private void EquipWearable(WearableItem wearable)
    {
        if (!wearablesByCategory.ContainsKey(wearable.category))
        {
            return;
        }

        if (wearablesByCategory[wearable.category].Contains(wearable) && wearable.SupportsBodyShape(model.bodyShape.id) && !model.wearables.Contains(wearable))
        {
            var toReplace = GetWearablesReplacedBy(wearable);
            toReplace.ForEach(UnequipWearable);
            model.wearables.Add(wearable);
            view.SelectWearable(wearable);
        }
    }