feat(render): implement Campaign AR and terrain fidelity
This commit is contained in:
parent
99cf26e00c
commit
7a5f96ede5
368 changed files with 50611 additions and 950 deletions
|
|
@ -2,6 +2,13 @@ using System.Text.Json;
|
|||
|
||||
namespace AcDream.Core.Plugins;
|
||||
|
||||
/// <summary>Host facility an entry assembly declares in <c>plugin.json</c>.</summary>
|
||||
public enum PluginKind
|
||||
{
|
||||
Gameplay,
|
||||
RenderPack,
|
||||
}
|
||||
|
||||
public sealed record PluginManifest(
|
||||
string Id,
|
||||
string DisplayName,
|
||||
|
|
@ -10,6 +17,32 @@ public sealed record PluginManifest(
|
|||
int ApiVersion,
|
||||
IReadOnlyList<string> Dependencies)
|
||||
{
|
||||
/// <summary>
|
||||
/// Declared entry-point kinds. Old manifests omit <c>kinds</c> and remain
|
||||
/// gameplay plugins, preserving the pre-render-pack loading contract.
|
||||
/// </summary>
|
||||
public IReadOnlyList<PluginKind> Kinds { get; init; } = [PluginKind.Gameplay];
|
||||
|
||||
public PluginManifest(
|
||||
string Id,
|
||||
string DisplayName,
|
||||
string Version,
|
||||
string EntryDll,
|
||||
int ApiVersion,
|
||||
IReadOnlyList<string> Dependencies,
|
||||
IReadOnlyList<PluginKind> Kinds)
|
||||
: this(Id, DisplayName, Version, EntryDll, ApiVersion, Dependencies)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(Kinds);
|
||||
if (Kinds.Count == 0)
|
||||
throw new ArgumentException("At least one plugin kind is required.", nameof(Kinds));
|
||||
this.Kinds = Kinds
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public bool Declares(PluginKind kind) => Kinds.Contains(kind);
|
||||
|
||||
public static PluginManifest Parse(string json)
|
||||
{
|
||||
PluginManifestDto? dto;
|
||||
|
|
@ -32,13 +65,40 @@ public sealed record PluginManifest(
|
|||
if (dto.ApiVersion <= 0)
|
||||
throw new PluginManifestException("apiVersion must be >= 1");
|
||||
|
||||
IReadOnlyList<PluginKind> kinds = ParseKinds(dto.Kinds);
|
||||
|
||||
return new PluginManifest(
|
||||
dto.Id!,
|
||||
dto.DisplayName!,
|
||||
dto.Version!,
|
||||
dto.EntryDll!,
|
||||
dto.ApiVersion,
|
||||
dto.Dependencies ?? Array.Empty<string>());
|
||||
dto.Dependencies ?? Array.Empty<string>(),
|
||||
kinds);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<PluginKind> ParseKinds(IReadOnlyList<string>? values)
|
||||
{
|
||||
if (values is null)
|
||||
return [PluginKind.Gameplay];
|
||||
if (values.Count == 0)
|
||||
throw new PluginManifestException("kinds must contain at least one entry");
|
||||
|
||||
var kinds = new List<PluginKind>(values.Count);
|
||||
foreach (string? value in values)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)
|
||||
|| !Enum.TryParse(value, ignoreCase: true, out PluginKind kind)
|
||||
|| !Enum.IsDefined(kind))
|
||||
{
|
||||
throw new PluginManifestException(
|
||||
$"unknown plugin kind: {value ?? "<null>"}");
|
||||
}
|
||||
|
||||
if (!kinds.Contains(kind))
|
||||
kinds.Add(kind);
|
||||
}
|
||||
return kinds;
|
||||
}
|
||||
|
||||
private static void Require(string? value, string jsonFieldName)
|
||||
|
|
@ -61,6 +121,7 @@ public sealed record PluginManifest(
|
|||
public string? EntryDll { get; set; }
|
||||
public int ApiVersion { get; set; }
|
||||
public IReadOnlyList<string>? Dependencies { get; set; }
|
||||
public IReadOnlyList<string>? Kinds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue