Code cleanup.

This commit is contained in:
2023-04-22 21:08:06 +08:00
parent 2784544884
commit d72afaa75b
5 changed files with 14 additions and 17 deletions

View File

@@ -36,16 +36,6 @@ namespace Cryville.Common.Pdt {
return Operate(target, _framecount, true);
}
/// <summary>
/// Patches an expression with a lefthand variable and a compound operator.
/// </summary>
/// <param name="target">The name of the lefthand variable.</param>
/// <param name="op">The name of the compound operator.</param>
/// <param name="exp">The expression.</param>
public void PatchCompound(int target, int op, PdtExpression exp) {
exp.Instructions.AddFirst(new PdtInstruction.PushVariable(target));
exp.Instructions.AddLast(new PdtInstruction.Operate(op, 2));
}
/// <summary>
/// Optimizes an expression by merging its instructions.
/// </summary>
/// <param name="exp">The expression to optimize.</param>

View File

@@ -27,6 +27,16 @@ namespace Cryville.Common.Pdt {
}
return r;
}
/// <summary>
/// Patches an expression with a lefthand variable and a compound operator.
/// </summary>
/// <param name="target">The name of the lefthand variable.</param>
/// <param name="op">The name of the compound operator.</param>
/// <param name="exp">The expression.</param>
public static void PatchCompound(int target, int op, PdtExpression exp) {
exp.Instructions.AddFirst(new PdtInstruction.PushVariable(target));
exp.Instructions.AddLast(new PdtInstruction.Operate(op, 2));
}
}
internal abstract class PdtInstruction {
internal abstract void Execute(PdtEvaluatorBase etor);

View File

@@ -59,11 +59,8 @@ namespace Cryville.Common.Unity.Input {
var t = unity::Input.GetTouch(i);
Vector2 pos = UnityCameraUtils.ScreenToWorldPoint(t.position);
var vec = new InputVector(time, pos);
if (t.phase == TouchPhase.Began || t.phase == TouchPhase.Stationary || t.phase == TouchPhase.Moved) {
handler.Feed(0, t.fingerId, vec);
}
else if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled) {
handler.Feed(0, t.fingerId, vec);
handler.Feed(0, t.fingerId, vec);
if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled) {
handler.Feed(0, t.fingerId, new InputVector(time));
}
}