diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/DataInterfaceImplementations.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/DataInterfaceImplementations.cs index 790c7c9cd..21b718d03 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/DataInterfaceImplementations.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/DataInterfaceImplementations.cs @@ -33,146 +33,29 @@ public record LuaScriptsResourcesInfo(ImmutableArray Lua public record ConfigResourcesInfo(ImmutableArray Configs) : IConfigsResourcesInfo; public record ConfigProfilesResourcesInfo(ImmutableArray ConfigProfiles) : IConfigProfilesResourcesInfo; -public record AssemblyResourceInfo : IAssemblyResourceInfo +public record BaseResourceInfo : IBaseResourceInfo { + public Platform SupportedPlatforms { get; init; } + public Target SupportedTargets { get; init; } + public int LoadPriority { get; init; } + public ImmutableArray FilePaths { get; init; } + public bool Optional { get; init; } + public string InternalName { get; init; } public ContentPackage OwnerPackage { get; init; } +} + +public record AssemblyResourceInfo : BaseResourceInfo, IAssemblyResourceInfo +{ 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; } - public int LoadPriority { get; init; } - public ImmutableArray FilePaths { get; init; } - public ImmutableArray SupportedCultures { get; init; } - public ImmutableArray Dependencies { get; init; } - public bool Optional { get; init; } } -public record PackageDependency : IPackageDependency +public record ConfigResourceInfo : BaseResourceInfo, IConfigResourceInfo {} + +public record ConfigProfileResourceInfo : BaseResourceInfo, IConfigProfileResourceInfo {} + +public record LuaScriptsResourceInfo : BaseResourceInfo, ILuaScriptResourceInfo { - public PackageDependency(ContentPackage package, IPackageInfo dependencyInfo, string internalName) - { - Dependency = dependencyInfo ?? throw new ArgumentNullException(nameof(dependencyInfo)); - OwnerPackage = package ?? throw new ArgumentNullException(nameof(package)); - InternalName = internalName ?? throw new ArgumentNullException(nameof(internalName)); - } - public string InternalName { get; init; } - public ContentPackage OwnerPackage { get; init; } - public IPackageInfo Dependency { get; init; } - public override int GetHashCode() => Dependency.GetHashCode(); - -} - -public record PackageInfo : IPackageInfo -{ - public string Name { get; private set; } - public ulong SteamWorkshopId { get; private set; } - public uint Id { get; private set; } - - private readonly Func _getPackage; - - public ContentPackage GetPackage() => _getPackage?.Invoke(this) ?? null; - - public void UpdateInfo(string name, ulong steamId, uint packageId) - { - if (name.IsNullOrWhiteSpace() || steamId == 0 || packageId == 0) - { - throw new ArgumentException( - $"{nameof(PackageInfo)}: You cannot update a package with an invalid name or steam id with a valid id, or vice-versa."); - } - - Name = name; - SteamWorkshopId = steamId; - Id = packageId; - } - - public PackageInfo(ContentPackage package, uint id, Func getPackage) - { - if (package is null) - throw new ArgumentNullException($"{nameof(PackageInfo)}: package is null"); - if (id == 0) - throw new ArgumentNullException($"{nameof(PackageInfo)}: id is zero."); - - this.Name = package.Name; - this.SteamWorkshopId = package.TryExtractSteamWorkshopId(out var sId) ? sId.Value : 0; - this.Id = id; - this._getPackage = getPackage; - } - - public PackageInfo(string name, ulong steamWorkshopId, uint id, Func getPackage) - { - Name = !name.IsNullOrWhiteSpace() ? name : throw new ArgumentNullException($"{nameof(PackageInfo)}: name cannot be null or empty."); - SteamWorkshopId = steamWorkshopId != 0 ? steamWorkshopId : throw new ArgumentNullException($"{nameof(PackageInfo)}: steam id cannot be 0."); - this.Id = id; - this._getPackage = getPackage; - } - - public PackageInfo(string name, uint id, Func getPackage) - { - Name = name ?? throw new ArgumentNullException($"{nameof(PackageInfo)}: name cannot be null or empty."); - this.SteamWorkshopId = 0; - this.Id = id; - this._getPackage = getPackage; - } - - public PackageInfo(ulong steamWorkshopId, uint id, Func getPackage) - { - SteamWorkshopId = steamWorkshopId != 0 ? steamWorkshopId : throw new ArgumentNullException($"{nameof(PackageInfo)}: steamid cannot be 0."); - this.Id = id; - this._getPackage = getPackage; - } - - public override int GetHashCode() - { - return (int)Id; - } - - public virtual bool Equals(PackageInfo other) - { - return ((IEquatable)this).Equals(other); - } -} - - - -public record ConfigResourceInfo : IConfigResourceInfo -{ - public Platform SupportedPlatforms { get; init; } - public Target SupportedTargets { get; init; } - public int LoadPriority { get; init; } - public ImmutableArray FilePaths { get; init; } - public bool Optional { get; init; } - public ImmutableArray SupportedCultures { get; init; } - public ImmutableArray Dependencies { get; init; } - public string InternalName { get; init; } - public ContentPackage OwnerPackage { get; init; } -} - -public record ConfigProfileResourceInfo : IConfigProfileResourceInfo -{ - public Platform SupportedPlatforms { get; init; } - public Target SupportedTargets { get; init; } - public int LoadPriority { get; init; } - public ImmutableArray FilePaths { get; init; } - public bool Optional { get; init; } - public ImmutableArray SupportedCultures { get; init; } - public ImmutableArray Dependencies { get; init; } - public string InternalName { get; init; } - public ContentPackage OwnerPackage { get; init; } -} - -public readonly struct LuaScriptsResourceInfo : ILuaScriptResourceInfo -{ - public ContentPackage OwnerPackage { get; init; } - public Platform SupportedPlatforms { get; init; } - public Target SupportedTargets { get; init; } - public int LoadPriority { get; init; } - public ImmutableArray FilePaths { get; init; } - public ImmutableArray SupportedCultures { get; init; } - public ImmutableArray Dependencies { get; init; } - public bool Optional { get; init; } - public string InternalName { get; init; } public bool IsAutorun { get; init; } } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs index cc9387175..bf3525c0d 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IBaseInfoDefinitions.cs @@ -37,7 +37,7 @@ public interface IResourceInfo : IPlatformInfo /// Resource absolute file paths. /// [Required] - ImmutableArray FilePaths { get; } + ImmutableArray FilePaths { get; } /// /// Marks this resource as optional (ie. Cross-CP content). Setting this to true will allow the dependency system to @@ -45,14 +45,3 @@ public interface IResourceInfo : IPlatformInfo /// bool Optional { get; } } - -/// -/// Information about supported cultures. It is intended to be ignored if the array is ImmutableArray.Empty . -/// -public interface IResourceCultureInfo -{ - /// - /// List of supported cultures by this resource. - /// - ImmutableArray SupportedCultures { get; } -} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IPackageDependency.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IPackageDependency.cs deleted file mode 100644 index a094d122f..000000000 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IPackageDependency.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Immutable; -using Barotrauma; -using Barotrauma.LuaCs.Data; - -namespace Barotrauma.LuaCs.Data; - -public interface IPackageDependency : IDataInfo, IEquatable -{ - public IPackageInfo Dependency { get; } - - bool IEquatable.Equals(IPackageDependency other) - { - return other is not null && Dependency.Equals(other.Dependency); - } -} - -public interface IPackageInfo : IEquatable -{ - /// - /// Name of the content package. - /// - public string Name { get; } - /// - /// Steam ID of the package. - /// - public ulong SteamWorkshopId { get; } - /// - /// The Guid for the runtime instance of the package. - /// - public uint Id { get; } - - /// - /// Gets the reference to the best-match target ContentPackage that meets the requirement. - /// - /// The reference, or null if none was found. - public ContentPackage GetPackage(); - - /// - /// Tries to retrieve the current best and returns true if none was found. - /// - public bool IsMissing => GetPackage() is null; - - bool IEquatable.Equals(IPackageInfo other) - { - if (other is null) - return false; - if (ReferenceEquals(other, this)) - return true; - if (!this.IsMissing && !other.IsMissing && ReferenceEquals(other.GetPackage, this.GetPackage)) - return true; - if (this.SteamWorkshopId != 0 && other.SteamWorkshopId == this.SteamWorkshopId) - return true; - return this.Name == other.Name; - } -} - -public interface IPackageDependenciesInfo -{ - /// - /// List of required packages. - /// - ImmutableArray Dependencies { get; } -} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDeclarations.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDeclarations.cs index 777bd24d1..1bc74e54a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDeclarations.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceInfoDeclarations.cs @@ -4,13 +4,17 @@ using System.Globalization; namespace Barotrauma.LuaCs.Data; -public interface IConfigResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo, IDataInfo { } -public interface IConfigProfileResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo, IDataInfo { } + +public interface IBaseResourceInfo : IResourceInfo, IDataInfo {} + +public interface IConfigResourceInfo : IBaseResourceInfo {} + +public interface IConfigProfileResourceInfo :IBaseResourceInfo {} /// /// Represents loadable Lua files. /// -public interface ILuaScriptResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo, IDataInfo +public interface ILuaScriptResourceInfo : IBaseResourceInfo { /// /// Should this script be run automatically. @@ -18,7 +22,7 @@ public interface ILuaScriptResourceInfo : IResourceInfo, IResourceCultureInfo, I public bool IsAutorun { get; } } -public interface IAssemblyResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo, IDataInfo +public interface IAssemblyResourceInfo : IBaseResourceInfo { /// /// The friendly name of the assembly. Script files belonging to the same assembly should all have the same name. diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/ContentPackageInfoLookup.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/ContentPackageInfoLookup.cs deleted file mode 100644 index e8f906079..000000000 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/ContentPackageInfoLookup.cs +++ /dev/null @@ -1,393 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Barotrauma.LuaCs.Data; -using Barotrauma.LuaCs.Events; -using Barotrauma.Steam; -using FluentResults; -using OneOf; - -namespace Barotrauma.LuaCs.Services; - -/// -/// Provides resolution for dynamically locating the best matching package at the time of consumption. -/// -public sealed class ContentPackageInfoLookup : IPackageInfoLookupService, IEventEnabledPackageListChanged, IEventAllPackageListChanged -{ - #region INTERNAL - - // packageinfo query data - private readonly ConcurrentDictionary, IPackageInfo> _packageInfoMap = new(); - // package query data - private readonly ConcurrentDictionary> _packageIdGroups = new(); - private readonly ConcurrentDictionary> _reversePackageIdGroups = new(); - private readonly HashSet _enabledPackages; - private readonly HashSet _allPackages; - // threading - private readonly AsyncReaderWriterLock _packageIdGroupsLock = new(); - private readonly AsyncReaderWriterLock _packageSetsLock = new(); - // services - private readonly IEventService _eventService; - private readonly IPackageListRetrievalService _packageListRetrievalService; - - private int _isDisposed = 0; - private uint _idCounter = 0; - - // returns ++_idCounter; - private uint GetNextId() => Interlocked.Increment(ref _idCounter); - - private ContentPackage GetBestMatchPackage(IPackageInfo packageInfo) - { - if (packageInfo is null) - return null; - if (!_packageIdGroups.TryGetValue(packageInfo.Id, out var packageGroup) - || packageGroup.IsDefaultOrEmpty) - return null; - if (packageGroup.Length == 1) - return packageGroup[0]; - - bool nameGood = !packageInfo.Name.IsNullOrWhiteSpace(); - - // try by enabled - var prev = packageGroup; - - var packList = packageGroup; - using (_packageSetsLock.AcquireReaderLock().GetAwaiter().GetResult()) - { - packList = packList - .Where(p => p is not null && _enabledPackages.Contains(p)) - .ToImmutableArray(); - } - - if (ReturnValue()) - return packList[0]; - - // try by steam id - if (packageInfo.SteamWorkshopId != 0) - { - packList = packList - .Where(p => p.TryExtractSteamWorkshopId(out var sId) && sId.Value == packageInfo.SteamWorkshopId) - .ToImmutableArray(); - - if (ReturnValue()) - return packList[0]; - } - - // try by name - if (nameGood) - { - packList = packList - .Where(p => p.Name == packageInfo.Name) - .ToImmutableArray(); - - if (ReturnValue()) - return packList[0]; - } - - // try by localmods - packList = packList.Where(p => p.Path.ToLowerInvariant().Contains("localmods")) - .ToImmutableArray(); - - if (ReturnValue()) - return packList[0]; - - // get the first in the list - return packList.First(); - - bool ReturnValue() - { - if (packList.IsDefaultOrEmpty) - packList = prev; - else if (packList.Length == 1) - return true; - else - prev = packList; - return false; - } - } - - private async Task SyncPackagesLists(IReadOnlyList enabledPackages, - IReadOnlyList allPackages) - { - if (enabledPackages is null || allPackages is null) - return; - - // take all locks - using var l1 = await _packageIdGroupsLock.AcquireWriterLock(); - using var l2 = await _packageSetsLock.AcquireWriterLock(); - - // calc diffs - var toAddAll = allPackages.Except(_allPackages).ToHashSet(); - var toAddEnabled = enabledPackages.Except(_enabledPackages).ToHashSet(); - var toRemoveAll = _allPackages.Except(allPackages).ToHashSet(); - var toRemoveEnabled = _enabledPackages.Except(enabledPackages).ToHashSet(); - - // remove old - if (toRemoveAll.Any()) - { - foreach (var package in toRemoveAll) - { - if (package is null) - continue; - - _allPackages.Remove(package); - - // try to find id lookup - if (!_reversePackageIdGroups.TryGetValue(package, out var idGroup)) - continue; - - // found packs - if (!idGroup.IsDefaultOrEmpty) - { - foreach (var id in idGroup) - { - if (!_packageIdGroups.TryGetValue(id, out var packageGroup) - || packageGroup.IsDefaultOrEmpty) - continue; - _packageIdGroups[id] = packageGroup.RemoveAll(p => toRemoveAll.Contains(p)); - } - } - - // remove ref - _reversePackageIdGroups.Remove(package, out _); - } - } - - if (toRemoveEnabled.Any()) - { - foreach (var package in toRemoveEnabled) - { - if (package is null) - continue; - _enabledPackages.Remove(package); - } - } - - // add new - if (toAddAll.Any()) - { - foreach (var package in toAddAll) - { - if (package is null) - continue; - - _allPackages.Add(package); - - var steamId = package.TryExtractSteamWorkshopId(out var id) ? id.Value : 0; - IPackageInfo packageInfo; - Queue idListsToAdd = new(); - if (!package.Name.IsNullOrWhiteSpace() && steamId > 0) - { - // combined key - packageInfo = GetOrCreateInfoForMap(package, (package.Name, steamId)); - AddToPackageIdGroups(packageInfo.Id, package); - // string key - packageInfo = GetOrCreateInfoForMap(package, package.Name); - AddToPackageIdGroups(packageInfo.Id, package); - // steamId key - packageInfo = GetOrCreateInfoForMap(package, steamId); - AddToPackageIdGroups(packageInfo.Id, package); - } - - // try find in the existing list, or make a new one - IPackageInfo GetOrCreateInfoForMap(ContentPackage package, OneOf.OneOf infoKey) - { - return _packageInfoMap.TryGetValue(infoKey, out var pInfo) - ? pInfo - : new PackageInfo(package, GetNextId(), GetBestMatchPackage); - } - - // add to package lookups - void AddToPackageIdGroups(uint id, ContentPackage package) - { - if (_packageIdGroups.TryGetValue(id, out var packageGroup)) - { - if (!packageGroup.Contains(package)) - _packageIdGroups[id] = packageGroup.Add(package); - } - else - _packageIdGroups[id] = new[] { package }.ToImmutableArray(); - - if (_reversePackageIdGroups.TryGetValue(package, out var idGroup)) - { - if (!idGroup.Contains(id)) - _reversePackageIdGroups[package] = idGroup.Add(id); - } - else - _reversePackageIdGroups[package] = new[] { id }.ToImmutableArray(); - } - } - } - - if (toAddEnabled.Any()) - { - foreach (var package in toAddEnabled) - { - if (package is null) - continue; - _enabledPackages.Add(package); - } - } - } - - private async Task> LookupInternal(OneOf.OneOf infoKey) - { - using (await _packageIdGroupsLock.AcquireReaderLock()) - { - if (_packageInfoMap.TryGetValue(infoKey, out var packageInfo)) - return FluentResults.Result.Ok(packageInfo); - } - - // change to write lock - using (await _packageIdGroupsLock.AcquireWriterLock()) - { - // create one - var packageInfo = infoKey.Match( - sPackName => new PackageInfo(sPackName, GetNextId(), GetBestMatchPackage), - uSteamId => new PackageInfo(uSteamId, GetNextId(), GetBestMatchPackage), - cKey => new PackageInfo(cKey.Item1, cKey.Item2, GetNextId(), GetBestMatchPackage) - ); - _packageInfoMap[infoKey] = packageInfo; - // empty array - _packageIdGroups[packageInfo.Id] = ImmutableArray.Empty; - return FluentResults.Result.Ok(packageInfo); - } - } - - #endregion - - public ContentPackageInfoLookup(IEventService eventService, IPackageListRetrievalService packageListRetrievalService) - { - _eventService = eventService ?? throw new ArgumentNullException( - $"{nameof(ContentPackageInfoLookup)}: {nameof(eventService)} cannot be null."); - _packageListRetrievalService = packageListRetrievalService ?? throw new ArgumentNullException(nameof(packageListRetrievalService)); - this._enabledPackages = new HashSet(); - this._allPackages = new HashSet(); - } - - public void Dispose() - { - IsDisposed = true; - // locks - using var l1 = _packageIdGroupsLock.AcquireWriterLock().GetAwaiter().GetResult(); - using var l2 = _packageSetsLock.AcquireWriterLock().GetAwaiter().GetResult(); - - _eventService.Unsubscribe(this); - _eventService.Unsubscribe(this); - - _packageIdGroups.Clear(); - _packageInfoMap.Clear(); - _reversePackageIdGroups.Clear(); - } - - public bool IsDisposed - { - get => ModUtils.Threading.GetBool(ref _isDisposed); - private set => ModUtils.Threading.SetBool(ref _isDisposed, value); - } - - public FluentResults.Result Reset() - { - if (IsDisposed) - return FluentResults.Result.Fail($"Service is disposed."); - - using var l1 = _packageIdGroupsLock.AcquireWriterLock().GetAwaiter().GetResult(); - using var l2 = _packageSetsLock.AcquireWriterLock().GetAwaiter().GetResult(); - - _packageIdGroups.Clear(); - _packageInfoMap.Clear(); - _reversePackageIdGroups.Clear(); - - RefreshPackageLists(); - - return FluentResults.Result.Ok(); - } - - public void OnEnabledPackageListChanged(CorePackage package, IEnumerable regularPackages) - { - ((IService)this).CheckDisposed(); - SyncPackagesLists( - regularPackages.Select(p => (ContentPackage)p).ToImmutableArray().Add(package), - _allPackages.ToImmutableArray()) - .GetAwaiter().GetResult(); - } - - public void OnAllPackageListChanged(IEnumerable corePackages, IEnumerable regularPackages) - { - ((IService)this).CheckDisposed(); - SyncPackagesLists( - _enabledPackages.ToImmutableArray(), - regularPackages.Select(p => p as ContentPackage) - .Union(corePackages.Select(p => p as ContentPackage)) - .ToImmutableArray() - ).GetAwaiter().GetResult(); - } - - public bool IsPackageEnabled(ContentPackage package) - { - if (package is null) - return false; - using (_packageSetsLock.AcquireReaderLock().GetAwaiter().GetResult()) - { - return _enabledPackages.Contains(package); - } - } - - public async Task> Lookup(string packageName) - { - ((IService)this).CheckDisposed(); - if(packageName.IsNullOrWhiteSpace()) - return FluentResults.Result.Fail($"Name is null or empty."); - return await LookupInternal(packageName); - } - - public async Task> Lookup(string packageName, ulong steamWorkshopId) - { - ((IService)this).CheckDisposed(); - if (packageName.IsNullOrWhiteSpace() || steamWorkshopId == 0) - return FluentResults.Result.Fail($"Name or steam id is null or empty."); - return await LookupInternal((packageName, steamWorkshopId)); - } - - public async Task> Lookup(ulong steamWorkshopId) - { - ((IService)this).CheckDisposed(); - if (steamWorkshopId is 0) - return FluentResults.Result.Fail($"SteamId is 0."); - return await LookupInternal(steamWorkshopId); - } - - public async Task> Lookup(ContentPackage package) - { - ((IService)this).CheckDisposed(); - if (package is null) - return FluentResults.Result.Fail($"Package is null."); - - if (package.TryExtractSteamWorkshopId(out var steamWorkshopId) && steamWorkshopId.Value != 0) - { - if (!package.Name.IsNullOrWhiteSpace()) - return await LookupInternal((package.Name, steamWorkshopId.Value)); - else - return await LookupInternal(steamWorkshopId.Value); - } - - if (!package.Name.IsNullOrWhiteSpace()) - return await LookupInternal(package.Name); - - return FluentResults.Result.Fail($"Package name is null and steamid is 0."); - } - - public void RefreshPackageLists() - { - ((IService)this).CheckDisposed(); - if (Thread.CurrentThread != GameMain.MainThread) - throw new InvalidOperationException($"{nameof(ContentPackageInfoLookup)}: {nameof(RefreshPackageLists)} must be run on the main thread."); - var enabledPackages = _packageListRetrievalService.GetEnabledContentPackages().ToImmutableArray(); - var allPackages = _packageListRetrievalService.GetAllContentPackages().ToImmutableArray(); - SyncPackagesLists(enabledPackages, allPackages).GetAwaiter().GetResult(); - } -} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs index 077c148ff..064813b9e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs @@ -1,376 +1,127 @@ - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; -using System.Threading; using System.Threading.Tasks; using Barotrauma.LuaCs.Data; -using Barotrauma.LuaCs.Services.Processing; -using Barotrauma.Steam; using FluentResults; -using OneOf; - -// ReSharper disable UseCollectionExpression namespace Barotrauma.LuaCs.Services; public partial class PackageManagementService : IPackageManagementService { - private int _isDisposed; - private readonly ConcurrentDictionary _modInfos = new(); - // lookup caches - private readonly IPackageInfoLookupService _packageInfoLookupService; - // processors - private readonly IConverterServiceAsync _modConfigParserService; - private readonly IProcessorService, IAssembliesResourcesInfo> _assemblyInfoConverter; - private readonly IProcessorService, IConfigsResourcesInfo> _configsInfoConverter; - private readonly IProcessorService, IConfigProfilesResourcesInfo> _configProfilesConverter; - private readonly IProcessorService, ILuaScriptsResourcesInfo> _luaScriptsConverter; - - public PackageManagementService( - IConverterServiceAsync modConfigParserService, - IProcessorService, IAssembliesResourcesInfo> assemblyInfoConverter, - IProcessorService, IConfigsResourcesInfo> configsInfoConverter, - IProcessorService, IConfigProfilesResourcesInfo> configProfilesConverter, - IProcessorService, ILuaScriptsResourcesInfo> luaScriptsConverter, - IPackageInfoLookupService packageInfoLookupService) - { - _modConfigParserService = modConfigParserService; - _assemblyInfoConverter = assemblyInfoConverter; - _configsInfoConverter = configsInfoConverter; - _configProfilesConverter = configProfilesConverter; - _luaScriptsConverter = luaScriptsConverter; - _packageInfoLookupService = packageInfoLookupService; - } - public void Dispose() { - IsDisposed = true; - _modInfos.Clear(); + throw new System.NotImplementedException(); } + private int _isDisposed = 0; public bool IsDisposed { - get => ModUtils.Threading.GetBool(ref _isDisposed); - private set => ModUtils.Threading.SetBool(ref _isDisposed, value); + get => ModUtils.Threading.GetBool(ref _isDisposed); + private set => ModUtils.Threading.SetBool(ref _isDisposed, value); } - + + public FluentResults.Result Reset() { - try - { - ((IService)this).CheckDisposed(); - _modInfos.Clear(); - } - catch (Exception e) - { - return FluentResults.Result.Fail(new ExceptionalError(e)); - } - return FluentResults.Result.Ok(); + throw new System.NotImplementedException(); } - - public ImmutableArray Configs => _modInfos.IsEmpty ? ImmutableArray.Empty - : _modInfos.SelectMany(kvp => kvp.Value.Configs).ToImmutableArray(); - public ImmutableArray ConfigProfiles => _modInfos.IsEmpty ? ImmutableArray.Empty - : _modInfos.SelectMany(kvp => kvp.Value.ConfigProfiles).ToImmutableArray(); - public ImmutableArray LuaScripts => _modInfos.IsEmpty ? ImmutableArray.Empty - : _modInfos.SelectMany(kvp => kvp.Value.LuaScripts).ToImmutableArray(); - public ImmutableArray Assemblies => _modInfos.IsEmpty ? ImmutableArray.Empty - : _modInfos.SelectMany(kvp => kvp.Value.Assemblies).ToImmutableArray(); - + public ImmutableArray Configs { get; } + public ImmutableArray ConfigProfiles { get; } + public ImmutableArray LuaScripts { get; } + public ImmutableArray Assemblies { get; } public async Task LoadPackageInfosAsync(ContentPackage package) { - ((IService)this).CheckDisposed(); - if (package is null) - return FluentResults.Result.Fail(new ExceptionalError(new NullReferenceException($"{nameof(LoadPackageInfosAsync)}: ContentPackage is null."))); - var result = await _modConfigParserService.TryParseResourceAsync(package); - if (result.IsFailed) - return FluentResults.Result.Fail($"$Could not parse package mod config.").WithErrors(result.Errors); - if (!_modInfos.TryAdd(package, result.Value)) - return FluentResults.Result.Fail($"Failed to add ModInfo for {package.Name}."); - return FluentResults.Result.Ok(); + throw new System.NotImplementedException(); } public async Task> LoadPackagesInfosAsync(IReadOnlyList packages) { - ((IService)this).CheckDisposed(); - if (packages is null || packages.Count == 0) - throw new ArgumentNullException(nameof(LoadPackagesInfosAsync)); - ConcurrentQueue<(ContentPackage, FluentResults.Result)> results = new(); - await packages.ParallelForEachAsync(async package => - { - var res = await LoadPackageInfosAsync(package); - results.Enqueue((package, res)); - }, Environment.ProcessorCount); - return results.ToImmutableArray(); + throw new System.NotImplementedException(); } public IReadOnlyList GetAllLoadedPackages() { - ((IService)this).CheckDisposed(); - return _modInfos.IsEmpty ? ImmutableArray.Empty - : _modInfos.Select(kvp => kvp.Key).ToImmutableArray(); + throw new System.NotImplementedException(); } public bool IsPackageLoaded(ContentPackage package) { - return package is not null && _modInfos.ContainsKey(package); + throw new System.NotImplementedException(); } - public ImmutableArray FilterUnloadableResources(IReadOnlyList resources, bool enabledPackagesOnly = false) - where T : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo + public ImmutableArray FilterUnloadableResources(IReadOnlyList resources, bool enabledPackagesOnly = false) where T : IResourceInfo { - return resources - .Where(r => r is not null) - .Where(r => (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0) - .Where(r => (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0) - .Where(r => !r.Dependencies.Any() || r.Dependencies.All(d => - d.Dependency.GetPackage() is {} p // cp is valid - && _modInfos.ContainsKey(p) // cp is parsed - && (!enabledPackagesOnly || _packageInfoLookupService.IsPackageEnabled(p)))) // cp is enabled - .ToImmutableArray(); + throw new System.NotImplementedException(); } public void DisposePackageInfos(ContentPackage package) { - _modInfos.TryRemove(package, out _); + throw new System.NotImplementedException(); } public void DisposePackagesInfos(IReadOnlyList packages) { - if (packages is null || packages.Count == 0) - return; - - foreach (var package in packages) - { - DisposePackageInfos(package); - } - } - - public Result GetPackageDependencyInfo(ContentPackage ownerPackage, string packageName, - ulong steamWorkshopId) - { - ((IService)this).CheckDisposed(); - - if (ownerPackage is null) - return FluentResults.Result.Fail($"OwnerPackage is null."); - var nameGood = !packageName.IsNullOrWhiteSpace(); - - if (!nameGood && steamWorkshopId == 0) - FluentResults.Result.Fail($"PackageName and SteamId cannot both be invalid."); - - IPackageInfo depInfo = null; - - // complex key - if (nameGood && steamWorkshopId != 0 - && _packageInfoLookupService.Lookup(packageName, steamWorkshopId).GetAwaiter().GetResult() is - { IsSuccess: true, Value: {} dep1 }) - { - depInfo = dep1; - } - // name key - else if (nameGood && _packageInfoLookupService.Lookup(packageName).GetAwaiter().GetResult() is - { IsSuccess: true, Value: { } dep2 }) - { - depInfo = dep2; - } - // steamid key - else if (_packageInfoLookupService.Lookup(steamWorkshopId).GetAwaiter().GetResult() is - { IsSuccess: true, Value: { } dep3 }) - { - depInfo = dep3; - } - // this should never be null so we return an exception - else - { - return FluentResults.Result.Fail($"Package Dependency for {ownerPackage.Name} was not found."); - } - - return FluentResults.Result.Ok(new PackageDependency(ownerPackage, depInfo, ownerPackage.Name)); + throw new System.NotImplementedException(); } public Result GetAssembliesInfos(ContentPackage package, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (package is null) - return FluentResults.Result.Fail($"{nameof(GetAssembliesInfos)}: ContentPackage is null."); - if (_modInfos.TryGetValue(package, out var result)) - return FluentResults.Result.Ok(_assemblyInfoConverter.Process(onlySupportedResources? - result.Assemblies.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.Assemblies - )); - return FluentResults.Result.Fail( - $"{nameof(GetAssembliesInfos)}: ContentPackage {package.Name} is not registered."); + throw new System.NotImplementedException(); } public Result GetConfigsInfos(ContentPackage package, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (package is null) - return FluentResults.Result.Fail($"{nameof(GetConfigsInfos)}: ContentPackage is null."); - - if (_modInfos.TryGetValue(package, out var result)) - { - return FluentResults.Result.Ok(_configsInfoConverter.Process(onlySupportedResources? - result.Configs.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.Configs - )); - } - - return FluentResults.Result.Fail( - $"{nameof(GetConfigsInfos)}: ContentPackage {package.Name} is not registered."); + throw new System.NotImplementedException(); } public Result GetConfigProfilesInfos(ContentPackage package, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (package is null) - return FluentResults.Result.Fail($"{nameof(GetConfigProfilesInfos)}: ContentPackage is null."); - - if (_modInfos.TryGetValue(package, out var result)) - { - return FluentResults.Result.Ok(_configProfilesConverter.Process(onlySupportedResources? - result.ConfigProfiles.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.ConfigProfiles - )); - } - - return FluentResults.Result.Fail( - $"{nameof(GetConfigProfilesInfos)}: ContentPackage {package.Name} is not registered."); + throw new System.NotImplementedException(); } public Result GetLuaScriptsInfos(ContentPackage package, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (package is null) - return FluentResults.Result.Fail($"{nameof(GetLuaScriptsInfos)}: ContentPackage is null."); - - if (_modInfos.TryGetValue(package, out var result)) - { - return FluentResults.Result.Ok(_luaScriptsConverter.Process(onlySupportedResources? - result.LuaScripts.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.LuaScripts - )); - } - - return FluentResults.Result.Fail( - $"{nameof(GetLuaScriptsInfos)}: ContentPackage {package.Name} is not registered."); + throw new System.NotImplementedException(); } public Result GetAssembliesInfos(IReadOnlyList packages, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (packages is null || packages.Count == 0) - return FluentResults.Result.Fail($"{nameof(GetAssembliesInfos)}: ContentPackage list is null or empty."); - var builder = ImmutableArray.CreateBuilder(); - foreach (var package in packages) - { - if (_modInfos.TryGetValue(package, out var result) && result.Assemblies is { IsEmpty: false }) - { - builder.AddRange(onlySupportedResources? - result.Assemblies.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.Assemblies); - } - } - - return FluentResults.Result.Ok(_assemblyInfoConverter.Process(builder.MoveToImmutable())); + throw new System.NotImplementedException(); } public Result GetConfigsInfos(IReadOnlyList packages, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (packages is null || packages.Count == 0) - return FluentResults.Result.Fail($"{nameof(GetConfigsInfos)}: ContentPackage list is null or empty."); - var builder = ImmutableArray.CreateBuilder(); - foreach (var package in packages) - { - if (_modInfos.TryGetValue(package, out var result) && result.Configs is { IsEmpty: false }) - { - builder.AddRange(onlySupportedResources? - result.Configs.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.Configs); - } - } - - return FluentResults.Result.Ok(_configsInfoConverter.Process(builder.MoveToImmutable())); + throw new System.NotImplementedException(); } public Result GetConfigProfilesInfos(IReadOnlyList packages, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (packages is null || packages.Count == 0) - return FluentResults.Result.Fail($"{nameof(GetConfigProfilesInfos)}: ContentPackage list is null or empty."); - var builder = ImmutableArray.CreateBuilder(); - foreach (var package in packages) - { - if (_modInfos.TryGetValue(package, out var result) && result.ConfigProfiles is { IsEmpty: false }) - { - builder.AddRange(onlySupportedResources? - result.ConfigProfiles.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.ConfigProfiles); - } - } - - return FluentResults.Result.Ok(_configProfilesConverter.Process(builder.MoveToImmutable())); + throw new System.NotImplementedException(); } public Result GetLuaScriptsInfos(IReadOnlyList packages, bool onlySupportedResources = true) { - ((IService)this).CheckDisposed(); - if (packages is null || packages.Count == 0) - return FluentResults.Result.Fail($"{nameof(GetLuaScriptsInfos)}: ContentPackage list is null or empty."); - var builder = ImmutableArray.CreateBuilder(); - foreach (var package in packages) - { - if (_modInfos.TryGetValue(package, out var result) && result.LuaScripts is { IsEmpty: false }) - { - builder.AddRange(onlySupportedResources? - result.LuaScripts.Where(r => - (r.SupportedPlatforms & ModUtils.Environment.CurrentPlatform) > 0 - && (r.SupportedTargets & ModUtils.Environment.CurrentTarget) > 0).ToImmutableArray() - : result.LuaScripts); - } - } - - return FluentResults.Result.Ok(_luaScriptsConverter.Process(builder.MoveToImmutable())); + throw new System.NotImplementedException(); } public async Task> GetAssembliesInfosAsync(IReadOnlyList packages, bool onlySupportedResources = true) { - return await Task.Run(() => GetAssembliesInfos(packages, onlySupportedResources)); + throw new System.NotImplementedException(); } public async Task> GetConfigsInfosAsync(IReadOnlyList packages, bool onlySupportedResources = true) { - return await Task.Run(() => GetConfigsInfos(packages, onlySupportedResources)); + throw new System.NotImplementedException(); } public async Task> GetConfigProfilesInfosAsync(IReadOnlyList packages, bool onlySupportedResources = true) { - return await Task.Run(() => GetConfigProfilesInfos(packages, onlySupportedResources)); + throw new System.NotImplementedException(); } public async Task> GetLuaScriptsInfosAsync(IReadOnlyList packages, bool onlySupportedResources = true) { - return await Task.Run(() => GetLuaScriptsInfos(packages, onlySupportedResources)); + throw new System.NotImplementedException(); } - - } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/ModConfigService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/ModConfigService.cs index afb5c3ec1..8604bbe64 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/ModConfigService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/Processing/ModConfigService.cs @@ -92,25 +92,20 @@ public partial class ModConfigService : IConverterServiceAsync GetElementsDependenciesData(XElement element, ContentPackage src) - { - if (element.GetChildElement("Dependencies") is not {} dependencies - || dependencies.GetChildElements("Dependency").ToImmutableArray() is not { Length: >0 } depsList) - return ImmutableArray.Empty; - var builder = ImmutableArray.CreateBuilder(); - foreach (var dep in depsList) - { - var packName = dep.GetAttributeString("PackageName", string.Empty); - var packId = dep.GetAttributeUInt64("PackageId", 0); - - // invalid entry - if (packName.IsNullOrWhiteSpace() && packId == 0) - continue; - - if (_packageManagementService.Value.GetPackageDependencyInfo(src, packName, packId) is - { IsSuccess: true, Value: { } depsInfo }) - { - builder.Add(depsInfo); - } - } - return builder.ToImmutable(); - } private ImmutableArray GetAssembliesLegacy(ContentPackage src) { @@ -382,16 +336,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = filesSrvLin, FriendlyName = "AssembliesServerLinux", InternalName = "AssembliesServerLinux", IsScript = false, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Linux, SupportedTargets = Target.Server }); @@ -403,16 +354,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = filesSrvOsx, FriendlyName = "AssembliesServerOSX", InternalName = "AssembliesServerOSX", IsScript = false, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.OSX, SupportedTargets = Target.Server }); @@ -424,16 +372,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = filesSrvWin, FriendlyName = "AssembliesServerWin", InternalName = "AssembliesServerWin", IsScript = false, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Windows, SupportedTargets = Target.Server }); @@ -445,16 +390,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = filesCliLin, FriendlyName = "AssembliesClientLinux", InternalName = "AssembliesClientLinux", IsScript = false, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Linux, SupportedTargets = Target.Client }); @@ -466,16 +408,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = filesCliOsx, FriendlyName = "AssembliesClientOSX", InternalName = "AssembliesClientOSX", IsScript = false, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.OSX, SupportedTargets = Target.Client }); @@ -487,16 +426,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = filesCliWin, FriendlyName = "AssembliesClientWin", InternalName = "AssembliesClientWin", IsScript = false, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Windows, SupportedTargets = Target.Client }); @@ -518,16 +454,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = sharedFound ? filesCssServer.Concat(filesCssShared).ToImmutableArray() : filesCssServer, FriendlyName = "CssServer", InternalName = "CssServer", IsScript = true, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Linux | Platform.OSX | Platform.Windows, SupportedTargets = Target.Server }); @@ -539,16 +472,13 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = sharedFound ? filesCssClient.Concat(filesCssShared).ToImmutableArray() : filesCssClient, FriendlyName = "CssClient", InternalName = "CssClient", IsScript = true, - LazyLoad = false, LoadPriority = 1, Optional = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Linux | Platform.OSX | Platform.Windows, SupportedTargets = Target.Client }); @@ -565,26 +495,22 @@ public partial class ModConfigService : IConverterServiceAsync.Empty, FilePaths = fileAll.Where(path => !path.Contains("Autorun")).ToImmutableArray(), InternalName = "LuaScriptsNormal", Optional = false, IsAutorun = false, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Linux | Platform.OSX | Platform.Windows, SupportedTargets = Target.Client | Target.Server }); builder.Add(new LuaScriptsResourceInfo() { - Dependencies = ImmutableArray.Empty, FilePaths = fileAll.Where(path => path.Contains("Autorun")).ToImmutableArray(), InternalName = "LuaScriptsAutorun", Optional = false, IsAutorun = true, OwnerPackage = src, - SupportedCultures = new CultureInfo[]{ CultureInfo.InvariantCulture }.ToImmutableArray(), SupportedPlatforms = Platform.Linux | Platform.OSX | Platform.Windows, SupportedTargets = Target.Client | Target.Server }); diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/_Interfaces/IPackageInfoLookupService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/_Interfaces/IPackageInfoLookupService.cs deleted file mode 100644 index 836103c25..000000000 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/_Interfaces/IPackageInfoLookupService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; -using Barotrauma.LuaCs.Data; -using Barotrauma.LuaCs.Events; - -namespace Barotrauma.LuaCs.Services; - -public interface IPackageInfoLookupService : IReusableService -{ - bool IsPackageEnabled(ContentPackage package); - Task> Lookup(string packageName); - Task> Lookup(string packageName, ulong steamWorkshopId); - Task> Lookup(ulong steamWorkshopId); - Task> Lookup(ContentPackage package); - void RefreshPackageLists(); -} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/_Interfaces/IPackageManagementService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/_Interfaces/IPackageManagementService.cs index c342ff9f4..0f185aa8b 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/_Interfaces/IPackageManagementService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/_Interfaces/IPackageManagementService.cs @@ -39,10 +39,9 @@ public interface IPackageManagementService : IReusableService, IConfigsResources /// /// ImmutableArray FilterUnloadableResources(IReadOnlyList resources, bool enabledPackagesOnly = false) - where T : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo; + where T : IResourceInfo; void DisposePackageInfos(ContentPackage package); void DisposePackagesInfos(IReadOnlyList packages); - FluentResults.Result GetPackageDependencyInfo(ContentPackage ownerPackage, string packageName, ulong steamWorkshopId); // single FluentResults.Result GetAssembliesInfos(ContentPackage package, bool onlySupportedResources = true);