diff --git a/SightKeeper.Data/Binary/Model/DataSets/PackableDataSet.cs b/SightKeeper.Data/Binary/Model/DataSets/PackableDataSet.cs index 4c7e5c0b..050016cb 100644 --- a/SightKeeper.Data/Binary/Model/DataSets/PackableDataSet.cs +++ b/SightKeeper.Data/Binary/Model/DataSets/PackableDataSet.cs @@ -39,6 +39,7 @@ public PackableDataSet( } public abstract ImmutableArray GetTags(); + public abstract ImmutableArray GetAssets(); } /// @@ -73,4 +74,9 @@ public sealed override ImmutableArray GetTags() { return ImmutableArray.CastUp(Tags); } + + public sealed override ImmutableArray GetAssets() + { + return ImmutableArray.CastUp(Assets); + } } \ No newline at end of file diff --git a/SightKeeper.Data/Binary/Replication/DataSetReplicator.cs b/SightKeeper.Data/Binary/Replication/DataSetReplicator.cs index ad01aa22..339e6283 100644 --- a/SightKeeper.Data/Binary/Replication/DataSetReplicator.cs +++ b/SightKeeper.Data/Binary/Replication/DataSetReplicator.cs @@ -1,11 +1,13 @@ using System.Collections.Immutable; using CommunityToolkit.Diagnostics; using SightKeeper.Data.Binary.Model.DataSets; +using SightKeeper.Data.Binary.Model.DataSets.Assets; using SightKeeper.Data.Binary.Model.DataSets.Compositions; using SightKeeper.Data.Binary.Model.DataSets.Tags; using SightKeeper.Data.Binary.Services; using SightKeeper.Domain.Model; using SightKeeper.Domain.Model.DataSets; +using SightKeeper.Domain.Model.DataSets.Assets; using SightKeeper.Domain.Model.DataSets.Screenshots; using SightKeeper.Domain.Model.DataSets.Tags; @@ -13,6 +15,8 @@ namespace SightKeeper.Data.Binary.Replication; internal abstract class DataSetReplicator { + protected delegate Tag TagGetter(byte TagId, byte? KeyPointTagId = null); + public DataSetReplicator(FileSystemScreenshotsDataAccess screenshotsDataAccess) { _screenshotsDataAccess = screenshotsDataAccess; @@ -26,6 +30,7 @@ public DataSet Replicate(PackableDataSet packed, ReplicationSession session) var dataSet = CreateDataSet(packed.Name, packed.Description, game, composition); ReplicateScreenshots(dataSet.Screenshots, packed.Screenshots); var tagsLookup = ReplicateTags(dataSet.Tags, packed.GetTags()); + ReplicateAssets(dataSet.Assets, packed.GetAssets(), (tagId, keyPointTagId) => tagsLookup[(tagId, keyPointTagId)]); return dataSet; } @@ -43,6 +48,8 @@ protected virtual Tag ReplicateTag( return tag; } + protected abstract void ReplicateAsset(AssetsLibrary library, PackableAsset asset, TagGetter getTag); + private readonly FileSystemScreenshotsDataAccess _screenshotsDataAccess; private static Composition ReplicateComposition(PackableComposition? composition) @@ -74,4 +81,10 @@ private void ReplicateScreenshots(ScreenshotsLibrary library, ImmutableArray assets, TagGetter getTag) + { + foreach (var asset in assets) + ReplicateAsset(library, asset, getTag); + } } \ No newline at end of file