start modExample 21, fix bundleLoading being Null,
This commit is contained in:
@@ -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<IBundleManifest>(modBundlesJson);
|
||||
var modBundles = _jsonUtil.Deserialize<BundleManifest>(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<IBundleManifestEntry> Manifest { get; set; }
|
||||
public List<BundleManifestEntry> Manifest { get; set; }
|
||||
}
|
||||
|
||||
public interface IBundleManifestEntry
|
||||
public record BundleManifestEntry
|
||||
{
|
||||
[JsonPropertyName("key")]
|
||||
public string Key {
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Core.Services
|
||||
private readonly JsonUtil _jsonUtil;
|
||||
private readonly HashUtil _hashUtil;
|
||||
private readonly FileUtil _fileUtil;
|
||||
protected readonly Dictionary<string, string> _bundleHashes;
|
||||
protected readonly Dictionary<string, string> _bundleHashes = new Dictionary<string, string>();
|
||||
protected const string _bundleHashCachePath = "./user/cache/bundleHashCache.json";
|
||||
|
||||
public BundleHashCacheService(
|
||||
|
||||
@@ -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/"));
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<RootNamespace>_21CustomCommandoCommand</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace _21CustomCommandoCommand;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user