| | 1 | | using DCL.Emotes; |
| | 2 | | using System; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.Linq; |
| | 5 | |
|
| | 6 | | namespace DCLServices.WearablesCatalogService |
| | 7 | | { |
| | 8 | | [Serializable] |
| | 9 | | public class WearableCollectionResponseFromBuilder |
| | 10 | | { |
| | 11 | | [Serializable] |
| | 12 | | public class Pagination |
| | 13 | | { |
| | 14 | | public int total; |
| | 15 | | public int limit; |
| | 16 | | public int pages; |
| | 17 | | public int page; |
| | 18 | | public BuilderWearable[] results; |
| | 19 | | } |
| | 20 | |
|
| | 21 | | public Pagination data; |
| | 22 | | } |
| | 23 | |
|
| | 24 | | [Serializable] |
| | 25 | | public class WearableItemResponseFromBuilder |
| | 26 | | { |
| | 27 | | public BuilderWearable data; |
| | 28 | | } |
| | 29 | |
|
| | 30 | | [Serializable] |
| | 31 | | public class BuilderWearable |
| | 32 | | { |
| | 33 | | [Serializable] |
| | 34 | | public class BuilderWearableData |
| | 35 | | { |
| | 36 | | [Serializable] |
| | 37 | | public class Representation |
| | 38 | | { |
| | 39 | | public string[] bodyShapes; |
| | 40 | | public string mainFile; |
| | 41 | | public string[] contents; |
| | 42 | | public string[] overrideHides; |
| | 43 | | public string[] overrideReplaces; |
| | 44 | |
|
| | 45 | | public WearableItem.Representation ToWearableRepresentation(string contentUrl, Dictionary<string, string |
| | 46 | | { |
| 0 | 47 | | return new WearableItem.Representation |
| | 48 | | { |
| | 49 | | bodyShapes = bodyShapes, |
| | 50 | | mainFile = mainFile, |
| | 51 | | overrideHides = overrideHides, |
| | 52 | | overrideReplaces = overrideReplaces, |
| 0 | 53 | | contents = contents.Select(s => new WearableItem.MappingPair |
| | 54 | | { |
| | 55 | | key = s, |
| | 56 | | hash = hashes[s], |
| | 57 | | url = $"{contentUrl}/{hashes[s]}", |
| | 58 | | }) |
| | 59 | | .ToArray(), |
| | 60 | | }; |
| | 61 | | } |
| | 62 | | } |
| | 63 | |
|
| | 64 | | public string category; |
| | 65 | | public bool loop; |
| | 66 | | public string[] replaces; |
| | 67 | | public string[] hides; |
| | 68 | | public string[] tags; |
| | 69 | | public Representation[] representations; |
| | 70 | | public bool blockVrmExport; |
| | 71 | |
|
| | 72 | | public WearableItem.Data ToWearableData(string contentUrl, Dictionary<string, string> hashes) |
| | 73 | | { |
| 0 | 74 | | return new WearableItem.Data |
| | 75 | | { |
| | 76 | | category = category, |
| | 77 | | hides = hides, |
| | 78 | | loop = loop, |
| | 79 | | replaces = replaces, |
| | 80 | | tags = tags, |
| 0 | 81 | | representations = representations.Select(r => r.ToWearableRepresentation(contentUrl, hashes)).ToArra |
| | 82 | |
|
| | 83 | | // TODO: builder api does not include this information |
| | 84 | | removesDefaultHiding = Array.Empty<string>(), |
| | 85 | | blockVrmExport = blockVrmExport, |
| | 86 | | }; |
| | 87 | | } |
| | 88 | | } |
| | 89 | |
|
| | 90 | | public string id; |
| | 91 | | public string name; |
| | 92 | | public string description; |
| | 93 | | public string rarity; |
| | 94 | | public string type; |
| | 95 | | public BuilderWearableData data; |
| | 96 | | public Dictionary<string, string> contents; |
| | 97 | | public string thumbnail; |
| | 98 | |
|
| | 99 | | public WearableItem ToWearableItem(string contentUrl, string assetBundleUrl) |
| | 100 | | { |
| 0 | 101 | | return new WearableItem |
| | 102 | | { |
| | 103 | | id = id, |
| | 104 | | baseUrl = contentUrl, |
| | 105 | | description = description, |
| | 106 | | thumbnail = contents[thumbnail], |
| | 107 | | rarity = rarity, |
| | 108 | | i18n = new[] |
| | 109 | | { |
| | 110 | | new i18n |
| | 111 | | { |
| | 112 | | code = "en", |
| | 113 | | text = name, |
| | 114 | | }, |
| | 115 | | }, |
| | 116 | | baseUrlBundles = assetBundleUrl, |
| | 117 | | data = data.ToWearableData(contentUrl, contents), |
| | 118 | | emoteDataV0 = type == "emote" ? new EmoteDataV0 { loop = data.loop } : null, |
| | 119 | | }; |
| | 120 | | } |
| | 121 | | } |
| | 122 | | } |