Skip to content

Commit

Permalink
yet another refactor iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
pravusjif committed Jan 30, 2025
1 parent a69a2d4 commit 82b102d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public LoadOwnedEmotesSystem(
IRealmData realmData,
IWebRequestController webRequestController,
IStreamableCache<EmotesResolution, GetOwnedEmotesFromRealmIntention> cache,
IEmoteStorage emoteStorage
) : base(world, cache, emoteStorage, webRequestController, realmData) { }
IEmoteStorage emoteStorage,
string? builderContentURL = null
) : base(world, cache, emoteStorage, webRequestController, realmData, builderContentURL) { }

protected override async UniTask<IAttachmentLambdaResponse<ILambdaResponseElement<EmoteDTO>>> ParseResponseAsync(GenericDownloadHandlerUtils.Adapter<GenericGetRequest, GenericGetArguments> adapter) =>
await adapter.CreateFromJson<LambdaOwnedEmoteElementList>(WRJsonParser.Unity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class AvatarAttachmentDTO
public long timestamp;
public string version;
public Content[] content;
public string? ContentDownloadUrl;
public string? ContentDownloadUrl { get; protected set; }

public abstract MetadataBase Metadata { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public interface IBuilderLambdaResponseElement<out TElementDTO>
{
IReadOnlyDictionary<string, string> Contents { get; }

TElementDTO BuildWearableDTO();
TElementDTO BuildWearableDTO(string contentDownloadUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ public abstract class LoadElementsByIntentionSystem<TAsset, TIntention, TAvatarE
private readonly IAvatarElementStorage<TAvatarElement, TAvatarElementDTO> avatarElementStorage;
private readonly IWebRequestController webRequestController;
private readonly IRealmData realmData;
private readonly string? builderContentURL;

protected LoadElementsByIntentionSystem(
World world,
IStreamableCache<TAsset, TIntention> cache,
IAvatarElementStorage<TAvatarElement, TAvatarElementDTO> avatarElementStorage,
IWebRequestController webRequestController,
IRealmData realmData
IRealmData realmData,
string? builderContentURL = null
) : base(world, cache)
{
this.avatarElementStorage = avatarElementStorage;
this.webRequestController = webRequestController;
this.realmData = realmData;
this.builderContentURL = builderContentURL;
}

protected sealed override async UniTask<StreamableLoadingResult<TAsset>> FlowInternalAsync(TIntention intention,
Expand Down Expand Up @@ -120,11 +123,13 @@ private void Load<TResponseElement>(ref TIntention intention, IAttachmentLambdaR
// private void LoadBuilderItem<TResponseElement>(ref TIntention intention, IBuilderLambdaResponse<TResponseElement> lambdaResponse) where TResponseElement : IBuilderLambdaResponseElement<TAvatarElementDTO>
private void LoadBuilderItem(ref TIntention intention, IBuilderLambdaResponse<IBuilderLambdaResponseElement<TAvatarElementDTO>> lambdaResponse)
{
if (string.IsNullOrEmpty(builderContentURL)) return;

intention.SetTotal(lambdaResponse.WearablesCollection.Count);

foreach (var element in lambdaResponse.WearablesCollection)
{
var wearable = avatarElementStorage.GetOrAddByDTO(element.BuildWearableDTO());
var wearable = avatarElementStorage.GetOrAddByDTO(element.BuildWearableDTO(builderContentURL));
intention.AppendToResult(wearable);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public class LambdaResponseElementDto : ILambdaResponseElement<WearableDTO>
[JsonIgnore]
public IReadOnlyList<ElementIndividualDataDto> IndividualData => individualData;
}
}

[Serializable]
public class BuilderWearableDTO : WearableDTO
{
[Serializable]
public struct BuilderLambdaResponse : IBuilderLambdaResponse<BuilderWearableMetadataDto>
{
Expand All @@ -62,15 +66,15 @@ public struct BuilderLambdaResponse : IBuilderLambdaResponse<BuilderWearableMeta
}

[Serializable]
public class BuilderWearableMetadataDto : WearableMetadataDto, IBuilderLambdaResponseElement<WearableDTO>
public class BuilderWearableMetadataDto : WearableMetadataDto, IBuilderLambdaResponseElement<BuilderWearableDTO>
{
public Dictionary<string, string> contents;
public string type;

[JsonIgnore]
public IReadOnlyDictionary<string, string> Contents => contents;

public WearableDTO BuildWearableDTO()
public BuilderWearableDTO BuildWearableDTO(string contentDownloadUrl)
{
Content[] parsedContent = new Content[contents.Count];
int i = 0;
Expand All @@ -80,12 +84,9 @@ public WearableDTO BuildWearableDTO()
i++;
}

return new WearableDTO()
return new BuilderWearableDTO()
{
// Take this from DecentralandUrl.BuilderApiContent but HOW ???
// Maybe avoid using it from here and rely on NeedsBuilderAPISigning
// to use the DecentralandUrl.BuilderApiContent url ?
ContentDownloadUrl = "https://builder-api.decentraland.org/v1/storage/contents/",
ContentDownloadUrl = contentDownloadUrl,
metadata = this,
id = this.id,
type = this.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public partial class LoadWearablesByParamSystem : LoadElementsByIntentionSystem<
public LoadWearablesByParamSystem(
World world, IWebRequestController webRequestController, IStreamableCache<WearablesResponse, GetWearableByParamIntention> cache,
IRealmData realmData, URLSubdirectory lambdaSubdirectory, URLSubdirectory wearablesSubdirectory,
IWearableStorage wearableStorage
) : base(world, cache, wearableStorage, webRequestController, realmData)
IWearableStorage wearableStorage, string? builderContentURL = null
) : base(world, cache, wearableStorage, webRequestController, realmData, builderContentURL)
{
this.realmData = realmData;
this.lambdaSubdirectory = lambdaSubdirectory;
Expand Down Expand Up @@ -71,7 +71,7 @@ protected override async UniTask<IAttachmentLambdaResponse<ILambdaResponseElemen

protected override async UniTask<IBuilderLambdaResponse<IBuilderLambdaResponseElement<WearableDTO>>> ParseBuilderResponseAsync(GenericDownloadHandlerUtils.Adapter<GenericGetRequest, GenericGetArguments> adapter)
{
var result = await adapter.CreateFromJson<WearableDTO.BuilderLambdaResponse>(WRJsonParser.Newtonsoft);
var result = await adapter.CreateFromJson<BuilderWearableDTO.BuilderLambdaResponse>(WRJsonParser.Newtonsoft);
return result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Explorer/Assets/DCL/PluginSystem/Global/EmotePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder<Arch.Core.World> builder,

LoadOwnedEmotesSystem.InjectToWorld(ref builder, realmData, webRequestController,
new NoCache<EmotesResolution, GetOwnedEmotesFromRealmIntention>(false, false),
emoteStorage);
emoteStorage, builderContentURL.Value);

CharacterEmoteSystem.InjectToWorld(ref builder, emoteStorage, messageBus, audioSourceReference, debugBuilder);

Expand Down
2 changes: 1 addition & 1 deletion Explorer/Assets/DCL/PluginSystem/Global/WearablePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async UniTask InitializeAsync(WearableSettings settings, CancellationToke
public void InjectToWorld(ref ArchSystemsWorldBuilder<World> builder, in GlobalPluginArguments arguments)
{
FinalizeWearableLoadingSystem.InjectToWorld(ref builder, wearableStorage, realmData, WEARABLES_EMBEDDED_SUBDIRECTORY);
LoadWearablesByParamSystem.InjectToWorld(ref builder, webRequestController, new NoCache<WearablesResponse, GetWearableByParamIntention>(false, false), realmData, EXPLORER_SUBDIRECTORY, WEARABLES_COMPLEMENT_URL, wearableStorage);
LoadWearablesByParamSystem.InjectToWorld(ref builder, webRequestController, new NoCache<WearablesResponse, GetWearableByParamIntention>(false, false), realmData, EXPLORER_SUBDIRECTORY, WEARABLES_COMPLEMENT_URL, wearableStorage, builderContentURL.Value);
LoadWearablesDTOByPointersSystem.InjectToWorld(ref builder, webRequestController, new NoCache<WearablesDTOList, GetWearableDTOByPointersIntention>(false, false));
LoadWearableAssetBundleManifestSystem.InjectToWorld(ref builder, new NoCache<SceneAssetBundleManifest, GetWearableAssetBundleManifestIntention>(true, true), assetBundleURL, webRequestController);
LoadDefaultWearablesSystem.InjectToWorld(ref builder, defaultWearablesDTOs, defaultEmptyWearableAsset, wearableStorage);
Expand Down

0 comments on commit 82b102d

Please sign in to comment.