-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for specifying an extension, with an optional feature flag, to MasterAsset. This will generate code that loads an additional file to override the contents of a master asset at load time, which will be gated by the feature flag if specified. This is primarily to enable some small-scale "mods" that I want to implement, specifically around boosting daily endeavour rewards in the absence of regular events. All such mods will be put behind feature flags so that they can be turned off and this project can still act as a 'reference implementation' of a vanilla Dragalia Lost backend. A secondary purpose, which has been used as a test run here, is to 'patch' the MasterAsset where it contains incorrect data. A previous workaround for welfare adventurer story IDs being incorrect has been repurposed to use this new functionality.
- Loading branch information
1 parent
3d0d8b4
commit 2ae2105
Showing
32 changed files
with
1,139 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...sterAssetGeneratorTest.GeneratesMasterAssetCorrectly#MasterAsset.Extensions.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//HintName: MasterAsset.Extensions.g.cs | ||
// <auto-generated/> | ||
|
||
#nullable enable | ||
|
||
namespace DragaliaAPI.Shared.MasterAsset; | ||
|
||
public static partial class MasterAsset | ||
{ | ||
private static async Task<List<TItem>> LoadFile<TItem>(string msgpackPath) | ||
{ | ||
string path = Path.Join( | ||
global::System.IO.Path.GetDirectoryName(global::System.Reflection.Assembly.GetExecutingAssembly().Location), | ||
"Resources", | ||
msgpackPath | ||
); | ||
|
||
await using FileStream fs = File.OpenRead(path); | ||
|
||
return await global::MessagePack.MessagePackSerializer.DeserializeAsync<List<TItem>>( | ||
fs, | ||
MasterAssetMessagePackOptions.Instance | ||
) ?? throw new global::MessagePack.MessagePackSerializationException($"Deserialized MasterAsset extension for {path} was null"); | ||
} | ||
|
||
public static async global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::DragaliaAPI.Shared.MasterAsset.Models.Event.EventData>> LoadEventDataExtension(global::Microsoft.FeatureManagement.IFeatureManager featureManager) | ||
{ | ||
global::System.Collections.Generic.List<global::DragaliaAPI.Shared.MasterAsset.Models.Event.EventData> extendedData = []; | ||
|
||
extendedData.AddRange(await LoadFile<global::DragaliaAPI.Shared.MasterAsset.Models.Event.EventData>("Event/BuildEventReward.extension.msgpack")); | ||
|
||
return extendedData; | ||
} | ||
|
||
public static async global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::DragaliaAPI.Shared.MasterAsset.Models.DragonData>> LoadDragonDataExtension(global::Microsoft.FeatureManagement.IFeatureManager featureManager) | ||
{ | ||
global::System.Collections.Generic.List<global::DragaliaAPI.Shared.MasterAsset.Models.DragonData> extendedData = []; | ||
|
||
if (await featureManager.IsEnabledAsync("ModdedDragons")) | ||
{ | ||
extendedData.AddRange(await LoadFile<global::DragaliaAPI.Shared.MasterAsset.Models.DragonData>("DragonData.modded.msgpack")); | ||
} | ||
|
||
return extendedData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...etGeneratorTest.GeneratesMasterAssetCorrectly#MasterAssetMessagePackOptions.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//HintName: MasterAssetMessagePackOptions.g.cs | ||
// <auto-generated/> | ||
|
||
#nullable enable | ||
|
||
namespace DragaliaAPI.Shared.MasterAsset; | ||
|
||
public class MasterAssetMessagePackOptions | ||
{ | ||
public static global::MessagePack.MessagePackSerializerOptions Instance { get; } = | ||
global::MessagePack.MessagePackSerializerOptions | ||
.Standard.WithResolver(global::MessagePack.Resolvers.ContractlessStandardResolver.Instance) | ||
.WithCompression(global::MessagePack.MessagePackCompression.Lz4BlockArray); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.