refactor: Update Unity to 2022.3.62

This commit is contained in:
2025-06-21 01:22:02 +08:00
parent d71bf7d4a5
commit 283783954f
112 changed files with 778 additions and 907 deletions

View File

@@ -20,37 +20,35 @@ namespace Cryville.Crtr.Skin {
[JsonRequired]
public string ruleset;
public List<string> frames = new List<string>();
public List<string> frames = new();
[JsonIgnore]
public PdtSkin Root { get; private set; }
public void LoadPdt(DirectoryInfo dir) {
using (StreamReader pdtreader = new StreamReader(Path.Combine(dir.FullName, data + ".pdt"), Encoding.UTF8)) {
var src = pdtreader.ReadToEnd();
var interpreter = new SkinInterpreter(src, null);
var format = interpreter.GetFormatVersion();
if (format.Length == 1) {
Root = new PdtSkin();
Root.elements = (SkinElement)new SkinInterpreter(src, new PdtBinder()).Interpret(typeof(SkinElement));
}
else {
switch (format[1]) {
case 1:
Root = (PdtSkin)new SkinInterpreter(src, new PdtBinder()).Interpret(typeof(PdtSkin));
break;
default: throw new NotSupportedException("Unsupported skin format");
}
}
using StreamReader pdtreader = new(Path.Combine(dir.FullName, data + ".pdt"), Encoding.UTF8);
var src = pdtreader.ReadToEnd();
var interpreter = new SkinInterpreter(src, null);
var format = interpreter.GetFormatVersion();
if (format.Length == 1) {
Root = new PdtSkin {
elements = (SkinElement)new SkinInterpreter(src, new PdtBinder()).Interpret(typeof(SkinElement))
};
}
else {
Root = format[1] switch {
1 => (PdtSkin)new SkinInterpreter(src, new PdtBinder()).Interpret(typeof(PdtSkin)),
_ => throw new NotSupportedException("Unsupported skin format"),
};
}
}
}
public class PdtSkin {
public Dictionary<Identifier, AnimationSpan> animations
= new Dictionary<Identifier, AnimationSpan>();
= new();
public Dictionary<Identifier, EffectDefinition> effects
= new Dictionary<Identifier, EffectDefinition>();
= new();
public SkinElement elements;
public void Optimize(PdtEvaluator etor) {
@@ -74,11 +72,11 @@ namespace Cryville.Crtr.Skin {
public class SkinElement {
[ElementList]
public PairList<SkinSelectors, SkinElement> elements
= new PairList<SkinSelectors, SkinElement>();
= new();
[PropertyList]
public PairList<SkinPropertyKey, PdtExpression> properties
= new PairList<SkinPropertyKey, PdtExpression>();
= new();
public bool IsDynamic {
get;
@@ -102,19 +100,18 @@ namespace Cryville.Crtr.Skin {
}
public class EffectDefinition {
static readonly Identifier _ident_init = new Identifier("<init>");
static readonly Identifier _ident_init = new("<init>");
#pragma warning disable IDE1006
public PdtExpression duration {
set {
EffectState s;
if (!states.TryGetValue(_ident_init, out s))
if (!states.TryGetValue(_ident_init, out EffectState s))
throw new InvalidOperationException("Cannot set duration and states at the same time");
s.duration = value;
}
}
#pragma warning restore IDE1006
public Identifier init = _ident_init;
public Dictionary<Identifier, EffectState> states = new Dictionary<Identifier, EffectState> {
public Dictionary<Identifier, EffectState> states = new() {
{ _ident_init, new EffectState() { rewind = _ident_init } }
};
public SkinElement elements;
@@ -129,11 +126,11 @@ namespace Cryville.Crtr.Skin {
public class AnimationSpan {
[ElementList]
public PairList<Clip, AnimationSpan> spans
= new PairList<Clip, AnimationSpan>();
= new();
[PropertyList]
public PairList<SkinPropertyKey, PdtExpression> properties
= new PairList<SkinPropertyKey, PdtExpression>();
= new();
public void Optimize(PdtEvaluator etor) {
foreach (var p in properties) {