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

@@ -23,10 +23,9 @@ namespace Cryville.Crtr.Ruleset {
public PdtRuleset 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();
Root = (PdtRuleset)new RulesetInterpreter(src, null).Interpret(typeof(PdtRuleset));
}
using StreamReader pdtreader = new(Path.Combine(dir.FullName, data + ".pdt"), Encoding.UTF8);
var src = pdtreader.ReadToEnd();
Root = (PdtRuleset)new RulesetInterpreter(src, null).Interpret(typeof(PdtRuleset));
}
}
@@ -99,7 +98,7 @@ namespace Cryville.Crtr.Ruleset {
#pragma warning disable IDE1006
public PairList<ScoreOperation, PdtExpression> scores {
set {
if (on_hit == null) on_hit = new PairList<JudgeAction, PdtExpression>();
on_hit ??= new PairList<JudgeAction, PdtExpression>();
int i = 0;
foreach (var s in value) {
on_hit.Insert(i++, new JudgeAction.Score(s.Key), s.Value);
@@ -108,13 +107,13 @@ namespace Cryville.Crtr.Ruleset {
}
public Identifier[] pass {
set {
if (on_hit == null) on_hit = new PairList<JudgeAction, PdtExpression>();
on_hit ??= new PairList<JudgeAction, PdtExpression>();
on_hit.Add(new JudgeAction.Pass(Enumerable.Empty<string>(), value), PdtExpression.Empty);
}
}
public Identifier[] miss {
set {
if (on_miss == null) on_miss = new PairList<JudgeAction, PdtExpression>();
on_miss ??= new PairList<JudgeAction, PdtExpression>();
on_miss.Add(new JudgeAction.Pass(Enumerable.Empty<string>(), value), PdtExpression.Empty);
}
}
@@ -134,7 +133,7 @@ namespace Cryville.Crtr.Ruleset {
op = new Identifier(m.Groups[2].Value);
}
public override string ToString() {
if (op == default(Identifier)) return name.ToString();
if (op == default) return name.ToString();
else return string.Format("{0} {1}", name, op);
}
}
@@ -144,11 +143,11 @@ namespace Cryville.Crtr.Ruleset {
public string format = "";
}
public class Constraint {
static readonly PropOp.Arbitrary _arbop = new PropOp.Arbitrary();
static readonly PropOp.Arbitrary _arbop = new();
[ElementList]
public PairList<RulesetSelectors, Constraint> Elements = new PairList<RulesetSelectors, Constraint>();
public PairList<RulesetSelectors, Constraint> Elements = new();
[PropertyList]
public PairList<ConstraintKey, PdtExpression> Properties = new PairList<ConstraintKey, PdtExpression>();
public PairList<ConstraintKey, PdtExpression> Properties = new();
public void Optimize(PdtEvaluatorBase etor) {
foreach (var e in Properties) {
etor.Optimize(e.Value);
@@ -160,14 +159,13 @@ namespace Cryville.Crtr.Ruleset {
}
public void PrePatch(ChartEvent ev) {
var etor = PdtEvaluator.Instance;
PropSrc src;
etor.ContextCascadeInsert();
etor.ContextEvent = ev;
foreach (var prop in Properties) {
var name = prop.Key.Name;
switch (prop.Key.Type) {
case ConstraintType.Property:
if (ev.PropSrcs.TryGetValue(name, out src))
if (ev.PropSrcs.TryGetValue(name, out PropSrc src))
etor.ContextSelfValue = src;
etor.Evaluate(ev.PropOps[name], prop.Value);
etor.ContextSelfValue = null;
@@ -196,13 +194,11 @@ namespace Cryville.Crtr.Ruleset {
Type = type;
Name = IdentifierManager.Shared.Request(name);
}
public override string ToString() {
switch (Type) {
case ConstraintType.Property: return (string)IdentifierManager.Shared.Retrieve(Name);
case ConstraintType.Variable: return string.Format("@var {0}", IdentifierManager.Shared.Retrieve(Name));
default: return string.Format("<{0}> {1}", Type, IdentifierManager.Shared.Retrieve(Name));
}
}
public override string ToString() => Type switch {
ConstraintType.Property => (string)IdentifierManager.Shared.Retrieve(Name),
ConstraintType.Variable => string.Format("@var {0}", IdentifierManager.Shared.Retrieve(Name)),
_ => string.Format("<{0}> {1}", Type, IdentifierManager.Shared.Retrieve(Name)),
};
}
public enum ConstraintType {
Property,