diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IModConfigInfo.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IModConfigInfo.cs
new file mode 100644
index 0000000000..c815e97854
--- /dev/null
+++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IModConfigInfo.cs
@@ -0,0 +1,11 @@
+using System.Collections.Immutable;
+
+namespace Barotrauma.LuaCs.Data;
+
+public partial interface IModConfigInfo
+{
+ ///
+ /// Collection of loadable styles data.
+ ///
+ ImmutableArray StylesResourceInfos { get; }
+}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IStylesResourceInfo.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IStylesResourceInfo.cs
index 3f8747340b..10933583ae 100644
--- a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IStylesResourceInfo.cs
+++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IStylesResourceInfo.cs
@@ -1,3 +1,3 @@
namespace Barotrauma.LuaCs.Data;
-public interface IStylesResourceInfo : IResourceInfo, IResourceCultureInfo { }
+public interface IStylesResourceInfo : IResourceInfo, IResourceCultureInfo, ILazyLoadableResourceInfo, IPackageDependenciesInfo { }
diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/ModConfigInfo.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/ModConfigInfo.cs
new file mode 100644
index 0000000000..a3b9c8a4cd
--- /dev/null
+++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/ModConfigInfo.cs
@@ -0,0 +1,8 @@
+using System.Collections.Immutable;
+
+namespace Barotrauma.LuaCs.Data;
+
+public readonly partial struct ModConfigInfo : IModConfigInfo
+{
+ public ImmutableArray StylesResourceInfos { get; init; }
+}
diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/PackageService.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/PackageService.cs
new file mode 100644
index 0000000000..ec110d8132
--- /dev/null
+++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/PackageService.cs
@@ -0,0 +1,29 @@
+using System;
+using Barotrauma.LuaCs.Services.Processing;
+
+namespace Barotrauma.LuaCs.Services;
+
+public partial class PackageService
+{
+ private readonly Lazy _stylesConverterService;
+
+ public PackageService(
+ Lazy converterService,
+ Lazy legacyConfigConverterService,
+ Lazy localizationConverterService,
+ Lazy stylesConverterService,
+ IStorageService storageService,
+ ILoggerService loggerService)
+ {
+ _modConfigConverterService = converterService;
+ _legacyConfigConverterService = legacyConfigConverterService;
+ _localizationConverterService = localizationConverterService;
+ _stylesConverterService = stylesConverterService;
+ _storageService = storageService;
+ _loggerService = loggerService;
+ }
+ partial void TryParsePackageClient(ContentPackage package)
+ {
+ throw new NotImplementedException();
+ }
+}
diff --git a/Barotrauma/BarotraumaServer/ServerSource/LuaCs/Services/PackageService.cs b/Barotrauma/BarotraumaServer/ServerSource/LuaCs/Services/PackageService.cs
new file mode 100644
index 0000000000..7a23776b80
--- /dev/null
+++ b/Barotrauma/BarotraumaServer/ServerSource/LuaCs/Services/PackageService.cs
@@ -0,0 +1,23 @@
+using System;
+using Barotrauma.LuaCs.Services.Processing;
+
+namespace Barotrauma.LuaCs.Services;
+
+public partial class PackageService
+{
+ public PackageService(
+ Lazy converterService,
+ Lazy legacyConfigConverterService,
+ Lazy localizationConverterService,
+ IStorageService storageService,
+ ILoggerService loggerService)
+ {
+ _modConfigConverterService = converterService;
+ _legacyConfigConverterService = legacyConfigConverterService;
+ _localizationConverterService = localizationConverterService;
+ _storageService = storageService;
+ _loggerService = loggerService;
+ }
+ // No implementation
+ partial void TryParsePackageClient(ContentPackage package) {}
+}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs
index a1eaba9a7c..42fb22e1a8 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs
@@ -39,3 +39,17 @@ public interface IResourceCultureInfo
///
ImmutableArray SupportedCultures { get; init; }
}
+
+
+public interface ILazyLoadableResourceInfo
+{
+ ///
+ /// The name that will be used when trying to reference this resource for execution or loading.
+ ///
+ public string InternalName { get; }
+
+ ///
+ /// Should this be compiled/loaded immediately or stored until demanded.
+ ///
+ public bool LazyLoad { get; }
+}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IModConfigInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IModConfigInfo.cs
index ace21f7964..af902b60f6 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IModConfigInfo.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IModConfigInfo.cs
@@ -2,7 +2,7 @@
namespace Barotrauma.LuaCs.Data;
-public interface IModConfigInfo : IPackageDependenciesInfo, IResourceCultureInfo
+public partial interface IModConfigInfo : IPackageDependenciesInfo, IResourceCultureInfo
{
// package info
ContentPackage Package { get; }
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDefinitions.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDefinitions.cs
index be2ce7a8ac..cd8e1ee3ae 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDefinitions.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDefinitions.cs
@@ -6,8 +6,11 @@ namespace Barotrauma.LuaCs.Data;
public interface IConfigResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
public interface IConfigProfileResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
public interface ILocalizationResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
-
-public interface IAssemblyResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo
+///
+/// Represents loadable Lua files.
+///
+public interface ILuaResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo, ILazyLoadableResourceInfo { }
+public interface IAssemblyResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo, ILazyLoadableResourceInfo
{
///
/// The friendly name of the assembly. Script files belonging to the same assembly should all have the same name.
@@ -18,8 +21,4 @@ public interface IAssemblyResourceInfo : IResourceInfo, IResourceCultureInfo, IP
/// Is this entry referring to a script file collection.
///
public bool IsScript { get; }
- ///
- /// Should this be compiled/loaded immediately or stored until demanded.
- ///
- public bool LazyLoad { get; }
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigInfo.cs
index 3fc2bd74f8..4aa3818330 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigInfo.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigInfo.cs
@@ -2,12 +2,14 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace Barotrauma.LuaCs.Data;
#region ModConfigurationInfo
-public readonly struct ModConfigInfo : IModConfigInfo
+[StructLayout(LayoutKind.Auto)] // because we have a partial readonly struct
+public readonly partial struct ModConfigInfo : IModConfigInfo
{
public ContentPackage Package { get; init; }
public string PackageName { get; init; }
@@ -28,6 +30,7 @@ namespace Barotrauma.LuaCs.Data;
{
public string FriendlyName { get; init; }
public bool IsScript { get; init; }
+ public string InternalName { get; init; }
public bool LazyLoad { get; init; }
public Platform SupportedPlatforms { get; init; }
public Target SupportedTargets { get; init; }
@@ -55,4 +58,15 @@ namespace Barotrauma.LuaCs.Data;
public ImmutableArray Dependencies { get; init; }
}
+public readonly struct LuaScriptResourceInfo : ILuaResourceInfo
+{
+ public Platform SupportedPlatforms { get; init; }
+ public Target SupportedTargets { get; init; }
+ public ImmutableArray FilePaths { get; init; }
+ public ImmutableArray SupportedCultures { get; init; }
+ public ImmutableArray Dependencies { get; init; }
+ public string InternalName { get; init; }
+ public bool LazyLoad { get; init; }
+}
+
#endregion
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs
index 4015e882e2..a23d70f7b1 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs
@@ -150,23 +150,23 @@ public bool LuaTryRegisterPackageTypes(string name, bool caseSensitive = false)
#endregion
///
- /// Whether or not assemblies have been loaded.
+ /// Whether assemblies have been loaded.
///
public bool AssembliesLoaded { get; private set; }
///
- /// Whether or not loaded plugins had their preloader run.
+ /// Whether loaded plugins had their preloader run.
///
public bool PluginsPreInit { get; private set; }
///
- /// Whether or not plugins' types have been instantiated.
+ /// Whether plugins' types have been instantiated.
///
public bool PluginsInitialized { get; private set; }
///
- /// Whether or not plugins are fully loaded.
+ /// Whether plugins are fully loaded.
///
public bool PluginsLoaded { get; private set; }
@@ -967,7 +967,7 @@ private static bool TryBuildDependenciesMap(ImmutableList packag
/// Packages with errors or cyclic dependencies. Element is error message. Null if empty.
/// Optional: Allows for a custom checks to be performed on each package.
/// Returns a bool indicating if the package is ready to load.
- /// Whether or not the process produces a usable list.
+ /// Whether the process produces a usable list.
private static bool OrderAndFilterPackagesByDependencies(
Dictionary> packages,
out IEnumerable readyToLoad,
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IContentPackageService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IContentPackageService.cs
index c4d1502f2d..ed07eb263b 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IContentPackageService.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IContentPackageService.cs
@@ -1,12 +1,13 @@
-using Barotrauma.LuaCs.Data;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using Barotrauma.LuaCs.Data;
namespace Barotrauma.LuaCs.Services;
public interface IContentPackageService : IService
{
- bool TryLoadPackageData(ContentPackage package);
- ModConfigInfo GetModConfigData();
- ContentPackage TryFindPackage(string packageName, bool prioritizeLocal = true);
- ContentPackage TryFindPackage(int steamId);
- ContentPath GetContentPath();
+ bool TryParsePackage(ContentPackage package);
+ ContentPackage Package { get; }
+ IModConfigInfo ModConfigInfo { get; }
}
+
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IPackageManagementService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IPackageManagementService.cs
new file mode 100644
index 0000000000..8c5f8a1183
--- /dev/null
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IPackageManagementService.cs
@@ -0,0 +1,6 @@
+namespace Barotrauma.LuaCs.Services;
+
+public interface IPackageManagementService : IService
+{
+
+}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IStorageService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IStorageService.cs
index b44a7a2009..63fc670933 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IStorageService.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IStorageService.cs
@@ -1,9 +1,33 @@
-using System.Xml.Linq;
+using System.Collections.Immutable;
+using System.Xml.Linq;
namespace Barotrauma.LuaCs.Services;
public interface IStorageService : IService
{
+ #region LocalGameData
+
+ bool TryLoadLocalXml(ContentPackage package, string localFilePath, out XDocument document);
+ bool TryLoadLocalBinary(ContentPackage package, string localFilePath, out byte[] bytes);
+ bool TryLoadLocalText(ContentPackage package, string localFilePath, out string text);
+
+ #endregion
+
+ #region ContentPackageData
+ bool TryLoadPackageXml(ContentPackage package, string localFilePath, out XDocument document);
+ bool TryLoadPackageBinary(ContentPackage package, string localFilePath, out byte[] bytes);
+ bool TryLoadPackageText(ContentPackage package, string localFilePath, out string text);
+
+ ImmutableArray TryLoadPackageXmlFiles(ContentPackage package, ImmutableArray localFilePath, out ImmutableArray document);
+ ImmutableArray TryLoadPackageBinaryFiles(ContentPackage package, ImmutableArray localFilePath, out ImmutableArray bytes);
+ ImmutableArray TryLoadPackageTextFiles(ContentPackage package, ImmutableArray localFilePath, out ImmutableArray text);
+
+ bool FindFilesInPackage(ContentPackage package, string localSubfolder, string regexFilter, bool searchRecursively, out ImmutableArray localFilePaths);
+
+ #endregion
+
+ #region AbsolutePaths
+
bool TryLoadXml(string filePath, out XDocument document);
bool TrySaveXml(string filePath, in XDocument document);
bool TryLoadBinary(string filePath, out byte[] bytes);
@@ -11,4 +35,6 @@ public interface IStorageService : IService
bool TryLoadText(string filePath, out string text);
bool TrySaveText(string filePath, string text);
bool FileExists(string filePath);
+
+ #endregion
}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs
new file mode 100644
index 0000000000..f6b5b456ce
--- /dev/null
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace Barotrauma.LuaCs.Services;
+
+public class PackageManagementService : IPackageManagementService
+{
+ private Func GetPackageServiceInstance { get; init; }
+
+ public PackageManagementService(Func getPackageService)
+ {
+ this.GetPackageServiceInstance = getPackageService;
+ }
+
+ public void Dispose()
+ {
+ throw new System.NotImplementedException();
+ }
+}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageService.cs
new file mode 100644
index 0000000000..1c0ad2deaa
--- /dev/null
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageService.cs
@@ -0,0 +1,41 @@
+using System;
+using Barotrauma.LuaCs.Data;
+using Barotrauma.LuaCs.Services.Processing;
+
+namespace Barotrauma.LuaCs.Services;
+
+public partial class PackageService : IContentPackageService
+{
+ private readonly Lazy _modConfigConverterService;
+ private readonly Lazy _legacyConfigConverterService;
+ private readonly Lazy _localizationConverterService;
+ private readonly IStorageService _storageService;
+ private readonly ILoggerService _loggerService;
+
+ // cctor in server source and client source
+
+ public ContentPackage Package { get; private set; }
+
+ public IModConfigInfo ModConfigInfo { get; private set; }
+
+ public bool TryParsePackage(ContentPackage package)
+ {
+ // scan for files: modconfig.xml
+
+ // on fail, scan and try for legacy loading
+
+ // load resources info for: config, assemblies, lua files, localization
+
+ // load styles data on clients
+ TryParsePackageClient(package);
+
+ throw new NotImplementedException();
+ }
+
+ partial void TryParsePackageClient(ContentPackage package);
+
+ public void Dispose()
+ {
+ // TODO release managed resources here
+ }
+}
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/IConverterServiceDefinitions.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/IConverterServiceDefinitions.cs
index c34cf1224f..9d72c1572d 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/IConverterServiceDefinitions.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/IConverterServiceDefinitions.cs
@@ -34,6 +34,10 @@ public interface IXmlLocalizationResConverterService : IXmlResourceConverterServ
#region XmlToInfoParsers
public interface IXmlDependencyConverterService : IXmlResourceConverterService { }
public interface IXmlModConfigConverterService : IXmlResourceConverterService { }
+///
+/// Parses legacy packages that make use of the RunConfig.xml structure to produce a ModConfig.
+///
+public interface IXmlLegacyModConfigConverterService : IXmlResourceConverterService { }
#endregion