- Removed all package dependency lookup code.
- Changed from absolute file paths to the upstream `ContentPath` system.
This commit is contained in:
+16
-133
@@ -33,146 +33,29 @@ public record LuaScriptsResourcesInfo(ImmutableArray<ILuaScriptResourceInfo> Lua
|
||||
public record ConfigResourcesInfo(ImmutableArray<IConfigResourceInfo> Configs) : IConfigsResourcesInfo;
|
||||
public record ConfigProfilesResourcesInfo(ImmutableArray<IConfigProfileResourceInfo> 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<ContentPath> 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<string> FilePaths { get; init; }
|
||||
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
|
||||
public ImmutableArray<IPackageDependency> 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<IPackageInfo, ContentPackage> _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<IPackageInfo, ContentPackage> 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<IPackageInfo, ContentPackage> 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<IPackageInfo, ContentPackage> 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<IPackageInfo, ContentPackage> 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<IPackageInfo>)this).Equals(other);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public record ConfigResourceInfo : IConfigResourceInfo
|
||||
{
|
||||
public Platform SupportedPlatforms { get; init; }
|
||||
public Target SupportedTargets { get; init; }
|
||||
public int LoadPriority { get; init; }
|
||||
public ImmutableArray<string> FilePaths { get; init; }
|
||||
public bool Optional { get; init; }
|
||||
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
|
||||
public ImmutableArray<IPackageDependency> 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<string> FilePaths { get; init; }
|
||||
public bool Optional { get; init; }
|
||||
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
|
||||
public ImmutableArray<IPackageDependency> 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<string> FilePaths { get; init; }
|
||||
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
|
||||
public ImmutableArray<IPackageDependency> Dependencies { get; init; }
|
||||
public bool Optional { get; init; }
|
||||
public string InternalName { get; init; }
|
||||
public bool IsAutorun { get; init; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user