Add contextual variable judge_delta_time
.
This commit is contained in:
@@ -67,6 +67,7 @@ namespace Cryville.Crtr {
|
||||
_numsrc3 = new PropSrc.Float(() => _numbuf3);
|
||||
_numsrc4 = new PropSrc.Float(() => _numbuf4);
|
||||
_jnumsrc = new PropSrc.Float(() => _jnumbuf);
|
||||
_jdnumsrc = new PropSrc.Float(() => _jdnumbuf);
|
||||
_jvecsrc = new PropSrc.Vector4(() => _jvecbuf);
|
||||
_identop = new PropOp.Identifier(v => _identbuf = new Identifier(v));
|
||||
_clipop = new PropOp.Clip(v => _clipbuf = v);
|
||||
@@ -176,9 +177,10 @@ namespace Cryville.Crtr {
|
||||
readonly PropSrc _numsrc1, _numsrc2, _numsrc3, _numsrc4;
|
||||
|
||||
static readonly int _var_jt = IdentifierManager.Shared.Request("judge_time");
|
||||
static readonly int _var_jdt = IdentifierManager.Shared.Request("judge_delta_time");
|
||||
static readonly int _var_jv = IdentifierManager.Shared.Request("judge_vec");
|
||||
float _jnumbuf; Vector4 _jvecbuf;
|
||||
readonly PropSrc _jnumsrc, _jvecsrc;
|
||||
float _jnumbuf, _jdnumbuf; Vector4 _jvecbuf;
|
||||
readonly PropSrc _jnumsrc, _jdnumsrc, _jvecsrc;
|
||||
|
||||
// Adopted from System.Collections.Generic.ArraySortHelper<T>.InternalBinarySearch(T[] array, int index, int length, T value, IComparer<T> comparer)
|
||||
int BinarySearch(List<JudgeEvent> list, float time, int stack) {
|
||||
@@ -208,6 +210,25 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
return ~num;
|
||||
}
|
||||
void UpdateContextJudgeEvent(JudgeEvent ev) {
|
||||
_numbuf1 = (float)ev.StartTime; _numsrc1.Invalidate(); _etor.ContextCascadeUpdate(_var_fn, _numsrc1);
|
||||
_numbuf2 = (float)ev.EndTime; _numsrc2.Invalidate(); _etor.ContextCascadeUpdate(_var_tn, _numsrc2);
|
||||
if (ev.BaseEvent != null) {
|
||||
_etor.ContextEvent = ev.BaseEvent;
|
||||
_etor.ContextState = ev.Handler.cs;
|
||||
}
|
||||
var call = ev.CallContext;
|
||||
if (call.ReturnEvent != null) {
|
||||
JudgeResult judgeResult = call.ReturnEvent.JudgeResult;
|
||||
_jnumbuf = judgeResult.Time.Value; _jnumsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jt, _jnumsrc);
|
||||
_jdnumbuf = (float)(judgeResult.Time.Value - call.ReturnEvent.StartTime); _jdnumsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jdt, _jdnumsrc);
|
||||
_jvecbuf = judgeResult.Vector; _jvecsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jv, _jvecsrc);
|
||||
}
|
||||
else {
|
||||
_etor.ContextCascadeUpdate(_var_jt, PropSrc.Null);
|
||||
_etor.ContextCascadeUpdate(_var_jv, PropSrc.Null);
|
||||
}
|
||||
}
|
||||
public void Feed(Identifier target, float ft, float tt) {
|
||||
Forward(target, tt);
|
||||
var actlist = activeEvs[target];
|
||||
@@ -223,12 +244,7 @@ namespace Cryville.Crtr {
|
||||
while (index >= 0 && index < actlist.Count) {
|
||||
var ev = actlist[index];
|
||||
if (ev.Definition.stack != cstack) break;
|
||||
_numbuf1 = (float)ev.StartTime; _numsrc1.Invalidate(); _etor.ContextCascadeUpdate(_var_fn, _numsrc1);
|
||||
_numbuf2 = (float)ev.EndTime; _numsrc2.Invalidate(); _etor.ContextCascadeUpdate(_var_tn, _numsrc2);
|
||||
if (ev.BaseEvent != null) {
|
||||
_etor.ContextEvent = ev.BaseEvent;
|
||||
_etor.ContextState = ev.Handler.cs;
|
||||
}
|
||||
UpdateContextJudgeEvent(ev);
|
||||
var def = ev.Definition;
|
||||
if (def.hit != null) {
|
||||
_etor.Evaluate(_hitop, def.hit);
|
||||
@@ -244,12 +260,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
if (hitIndex != -1) {
|
||||
var hitEvent = actlist[hitIndex];
|
||||
_numbuf1 = (float)hitEvent.StartTime; _numsrc1.Invalidate(); _etor.ContextCascadeUpdate(_var_fn, _numsrc1);
|
||||
_numbuf2 = (float)hitEvent.EndTime; _numsrc2.Invalidate(); _etor.ContextCascadeUpdate(_var_tn, _numsrc2);
|
||||
if (hitEvent.BaseEvent != null) {
|
||||
_etor.ContextEvent = hitEvent.BaseEvent;
|
||||
_etor.ContextState = hitEvent.Handler.cs;
|
||||
}
|
||||
UpdateContextJudgeEvent(hitEvent);
|
||||
var def = hitEvent.Definition;
|
||||
if (def == _judgePause) _sys.TogglePause();
|
||||
if (def.on_hit != null) Execute(hitEvent, (ft + tt) / 2, def.on_hit, false);
|
||||
@@ -294,9 +305,11 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
void Execute(JudgeEvent ev, float time, PairList<JudgeAction, PdtExpression> actions, bool onMiss, int depth = 0, int index = 0) {
|
||||
if (!onMiss && ev.JudgeResult.Time != null) {
|
||||
_jnumbuf = ev.JudgeResult.Time.Value; _jnumsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jt, _jnumsrc);
|
||||
_jvecbuf = ev.JudgeResult.Vector; _jvecsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jv, _jvecsrc);
|
||||
JudgeResult judgeResult = ev.JudgeResult;
|
||||
if (!onMiss && judgeResult.Time != null) {
|
||||
_jnumbuf = judgeResult.Time.Value; _jnumsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jt, _jnumsrc);
|
||||
_jdnumbuf = (float)(judgeResult.Time.Value - ev.StartTime); _jdnumsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jdt, _jdnumsrc);
|
||||
_jvecbuf = judgeResult.Vector; _jvecsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jv, _jvecsrc);
|
||||
}
|
||||
if (actions != null) {
|
||||
// Ensure that all actions that modifies judge result sources break the execution
|
||||
|
Reference in New Issue
Block a user