From ba1a149e8fc402cd3775ea7c597d7398df7abbec Mon Sep 17 00:00:00 2001 From: Juli Milloch <42394626+Julieta11@users.noreply.github.com> Date: Wed, 31 May 2023 21:55:19 +0200 Subject: [PATCH] feat: add `forceRenderer` property (#5259) * feat: add `forceRenderer` property * chore: undo change in default profile * chore: upgrade schema version * fix: correct entity build * fix: string as wearable category * fix: optional property * Minor changes for forceRender * Minor change * Fix * Added DTOs to allow serialization of hashsets * forceRender various fixes * Minor changes --------- Co-authored-by: davidejensen --- browser-interface/package-lock.json | 78 +++++++++++++++++-- browser-interface/package.json | 2 +- .../sceneRuntime/AvatarForUserData.ts | 3 +- .../sceneRuntimeCompatibleAvatar.ts | 1 + .../profileToRendererFormat.ts | 1 + .../transformations/profileToServerFormat.ts | 1 + .../profiles/sagas/handleDeployProfile.ts | 17 +++- .../unity-interface/BrowserInterface.ts | 7 +- .../DCL/Components/Avatar/AvatarShape.cs | 2 +- .../BackpackEditorHUDController.cs | 16 ++-- .../BackpackEditorHUDModel.cs | 3 +- .../CharacterPreviewController.cs | 2 +- .../PlayerAvatarController.cs | 1 + .../DCL/Models/AvatarModel/AvatarModel.cs | 29 ++++++- .../DCL/Models/AvatarModel/AvatarModelDTO.cs | 47 +++++++++++ .../Models/AvatarModel/AvatarModelDTO.cs.meta | 11 +++ .../DCL/UserProfile/UserProfileController.cs | 5 +- .../DCL/UserProfile/UserProfileModel.cs | 3 + .../DCL/UserProfile/UserProfileModelDTO.cs | 54 +++++++++++++ .../UserProfile/UserProfileModelDTO.cs.meta | 11 +++ .../MainScripts/DCL/WebInterface/Interface.cs | 5 +- .../DCL/WebInterface/WebInterface.asmdef | 3 +- 22 files changed, 272 insertions(+), 30 deletions(-) create mode 100644 unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs create mode 100644 unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs.meta create mode 100644 unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs create mode 100644 unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs.meta diff --git a/browser-interface/package-lock.json b/browser-interface/package-lock.json index 59ead7bb5f..3a2c9845e4 100644 --- a/browser-interface/package-lock.json +++ b/browser-interface/package-lock.json @@ -19,7 +19,7 @@ "@dcl/protocol": "1.0.0-5112230174.commit-a71a7e0", "@dcl/rpc": "^1.1.1", "@dcl/scene-runtime": "7.0.6-20230529131607.commit-637ca18", - "@dcl/schemas": "^6.11.1", + "@dcl/schemas": "^7.2.0", "@dcl/urn-resolver": "^2.0.3", "@types/mocha": "^10.0.1", "@types/redux-logger": "^3.0.9", @@ -497,6 +497,16 @@ "ethereum-cryptography": "^1.0.3" } }, + "node_modules/@dcl/crypto/node_modules/@dcl/schemas": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.19.0.tgz", + "integrity": "sha512-S8lrq8L1vriVXkBzeycxppjbfgJ5XofA9pbCKdteJR+79r6Dn5oLo3t5g7RcMQDihdjWdDLbbwxlEAkPgmvc8w==", + "dependencies": { + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } + }, "node_modules/@dcl/ecs-math": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@dcl/ecs-math/-/ecs-math-1.0.3.tgz", @@ -592,9 +602,9 @@ "integrity": "sha512-2CrhAg+kZ8agg+yVpBS1VKExBkiClyNwns6JuNb5yznx0+ze1XqT8ySGPZQv+Xat4S+U44+Bb6EXzPDBtnX8ww==" }, "node_modules/@dcl/schemas": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.18.1.tgz", - "integrity": "sha512-Us8E1FoJhG7jRRLjixkt6U79zD7oROdsjydo4t0t381xiNFZNUdclJQY6PGwEKCvPvO30cSR4OZCbqUT4DaFHg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-7.2.0.tgz", + "integrity": "sha512-oULCVSczP5bhfur95aWJ8iKVHl4gLH8++8CMyncTVKAeFhAjPLTE8lqpZmGPPkhd05/Crw/WALXT7ghukMlkQg==", "dependencies": { "ajv": "^8.11.0", "ajv-errors": "^3.0.0", @@ -2686,6 +2696,16 @@ "form-data": "^4.0.0" } }, + "node_modules/dcl-catalyst-client/node_modules/@dcl/schemas": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.19.0.tgz", + "integrity": "sha512-S8lrq8L1vriVXkBzeycxppjbfgJ5XofA9pbCKdteJR+79r6Dn5oLo3t5g7RcMQDihdjWdDLbbwxlEAkPgmvc8w==", + "dependencies": { + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } + }, "node_modules/dcl-catalyst-commons": { "version": "9.0.21", "resolved": "https://registry.npmjs.org/dcl-catalyst-commons/-/dcl-catalyst-commons-9.0.21.tgz", @@ -2702,6 +2722,16 @@ "npm": ">=7.0.0" } }, + "node_modules/dcl-catalyst-commons/node_modules/@dcl/schemas": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.19.0.tgz", + "integrity": "sha512-S8lrq8L1vriVXkBzeycxppjbfgJ5XofA9pbCKdteJR+79r6Dn5oLo3t5g7RcMQDihdjWdDLbbwxlEAkPgmvc8w==", + "dependencies": { + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } + }, "node_modules/dcl-catalyst-commons/node_modules/cookie": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", @@ -10295,6 +10325,18 @@ "@dcl/schemas": "^6.4.2", "eth-connect": "^6.0.3", "ethereum-cryptography": "^1.0.3" + }, + "dependencies": { + "@dcl/schemas": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.19.0.tgz", + "integrity": "sha512-S8lrq8L1vriVXkBzeycxppjbfgJ5XofA9pbCKdteJR+79r6Dn5oLo3t5g7RcMQDihdjWdDLbbwxlEAkPgmvc8w==", + "requires": { + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } + } } }, "@dcl/ecs-math": { @@ -10392,9 +10434,9 @@ "integrity": "sha512-2CrhAg+kZ8agg+yVpBS1VKExBkiClyNwns6JuNb5yznx0+ze1XqT8ySGPZQv+Xat4S+U44+Bb6EXzPDBtnX8ww==" }, "@dcl/schemas": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.18.1.tgz", - "integrity": "sha512-Us8E1FoJhG7jRRLjixkt6U79zD7oROdsjydo4t0t381xiNFZNUdclJQY6PGwEKCvPvO30cSR4OZCbqUT4DaFHg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-7.2.0.tgz", + "integrity": "sha512-oULCVSczP5bhfur95aWJ8iKVHl4gLH8++8CMyncTVKAeFhAjPLTE8lqpZmGPPkhd05/Crw/WALXT7ghukMlkQg==", "requires": { "ajv": "^8.11.0", "ajv-errors": "^3.0.0", @@ -12021,6 +12063,18 @@ "cookie": "^0.5.0", "dcl-catalyst-commons": "^9.0.6", "form-data": "^4.0.0" + }, + "dependencies": { + "@dcl/schemas": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.19.0.tgz", + "integrity": "sha512-S8lrq8L1vriVXkBzeycxppjbfgJ5XofA9pbCKdteJR+79r6Dn5oLo3t5g7RcMQDihdjWdDLbbwxlEAkPgmvc8w==", + "requires": { + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } + } } }, "dcl-catalyst-commons": { @@ -12035,6 +12089,16 @@ "ms": "^2.1.2" }, "dependencies": { + "@dcl/schemas": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-6.19.0.tgz", + "integrity": "sha512-S8lrq8L1vriVXkBzeycxppjbfgJ5XofA9pbCKdteJR+79r6Dn5oLo3t5g7RcMQDihdjWdDLbbwxlEAkPgmvc8w==", + "requires": { + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } + }, "cookie": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", diff --git a/browser-interface/package.json b/browser-interface/package.json index 07a9c23ed3..8fa094377e 100644 --- a/browser-interface/package.json +++ b/browser-interface/package.json @@ -65,7 +65,7 @@ "@dcl/protocol": "1.0.0-5112230174.commit-a71a7e0", "@dcl/rpc": "^1.1.1", "@dcl/scene-runtime": "7.0.6-20230529131607.commit-637ca18", - "@dcl/schemas": "^6.11.1", + "@dcl/schemas": "^7.2.0", "@dcl/urn-resolver": "^2.0.3", "@types/mocha": "^10.0.1", "@types/redux-logger": "^3.0.9", diff --git a/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/AvatarForUserData.ts b/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/AvatarForUserData.ts index 5032ddb963..a5c7de2a0a 100644 --- a/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/AvatarForUserData.ts +++ b/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/AvatarForUserData.ts @@ -1,4 +1,4 @@ -import type { Snapshots, WearableId } from '@dcl/schemas' +import type { Snapshots, WearableCategory, WearableId } from '@dcl/schemas' export type AvatarForUserData = { bodyShape: WearableId @@ -6,6 +6,7 @@ export type AvatarForUserData = { hairColor: string eyeColor: string wearables: WearableId[] + forceRender?: WearableCategory[] emotes?: { slot: number urn: string diff --git a/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/sceneRuntimeCompatibleAvatar.ts b/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/sceneRuntimeCompatibleAvatar.ts index c2e12a3f4a..be9e318aee 100644 --- a/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/sceneRuntimeCompatibleAvatar.ts +++ b/browser-interface/packages/lib/decentraland/profiles/sceneRuntime/sceneRuntimeCompatibleAvatar.ts @@ -7,6 +7,7 @@ export function sceneRuntimeCompatibleAvatar(avatar: AvatarInfo): AvatarForUserD ...avatar, bodyShape: avatar?.bodyShape, wearables: avatar?.wearables || [], + forceRender: avatar?.forceRender || [], snapshots: { ...avatar.snapshots, face: avatar.snapshots.face256, diff --git a/browser-interface/packages/lib/decentraland/profiles/transformations/profileToRendererFormat.ts b/browser-interface/packages/lib/decentraland/profiles/transformations/profileToRendererFormat.ts index 1d77b674cf..ad653e50c3 100644 --- a/browser-interface/packages/lib/decentraland/profiles/transformations/profileToRendererFormat.ts +++ b/browser-interface/packages/lib/decentraland/profiles/transformations/profileToRendererFormat.ts @@ -81,6 +81,7 @@ function defaultAvatar(): Omit { function prepareAvatar(avatar?: Partial) { return { wearables: avatar?.wearables || [], + forceRender: avatar?.forceRender || [], emotes: avatar?.emotes || [], bodyShape: avatar?.bodyShape || '', eyeColor: convertToRGBObject(avatar?.eyes?.color), diff --git a/browser-interface/packages/lib/decentraland/profiles/transformations/profileToServerFormat.ts b/browser-interface/packages/lib/decentraland/profiles/transformations/profileToServerFormat.ts index 21e3aa8cfc..6f3c18d667 100644 --- a/browser-interface/packages/lib/decentraland/profiles/transformations/profileToServerFormat.ts +++ b/browser-interface/packages/lib/decentraland/profiles/transformations/profileToServerFormat.ts @@ -19,6 +19,7 @@ export function ensureAvatarCompatibilityFormat(profile: Readonly = { hairColor: color3Schema, skinColor: color3Schema, wearables: { type: 'array', items: { type: 'string' } }, + forceRender: { type: 'array', items: { type: 'string' }, nullable: true }, emotes: { type: 'array', items: emoteSchema } } } @@ -220,6 +222,7 @@ export const rendererSaveProfileSchemaV1: JSONSchema = { hairColor: color3Schema, skinColor: color3Schema, wearables: { type: 'array', items: { type: 'string' } }, + forceRender: { type: 'array', items: { type: 'string' }, nullable: true }, emotes: { type: 'array', items: emoteSchema } } } @@ -436,6 +439,7 @@ export class BrowserInterface { hair: { color: changes.avatar.hairColor }, skin: { color: changes.avatar.skinColor }, wearables: changes.avatar.wearables, + forceRender: (changes.avatar.forceRender ?? []).map((category) => category as WearableCategory), snapshots: { body: changes.body, face256: changes.face256 @@ -452,6 +456,7 @@ export class BrowserInterface { hair: { color: changes.avatar.hairColor }, skin: { color: changes.avatar.skinColor }, wearables: changes.avatar.wearables, + forceRender: (changes.avatar.forceRender ?? []).map((category) => category as WearableCategory), emotes: (changes.avatar.emotes ?? []).map((value, index) => ({ slot: index, urn: value as any as string })), snapshots: { body: changes.body, diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs index 0cfa2ed252..487d1d12e7 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs @@ -145,7 +145,6 @@ public override IEnumerator ApplyChanges(BaseModel newModel) isGlobalSceneAvatar = scene.sceneData.sceneNumber == EnvironmentSettings.AVATAR_GLOBAL_SCENE_NUMBER; var model = (AvatarModel) newModel; - bool needsLoading = !model.HaveSameWearablesAndColors(currentAvatar); currentAvatar.CopyFrom(model); @@ -214,6 +213,7 @@ public override IEnumerator ApplyChanges(BaseModel newModel) eyesColor = model.eyeColor, skinColor = model.skinColor, hairColor = model.hairColor, + forceRender = new HashSet(userProfileBridge.Get(model.id).avatar.forceRender ?? new HashSet()), }, loadingCts.Token); // Yielding a UniTask doesn't do anything, we manually wait until the avatar is ready diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs index 485f86d13b..fd3663a90a 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs @@ -221,7 +221,7 @@ async UniTaskVoid LoadUserProfileAsync(UserProfile userProfile, CancellationToke model.skinColor = userProfile.avatar.skinColor; model.hairColor = userProfile.avatar.hairColor; model.eyesColor = userProfile.avatar.eyeColor; - + model.forceRender = new HashSet(userProfile.avatar.forceRender); model.wearables.Clear(); previewEquippedWearables.Clear(); @@ -243,9 +243,10 @@ async UniTaskVoid LoadUserProfileAsync(UserProfile userProfile, CancellationToke } } - EquipWearable(wearable, EquipWearableSource.None, false, false); + EquipWearable(wearable, EquipWearableSource.None, false, false, false); } + avatarSlotsHUDController.Recalculate(model.forceRender); view.UpdateAvatarPreview(model.ToAvatarModel()); } catch (OperationCanceledException) { } @@ -395,7 +396,8 @@ private void UnEquipWearableFromSlot(string wearableId, UnequipWearableSource so private void EquipWearable(string wearableId, EquipWearableSource source = EquipWearableSource.None, bool setAsDirty = true, - bool updateAvatarPreview = true) + bool updateAvatarPreview = true, + bool resetOverride = true) { if (!wearablesCatalogService.WearablesCatalog.TryGetValue(wearableId, out WearableItem wearable)) { @@ -403,13 +405,14 @@ private void EquipWearable(string wearableId, return; } - EquipWearable(wearable, source, setAsDirty, updateAvatarPreview); + EquipWearable(wearable, source, setAsDirty, updateAvatarPreview, resetOverride); } private void EquipWearable(WearableItem wearable, EquipWearableSource source = EquipWearableSource.None, bool setAsDirty = true, - bool updateAvatarPreview = true) + bool updateAvatarPreview = true, + bool resetOverride = true) { string wearableId = wearable.id; @@ -432,7 +435,8 @@ private void EquipWearable(WearableItem wearable, model.wearables.Add(wearableId, wearable); previewEquippedWearables.Add(wearableId); - ResetOverridesOfAffectedCategories(wearable, setAsDirty); + if (resetOverride) + ResetOverridesOfAffectedCategories(wearable, setAsDirty); avatarSlotsHUDController.Equip(wearable, ownUserProfile.avatar.bodyShape, model.forceRender); wearableGridController.Equip(wearableId); diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs index da56db038f..216be669e5 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs @@ -22,7 +22,7 @@ public AvatarModel ToAvatarModel() hairColor = hairColor, skinColor = skinColor, eyeColor = eyesColor, - forceRender = forceRender + forceRender = new HashSet(forceRender) }; } @@ -36,6 +36,7 @@ public void Update(BackpackEditorHUDModel newModel) hairColor = newModel.hairColor; skinColor = newModel.skinColor; eyesColor = newModel.eyesColor; + forceRender = new HashSet(newModel.forceRender); } } } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/CharacterPreview/CharacterPreviewController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/CharacterPreview/CharacterPreviewController.cs index 93d0aa4293..c0c4155a2d 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/CharacterPreview/CharacterPreviewController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/CharacterPreview/CharacterPreviewController.cs @@ -132,7 +132,7 @@ private async UniTask UpdateModelAsync(AvatarModel newModel, CancellationToken c eyesColor = newModel.eyeColor, hairColor = newModel.hairColor, skinColor = newModel.skinColor, - forceRender = newModel.forceRender + forceRender = new HashSet(newModel.forceRender) }, ct); } catch (Exception e) when (e is not OperationCanceledException) { Debug.LogException(e); } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs index aa4700d426..90517158e6 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs @@ -222,6 +222,7 @@ private async UniTaskVoid LoadingAvatarRoutine(UserProfile profile, Cancellation eyesColor = profile.avatar.eyeColor, skinColor = profile.avatar.skinColor, hairColor = profile.avatar.hairColor, + forceRender = new HashSet(profile.avatar.forceRender) }, ct); if (avatar.lodLevel <= 1) diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs index d9d4e5a3c3..6e9b96f9fd 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs @@ -119,6 +119,10 @@ public bool Equals(AvatarModel other) && other.wearables.All(wearables.Contains) && wearables.Count == other.wearables.Count; + bool forceRenderAreEqual = forceRender.All(other.forceRender.Contains) + && other.forceRender.All(forceRender.Contains) + && forceRender.Count == other.forceRender.Count; + return id == other.id && name == other.name && bodyShape == other.bodyShape && @@ -127,7 +131,8 @@ public bool Equals(AvatarModel other) eyeColor == other.eyeColor && expressionTriggerId == other.expressionTriggerId && expressionTriggerTimestamp == other.expressionTriggerTimestamp && - wearablesAreEqual; + wearablesAreEqual && + forceRenderAreEqual; } public void CopyFrom(AvatarModel other) @@ -145,10 +150,30 @@ public void CopyFrom(AvatarModel other) expressionTriggerTimestamp = other.expressionTriggerTimestamp; wearables = new List(other.wearables); emotes = other.emotes.Select(x => new AvatarEmoteEntry() { slot = x.slot, urn = x.urn }).ToList(); + forceRender = new HashSet(other.forceRender); } public override BaseModel GetDataFromJSON(string json) => Utils.SafeFromJson(json); - + public AvatarModelDTO ToAvatarModelDto() + { + AvatarModelDTO avatarModelDto = new AvatarModelDTO + { + id = this.id, + name = this.name, + bodyShape = this.bodyShape, + skinColor = this.skinColor, + hairColor = this.hairColor, + eyeColor = this.eyeColor, + wearables = this.wearables, + forceRender = this.forceRender.ToList(), + emotes = this.emotes, + expressionTriggerId = this.expressionTriggerId, + expressionTriggerTimestamp = this.expressionTriggerTimestamp, + talking = this.talking, + }; + + return avatarModelDto; + } } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs new file mode 100644 index 0000000000..75a0fbc990 --- /dev/null +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs @@ -0,0 +1,47 @@ +using System; +using DCL.Helpers; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using Decentraland.Sdk.Ecs6; +using MainScripts.DCL.Components; + +[Serializable] +public class AvatarModelDTO +{ + public string id; + public string name; + public string bodyShape; + public Color skinColor; + public Color hairColor; + public Color eyeColor; + public List wearables = new List(); + public List forceRender = new List(); + + public List emotes = new List(); + + public string expressionTriggerId = null; + public long expressionTriggerTimestamp = -1; + public bool talking = false; + + public AvatarModel ToAvatarModel() + { + AvatarModel avatarModel = new AvatarModel + { + id = this.id, + name = this.name, + bodyShape = this.bodyShape, + skinColor = this.skinColor, + hairColor = this.hairColor, + eyeColor = this.eyeColor, + wearables = this.wearables, + forceRender = new HashSet(this.forceRender), + emotes = this.emotes, + expressionTriggerId = this.expressionTriggerId, + expressionTriggerTimestamp = this.expressionTriggerTimestamp, + talking = this.talking, + }; + + return avatarModel; + } +} diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs.meta b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs.meta new file mode 100644 index 0000000000..078f0f6d49 --- /dev/null +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModelDTO.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aebf630175b974b14887d750d2806754 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileController.cs index 6674826a5f..cca108562b 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileController.cs @@ -68,13 +68,12 @@ async UniTaskVoid RequestBaseWearablesAsync(CancellationToken ct) if (payload == null) return; - var model = JsonUtility.FromJson(payload); - + var model = JsonUtility.FromJson(payload).ToUserProfileModel(); ownUserProfile.UpdateData(model); userProfilesCatalog.Add(model.userId, ownUserProfile); } - public void AddUserProfileToCatalog(string payload) { AddUserProfileToCatalog(JsonUtility.FromJson(payload)); } + public void AddUserProfileToCatalog(string payload) { AddUserProfileToCatalog(JsonUtility.FromJson(payload).ToUserProfileModel()); } public void AddUserProfilesToCatalog(string payload) { diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModel.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModel.cs index 075e5b40c3..7e892cec9b 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModel.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModel.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; [System.Serializable] public class UserProfileModel @@ -126,4 +127,6 @@ public string ComposeCorrectUrl(string url) return baseUrl + url; } + + } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs new file mode 100644 index 0000000000..cc53ef9b78 --- /dev/null +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; + +[System.Serializable] +public class UserProfileModelDTO +{ + public string userId; + public string ethAddress; + public string name; + public string email; + public string description; + public string baseUrl; + public UserProfileModel.ParcelsWithAccess[] parcelsWithAccess; + public ulong created_at; + public ulong updated_at; + public int version; + public AvatarModelDTO avatar; + public UserProfileModel.Snapshots snapshots = new UserProfileModel.Snapshots(); + + public bool hasConnectedWeb3 = true; + + public int tutorialFlagsMask; + public List blocked; + public List muted; + public int tutorialStep; + public bool hasClaimedName = false; + + public UserProfileModel ToUserProfileModel() + { + UserProfileModel userProfileModel = new UserProfileModel + { + userId = this.userId, + ethAddress = this.ethAddress, + name = this.name, + email = this.email, + description = this.description, + baseUrl = this.baseUrl, + parcelsWithAccess = this.parcelsWithAccess, + created_at = this.created_at, + updated_at = this.updated_at, + version = this.version, + avatar = this.avatar.ToAvatarModel(), + snapshots = this.snapshots, + hasConnectedWeb3 = this.hasConnectedWeb3, + tutorialFlagsMask = this.tutorialFlagsMask, + blocked = this.blocked, + muted = this.muted, + tutorialStep = this.tutorialStep, + hasClaimedName = this.hasClaimedName, + }; + + return userProfileModel; + } + +} diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs.meta b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs.meta new file mode 100644 index 0000000000..9063c6feb9 --- /dev/null +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/UserProfileModelDTO.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e14aa9bcc6f124ebeb0abd8a83d12ac5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs index 658744975e..d50f3ccbe7 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs @@ -1310,7 +1310,7 @@ public class SaveAvatarPayload public string face256; public string body; public bool isSignUpFlow; - public AvatarModel avatar; + public AvatarModelDTO avatar; } public static class RendererAuthenticationType @@ -1367,9 +1367,10 @@ public class SendVideoProgressEvent public static void SendSaveAvatar(AvatarModel avatar, Texture2D face256Snapshot, Texture2D bodySnapshot, bool isSignUpFlow = false) { + var payload = new SaveAvatarPayload() { - avatar = avatar, + avatar = avatar.ToAvatarModelDto(), face256 = System.Convert.ToBase64String(face256Snapshot.EncodeToPNG()), body = System.Convert.ToBase64String(bodySnapshot.EncodeToPNG()), isSignUpFlow = isSignUpFlow diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/WebInterface.asmdef b/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/WebInterface.asmdef index eae91e1523..2cc959298f 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/WebInterface.asmdef +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/WebInterface.asmdef @@ -11,7 +11,8 @@ "GUID:6e6a87f97192ec947993f360104e75b7", "GUID:f51ebe6a0ceec4240a699833d6309b23", "GUID:fbcc413e192ef9048811d47ab0aca0c0", - "GUID:3b80b0b562b1cbc489513f09fc1b8f69" + "GUID:3b80b0b562b1cbc489513f09fc1b8f69", + "GUID:a78c5d8dad39efe45ab1b21901f8db0f" ], "includePlatforms": [], "excludePlatforms": [],