Add secondary judge functions in_timing
and in_area
.
This commit is contained in:
@@ -208,6 +208,9 @@ namespace Cryville.Crtr {
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("leave_timed_area"), new func_enter_or_leave_timed_area(cccb, jacb, this, false));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("enter_timing_area"), new func_enter_or_leave_timing_area(cccb, jacb, this, true));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("leave_timing_area"), new func_enter_or_leave_timing_area(cccb, jacb, this, false));
|
||||
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("in_timing"), new func_in_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("in_area"), new func_in_area(cccb, jacb, this));
|
||||
}
|
||||
#region Operators
|
||||
#pragma warning disable IDE1006
|
||||
@@ -892,6 +895,54 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
static readonly int _var_jt = IdentifierManager.Shared.Request("judge_time");
|
||||
static readonly int _var_jv = IdentifierManager.Shared.Request("judge_vec");
|
||||
class func_in_timing : PdtOperator {
|
||||
readonly Func<int, PropSrc> _ctxcb;
|
||||
public func_in_timing(Func<int, PropSrc> ctxcb) : base(2) {
|
||||
_ctxcb = ctxcb;
|
||||
}
|
||||
protected sealed override void Execute() {
|
||||
var fn = oputil.AsNumber(_ctxcb(_var_fn));
|
||||
var tn = oputil.AsNumber(_ctxcb(_var_tn));
|
||||
var t0 = GetOperand(0).AsNumber() + fn;
|
||||
var t1 = GetOperand(1).AsNumber() + tn;
|
||||
var jt = oputil.AsNumber(_ctxcb(_var_jt));
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
ret.SetNumber((jt > t0 && jt <= t1) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
class func_in_area : PdtOperator {
|
||||
readonly Func<int, PropSrc> _ctxcb;
|
||||
readonly Func<int, PdtExpression> _jacb;
|
||||
readonly PdtEvaluator _etor;
|
||||
float _area;
|
||||
readonly PropOp _areaOp;
|
||||
Vector4 _vec;
|
||||
readonly PropSrc _vecSrc;
|
||||
public func_in_area(Func<int, PropSrc> ctxcb, Func<int, PdtExpression> jacb, PdtEvaluator etor) : base(2) {
|
||||
_ctxcb = ctxcb;
|
||||
_jacb = jacb;
|
||||
_etor = etor;
|
||||
_areaOp = new PropOp.Float(v => _area = v);
|
||||
_vecSrc = new PropSrc.Vector4(() => _vec);
|
||||
}
|
||||
protected sealed override void Execute() {
|
||||
var jv = oputil.AsVector(_ctxcb(_var_jv));
|
||||
if (jv == null) {
|
||||
_etor.ContextSelfValue = PropSrc.Null;
|
||||
}
|
||||
else {
|
||||
_vec = jv.Value;
|
||||
_vecSrc.Invalidate();
|
||||
_etor.ContextSelfValue = _vecSrc;
|
||||
}
|
||||
_etor.Evaluate(_areaOp, _jacb(GetOperand(0).AsIdentifier()));
|
||||
_etor.ContextSelfValue = null;
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
ret.SetNumber(_area);
|
||||
}
|
||||
}
|
||||
static unsafe class oputil {
|
||||
public static float AsNumber(PropSrc src) {
|
||||
if (src == null) throw new ArgumentNullException("src");
|
||||
|
Reference in New Issue
Block a user