| | 1 | | using System.Collections.Generic; |
| | 2 | | using System.Linq; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.Backpack |
| | 6 | | { |
| | 7 | | public record BackpackEditorHUDModel |
| | 8 | | { |
| 43 | 9 | | public WearableItem bodyShape = new() { id = "NOT_LOADED" }; |
| 43 | 10 | | public Dictionary<string, WearableItem> wearables = new (); |
| | 11 | | public Color hairColor; |
| | 12 | | public Color skinColor; |
| | 13 | | public Color eyesColor; |
| 43 | 14 | | public HashSet<string> forceRender = new (); |
| | 15 | |
|
| | 16 | | public AvatarModel ToAvatarModel(Dictionary<string, string> extendedWearableUrns = null) |
| | 17 | | { |
| | 18 | | List<string> wearables; |
| | 19 | |
|
| 58 | 20 | | if (extendedWearableUrns != null) |
| | 21 | | { |
| 26 | 22 | | wearables = new List<string>(); |
| | 23 | |
|
| 144 | 24 | | foreach (string w in this.wearables.Keys) |
| 46 | 25 | | wearables.Add(extendedWearableUrns.TryGetValue(w, out string extendedUrn) |
| | 26 | | ? extendedUrn : w); |
| | 27 | | } |
| | 28 | | else |
| 32 | 29 | | wearables = this.wearables.Keys.ToList(); |
| | 30 | |
|
| 58 | 31 | | return new AvatarModel |
| | 32 | | { |
| | 33 | | bodyShape = bodyShape.id, |
| | 34 | | wearables = wearables, |
| | 35 | | hairColor = hairColor, |
| | 36 | | skinColor = skinColor, |
| | 37 | | eyeColor = eyesColor, |
| | 38 | | forceRender = new HashSet<string>(forceRender) |
| | 39 | | }; |
| | 40 | | } |
| | 41 | |
|
| | 42 | | public void Update(BackpackEditorHUDModel newModel) |
| | 43 | | { |
| 0 | 44 | | wearables.Clear(); |
| 0 | 45 | | foreach (var wearable in newModel.wearables) |
| 0 | 46 | | wearables.Add(wearable.Key, wearable.Value); |
| | 47 | |
|
| 0 | 48 | | bodyShape = newModel.bodyShape; |
| 0 | 49 | | hairColor = newModel.hairColor; |
| 0 | 50 | | skinColor = newModel.skinColor; |
| 0 | 51 | | eyesColor = newModel.eyesColor; |
| 0 | 52 | | forceRender = new HashSet<string>(newModel.forceRender); |
| 0 | 53 | | } |
| | 54 | | } |
| | 55 | | } |