diff --git a/Libraries/Core/Loaders/BundleLoader.cs b/Libraries/Core/Loaders/BundleLoader.cs index 9f934ec4..0c4e733c 100644 --- a/Libraries/Core/Loaders/BundleLoader.cs +++ b/Libraries/Core/Loaders/BundleLoader.cs @@ -14,7 +14,7 @@ namespace Core.Loaders get; } - public IBundleManifestEntry Bundle + public BundleManifestEntry Bundle { get; } @@ -31,7 +31,7 @@ namespace Core.Loaders public BundleInfo( string modPath, - IBundleManifestEntry bundle, + BundleManifestEntry bundle, string bundleHash) { ModPath = modPath; @@ -92,14 +92,19 @@ namespace Core.Loaders // TODO: Implement var modBundlesJson = _fileUtil.ReadFile(Path.Combine(modPath, "bundles.json")); - var modBundles = _jsonUtil.Deserialize(modBundlesJson); + var modBundles = _jsonUtil.Deserialize(modBundlesJson); var bundleManifestArr = modBundles?.Manifest; foreach (var bundleManifest in bundleManifestArr) { // TODO: complete - var relativeModPath = modPath.Substring(0, -1); //.replace(/\\/g, "/"); - var bundleLocalPath = Path.Combine(modPath, "bundles", bundleManifest.Key); //.replace(/\\/g, "/"); + // we currently get D:\HomeRepos\SPT-CS-Server\Server\bin\Debug\net9.0/user/mods/Mod3 + // we want /user/mods/Mod3 + var relativeModPath = modPath.Substring(0, modPath.Length - 1); // /\\/g, "/" - replaces all instances of \\ with / + + // we currently get D:\HomeRepos\SPT-CS-Server\Server\bin\Debug\net9.0/user/mods/Mod3/bundles\assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle + // we want /user/mods/Mod3/bundles\assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle + var bundleLocalPath = Path.Combine(modPath, "bundles", bundleManifest.Key); // /\\/g, "/" - replaces all instances of \\ with / if (!_bundleHashCacheService.CalculateAndMatchHash(bundleLocalPath)) { @@ -123,13 +128,13 @@ namespace Core.Loaders } } -public interface IBundleManifest +public record BundleManifest { [JsonPropertyName("manifest")] - public List Manifest { get; set; } + public List Manifest { get; set; } } -public interface IBundleManifestEntry +public record BundleManifestEntry { [JsonPropertyName("key")] public string Key { diff --git a/Libraries/Core/Services/BundleHashCacheService.cs b/Libraries/Core/Services/BundleHashCacheService.cs index d9730312..35df5224 100644 --- a/Libraries/Core/Services/BundleHashCacheService.cs +++ b/Libraries/Core/Services/BundleHashCacheService.cs @@ -11,7 +11,7 @@ namespace Core.Services private readonly JsonUtil _jsonUtil; private readonly HashUtil _hashUtil; private readonly FileUtil _fileUtil; - protected readonly Dictionary _bundleHashes; + protected readonly Dictionary _bundleHashes = new Dictionary(); protected const string _bundleHashCachePath = "./user/cache/bundleHashCache.json"; public BundleHashCacheService( diff --git a/ModExamples/12Bundle/Bundle.cs b/ModExamples/12Bundle/Bundle.cs index acfc0db8..b027292e 100644 --- a/ModExamples/12Bundle/Bundle.cs +++ b/ModExamples/12Bundle/Bundle.cs @@ -1,4 +1,5 @@ -using Core.Loaders; +using System.Reflection; +using Core.Loaders; using Core.Models.External; using SptCommon.Annotations; @@ -19,6 +20,7 @@ public class Bundle : IPostDBLoadMod public void PostDBLoad() { var modFolder = Directory.GetCurrentDirectory(); - _bundleLoader.AddBundles(modFolder); + var test = Assembly.GetExecutingAssembly().Location; + _bundleLoader.AddBundles(Path.Join(modFolder, "/user/mods/Mod3/")); } } diff --git a/ModExamples/12Bundle/bundles/assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle b/ModExamples/12Bundle/bundles/assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle new file mode 100644 index 00000000..782eff68 Binary files /dev/null and b/ModExamples/12Bundle/bundles/assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle differ diff --git a/ModExamples/12Bundle/bundles/assets/content/patron_1143x33mmr_lead.bundle b/ModExamples/12Bundle/patron_1143x33mmr_lead.bundle similarity index 100% rename from ModExamples/12Bundle/bundles/assets/content/patron_1143x33mmr_lead.bundle rename to ModExamples/12Bundle/patron_1143x33mmr_lead.bundle diff --git a/ModExamples/21CustomCommandoCommand/21CustomCommandoCommand.csproj b/ModExamples/21CustomCommandoCommand/21CustomCommandoCommand.csproj new file mode 100644 index 00000000..fe8a000c --- /dev/null +++ b/ModExamples/21CustomCommandoCommand/21CustomCommandoCommand.csproj @@ -0,0 +1,10 @@ + + + + net9.0 + _21CustomCommandoCommand + enable + enable + + + diff --git a/ModExamples/21CustomCommandoCommand/Class1.cs b/ModExamples/21CustomCommandoCommand/Class1.cs new file mode 100644 index 00000000..b2845257 --- /dev/null +++ b/ModExamples/21CustomCommandoCommand/Class1.cs @@ -0,0 +1,5 @@ +namespace _21CustomCommandoCommand; + +public class Class1 +{ +} diff --git a/ModExamples/ModExamples.sln b/ModExamples/ModExamples.sln index d7d51c3d..3e6906b9 100644 --- a/ModExamples/ModExamples.sln +++ b/ModExamples/ModExamples.sln @@ -40,6 +40,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "20CustomChatBot", "20CustomChatBot\20CustomChatBot.csproj", "{32271491-8CF1-4014-9A8E-E1EA22EA4292}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "13.1AddTraderWithDynamicAssorts", "13.1AddTraderWithDynamicAssorts\13.1AddTraderWithDynamicAssorts.csproj", "{9038FA64-E484-4549-9728-C50F12BBE643}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "21CustomCommandoCommand", "21CustomCommandoCommand\21CustomCommandoCommand.csproj", "{A7D491BC-94C0-4AC9-9190-1FCA05D09B19}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -122,6 +124,10 @@ Global {9038FA64-E484-4549-9728-C50F12BBE643}.Debug|Any CPU.Build.0 = Debug|Any CPU {9038FA64-E484-4549-9728-C50F12BBE643}.Release|Any CPU.ActiveCfg = Release|Any CPU {9038FA64-E484-4549-9728-C50F12BBE643}.Release|Any CPU.Build.0 = Release|Any CPU + {A7D491BC-94C0-4AC9-9190-1FCA05D09B19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7D491BC-94C0-4AC9-9190-1FCA05D09B19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7D491BC-94C0-4AC9-9190-1FCA05D09B19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7D491BC-94C0-4AC9-9190-1FCA05D09B19}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE