refactor: Update Unity to 2022.3.62
This commit is contained in:
@@ -16,13 +16,13 @@ namespace Cryville.Crtr {
|
||||
static PdtEvaluator m_instance;
|
||||
public static PdtEvaluator Instance {
|
||||
get {
|
||||
if (m_instance == null) m_instance = new PdtEvaluator();
|
||||
m_instance ??= new PdtEvaluator();
|
||||
return m_instance;
|
||||
}
|
||||
}
|
||||
|
||||
readonly Dictionary<PdtOperatorSignature, PdtOperator> _shortops = new Dictionary<PdtOperatorSignature, PdtOperator>();
|
||||
readonly IntKeyedDictionary<PdtOperator> _ctxops = new IntKeyedDictionary<PdtOperator>();
|
||||
readonly Dictionary<PdtOperatorSignature, PdtOperator> _shortops = new();
|
||||
readonly IntKeyedDictionary<PdtOperator> _ctxops = new();
|
||||
|
||||
static readonly byte[] _nullbuf = new byte[0];
|
||||
readonly byte[] _numbuf = new byte[4];
|
||||
@@ -43,8 +43,7 @@ namespace Cryville.Crtr {
|
||||
else if (name == _var_false) { LoadNum(0); type = PdtInternalType.Number; value = _numbuf; }
|
||||
else if (name == _var_null) { LoadIdent(0); type = PdtInternalType.Undefined; value = _numbuf; }
|
||||
else {
|
||||
PropSrc prop; PropStores.Float variable;
|
||||
if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out prop)) {
|
||||
if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out PropSrc prop)) {
|
||||
prop.Get(out type, out value);
|
||||
}
|
||||
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(new Identifier(name))) {
|
||||
@@ -57,7 +56,7 @@ namespace Cryville.Crtr {
|
||||
prop.Get(out type, out value);
|
||||
RevokePotentialConstant();
|
||||
}
|
||||
else if (ContextSkinContainer != null && ContextSkinContainer.Variables.TryGetValue(name, out variable)) {
|
||||
else if (ContextSkinContainer != null && ContextSkinContainer.Variables.TryGetValue(name, out PropStores.Float variable)) {
|
||||
variable.Source.Get(out type, out value);
|
||||
}
|
||||
else if (ContextRulesetConfig != null && ContextRulesetConfig.TryGetMappedSource(name, out prop)) {
|
||||
@@ -94,8 +93,7 @@ namespace Cryville.Crtr {
|
||||
static readonly int _func_int_map = IdentifierManager.Shared.Request("int_map");
|
||||
static readonly int _func_map = IdentifierManager.Shared.Request("map");
|
||||
protected override PdtOperator GetOperator(PdtOperatorSignature sig) {
|
||||
PdtOperator result;
|
||||
if (_shortops.TryGetValue(sig, out result)) {
|
||||
if (_shortops.TryGetValue(sig, out PdtOperator result)) {
|
||||
return result;
|
||||
}
|
||||
else if (_ctxops.TryGetValue(sig.Name, out result)) {
|
||||
@@ -135,7 +133,7 @@ namespace Cryville.Crtr {
|
||||
public Judge ContextJudge { get; set; }
|
||||
public PropSrc ContextSelfValue { get; set; }
|
||||
|
||||
readonly Stack<int> ContextCascadeBlocks = new Stack<int>();
|
||||
readonly Stack<int> ContextCascadeBlocks = new();
|
||||
public void ContextCascadeInsertBlock() {
|
||||
ContextCascadeBlocks.Push(_cascadeHeight);
|
||||
}
|
||||
@@ -155,10 +153,9 @@ namespace Cryville.Crtr {
|
||||
ContextCascade[_cascadeHeight - 1][key] = value;
|
||||
}
|
||||
public PropSrc ContextCascadeLookup(int name) {
|
||||
PropSrc result;
|
||||
for (int i = _cascadeHeight - 1; i >= ContextCascadeBlocks.Peek(); i--) {
|
||||
var cas = ContextCascade[i];
|
||||
if (cas.TryGetValue(name, out result)) {
|
||||
if (cas.TryGetValue(name, out PropSrc result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -226,13 +223,13 @@ namespace Cryville.Crtr {
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("circle"), new func_sphere(() => ContextSelfValue));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("sphere"), new func_sphere(() => ContextSelfValue));
|
||||
|
||||
Func<int, PropSrc> cccb = k => ContextCascadeLookup(k);
|
||||
PropSrc cccb(int k) => ContextCascadeLookup(k);
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("attack_timing"), new func_attack_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("release_timing"), new func_release_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("enter_timing"), new func_enter_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("leave_timing"), new func_leave_timing(cccb));
|
||||
|
||||
Func<int, PdtExpression> jacb = k => ContextJudge._areaFuncs[new Identifier(k)];
|
||||
PdtExpression jacb(int k) => ContextJudge._areaFuncs[new Identifier(k)];
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("attack_timed_area"), new func_attack_timed_area(cccb, jacb, this));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("release_timed_area"), new func_release_timed_area(cccb, jacb, this));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("enter_timed_area"), new func_enter_or_leave_timed_area(cccb, jacb, this, true));
|
||||
@@ -450,9 +447,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
protected override unsafe void Execute() {
|
||||
var ctx = _ctxcb();
|
||||
float dist;
|
||||
var ray = new Ray(ctx.position, ctx.rotation * Vector3.forward);
|
||||
ChartPlayer.frustumPlanes[(int)GetOperand(0).AsNumber()].Raycast(ray, out dist);
|
||||
ChartPlayer.frustumPlanes[(int)GetOperand(0).AsNumber()].Raycast(ray, out float dist);
|
||||
var ret = GetReturnFrame(PdtInternalType.Vector, sizeof(Vector3) + sizeof(int));
|
||||
ret.Set(ray.GetPoint(dist));
|
||||
ret.SetArraySuffix(PdtInternalType.Number);
|
||||
@@ -465,12 +461,11 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
protected override unsafe void Execute() {
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
float v;
|
||||
switch (LoadedOperandCount) {
|
||||
case 0: v = oputil.AsNumber(_ctxcb()); break;
|
||||
case 1: v = GetOperand(0).AsNumber(); break;
|
||||
default: throw new ArgumentException("Argument count not 0 or 1");
|
||||
}
|
||||
var v = LoadedOperandCount switch {
|
||||
0 => oputil.AsNumber(_ctxcb()),
|
||||
1 => GetOperand(0).AsNumber(),
|
||||
_ => throw new ArgumentException("Argument count not 0 or 1"),
|
||||
};
|
||||
ret.SetNumber(Mathf.Floor(v));
|
||||
}
|
||||
}
|
||||
@@ -506,12 +501,11 @@ namespace Cryville.Crtr {
|
||||
protected override unsafe void Execute() {
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
float a = GetOperand(0).AsNumber();
|
||||
float b;
|
||||
switch (LoadedOperandCount) {
|
||||
case 1: b = oputil.AsNumber(_ctxcb()); break;
|
||||
case 2: b = GetOperand(1).AsNumber(); break;
|
||||
default: throw new ArgumentException("Argument count not 2 or 3");
|
||||
}
|
||||
var b = LoadedOperandCount switch {
|
||||
1 => oputil.AsNumber(_ctxcb()),
|
||||
2 => GetOperand(1).AsNumber(),
|
||||
_ => throw new ArgumentException("Argument count not 2 or 3"),
|
||||
};
|
||||
ret.SetNumber(Mathf.Min(a, b));
|
||||
}
|
||||
}
|
||||
@@ -523,12 +517,11 @@ namespace Cryville.Crtr {
|
||||
protected override unsafe void Execute() {
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
var a = GetOperand(0).AsNumber();
|
||||
float b;
|
||||
switch (LoadedOperandCount) {
|
||||
case 1: b = oputil.AsNumber(_ctxcb()); break;
|
||||
case 2: b = GetOperand(1).AsNumber(); break;
|
||||
default: throw new ArgumentException("Argument count not 2 or 3");
|
||||
}
|
||||
var b = LoadedOperandCount switch {
|
||||
1 => oputil.AsNumber(_ctxcb()),
|
||||
2 => GetOperand(1).AsNumber(),
|
||||
_ => throw new ArgumentException("Argument count not 2 or 3"),
|
||||
};
|
||||
ret.SetNumber(Mathf.Max(a, b));
|
||||
}
|
||||
}
|
||||
@@ -539,12 +532,11 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
protected override unsafe void Execute() {
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
float arg;
|
||||
switch (LoadedOperandCount) {
|
||||
case 0: arg = oputil.AsNumber(_ctxcb()); break;
|
||||
case 1: arg = GetOperand(0).AsNumber(); break;
|
||||
default: throw new ArgumentException("Argument count not 0 or 1");
|
||||
}
|
||||
var arg = LoadedOperandCount switch {
|
||||
0 => oputil.AsNumber(_ctxcb()),
|
||||
1 => GetOperand(0).AsNumber(),
|
||||
_ => throw new ArgumentException("Argument count not 0 or 1"),
|
||||
};
|
||||
ret.SetNumber(Mathf.Abs(arg));
|
||||
}
|
||||
}
|
||||
@@ -623,12 +615,11 @@ namespace Cryville.Crtr {
|
||||
protected override unsafe void Execute() {
|
||||
float x1 = GetOperand(0).AsNumber(), y1 = GetOperand(1).AsNumber();
|
||||
float x2 = GetOperand(2).AsNumber(), y2 = GetOperand(3).AsNumber();
|
||||
float time;
|
||||
switch (LoadedOperandCount) {
|
||||
case 4: time = oputil.AsNumber(_ctxcb()); break;
|
||||
case 5: time = GetOperand(4).AsNumber(); break;
|
||||
default: throw new ArgumentException("Argument count not 4 or 5");
|
||||
}
|
||||
var time = LoadedOperandCount switch {
|
||||
4 => oputil.AsNumber(_ctxcb()),
|
||||
5 => GetOperand(4).AsNumber(),
|
||||
_ => throw new ArgumentException("Argument count not 4 or 5"),
|
||||
};
|
||||
GetReturnFrame(PdtInternalType.Number, sizeof(float))
|
||||
.SetNumber(CubicBezier.Evaluate(time, x1, y1, x2, y2, 1e-3f));
|
||||
}
|
||||
@@ -642,12 +633,11 @@ namespace Cryville.Crtr {
|
||||
_ctxcb = ctxcb;
|
||||
}
|
||||
protected override void Execute() {
|
||||
float time;
|
||||
switch (LoadedOperandCount) {
|
||||
case 0: time = oputil.AsNumber(_ctxcb()); break;
|
||||
case 1: time = GetOperand(0).AsNumber(); break;
|
||||
default: throw new ArgumentException("Argument count not 0 or 1");
|
||||
}
|
||||
var time = LoadedOperandCount switch {
|
||||
0 => oputil.AsNumber(_ctxcb()),
|
||||
1 => GetOperand(0).AsNumber(),
|
||||
_ => throw new ArgumentException("Argument count not 0 or 1"),
|
||||
};
|
||||
GetReturnFrame(PdtInternalType.Number, sizeof(float))
|
||||
.SetNumber(CubicBezier.Evaluate(time, x1, y1, x2, y2, 1e-3f));
|
||||
}
|
||||
@@ -1003,8 +993,7 @@ namespace Cryville.Crtr {
|
||||
static unsafe class oputil {
|
||||
public static float AsNumber(PropSrc src) {
|
||||
if (src == null) throw new ArgumentNullException("src");
|
||||
int type; byte[] value;
|
||||
src.Get(out type, out value);
|
||||
src.Get(out int type, out byte[] value);
|
||||
if (type != PdtInternalType.Number && type != PdtInternalType.Vector)
|
||||
throw new ArgumentException("Not a number");
|
||||
fixed (byte* ptr = value) {
|
||||
@@ -1013,8 +1002,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public static Vector4? AsVector(PropSrc src) {
|
||||
if (src == null) throw new ArgumentNullException("src");
|
||||
int type; byte[] value;
|
||||
src.Get(out type, out value);
|
||||
src.Get(out int type, out byte[] value);
|
||||
if (type == PdtInternalType.Vector) {
|
||||
fixed (byte* ptr = value) {
|
||||
return *(Vector4*)ptr;
|
||||
@@ -1032,13 +1020,13 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public static Vector4? AsVector(PdtVariableMemory op) {
|
||||
if (op.Type == PdtInternalType.Vector) {
|
||||
switch ((op.Length - sizeof(int)) / sizeof(float)) {
|
||||
case 0: return null;
|
||||
case 1: return new Vector4(op.AsNumber(), 0, 0, 0);
|
||||
case 2: return new Vector4(op.AsNumber(), op.AsNumber(sizeof(float)), 0, 0);
|
||||
case 3: return new Vector4(op.AsNumber(), op.AsNumber(sizeof(float)), op.AsNumber(2 * sizeof(float)), 0);
|
||||
default: return new Vector4(op.AsNumber(), op.AsNumber(sizeof(float)), op.AsNumber(2 * sizeof(float)), op.AsNumber(3 * sizeof(float)));
|
||||
}
|
||||
return ((op.Length - sizeof(int)) / sizeof(float)) switch {
|
||||
0 => null,
|
||||
1 => (Vector4?)new Vector4(op.AsNumber(), 0, 0, 0),
|
||||
2 => (Vector4?)new Vector4(op.AsNumber(), op.AsNumber(sizeof(float)), 0, 0),
|
||||
3 => (Vector4?)new Vector4(op.AsNumber(), op.AsNumber(sizeof(float)), op.AsNumber(2 * sizeof(float)), 0),
|
||||
_ => (Vector4?)new Vector4(op.AsNumber(), op.AsNumber(sizeof(float)), op.AsNumber(2 * sizeof(float)), op.AsNumber(3 * sizeof(float))),
|
||||
};
|
||||
}
|
||||
else if (op.Type == PdtInternalType.Number) {
|
||||
return new Vector4(op.AsNumber(), 0, 0, 0);
|
||||
|
Reference in New Issue
Block a user