diff --git a/Assets/Cryville/Crtr/InputProxy.cs b/Assets/Cryville/Crtr/InputProxy.cs index f0b304e..e07d7c5 100644 --- a/Assets/Cryville/Crtr/InputProxy.cs +++ b/Assets/Cryville/Crtr/InputProxy.cs @@ -107,20 +107,11 @@ namespace Cryville.Crtr { readonly object _lock = new object(); static readonly int _var_value = IdentifierManager.SharedInstance.Request("value"); - static readonly int _var_ft = IdentifierManager.SharedInstance.Request("ft"); - static readonly int _var_tt = IdentifierManager.SharedInstance.Request("tt"); static readonly PropOp.Arbitrary _arbop = new PropOp.Arbitrary(); - readonly byte[] _numbuf = new byte[sizeof(float)]; - readonly byte[] _numbuf2 = new byte[sizeof(float)]; readonly byte[] _vecbuf = new byte[3 * sizeof(float) + sizeof(int)]; readonly Dictionary _vect = new Dictionary(); readonly Dictionary _vecs = new Dictionary(); - unsafe void LoadNum(float value) { - fixed (byte* ptr = _numbuf) *(float*)ptr = value; - } - unsafe void LoadNum2(float value) { - fixed (byte* ptr = _numbuf2) *(float*)ptr = value; - } + static readonly byte[] _nullvalue = new byte[0]; unsafe void OnInput(InputIdentifier id, InputVector vec) { lock (_lock) { InputProxyEntry proxy; @@ -128,9 +119,6 @@ namespace Cryville.Crtr { _etor.ContextCascadeInsert(); float ft, tt = (float)vec.Time; if (!_vect.TryGetValue(id, out ft)) ft = tt; - LoadNum(ft); _etor.ContextCascadeUpdate(_var_ft, new PropSrc.Arbitrary(PdtInternalType.Number, _numbuf)); - LoadNum2(tt); _etor.ContextCascadeUpdate(_var_tt, new PropSrc.Arbitrary(PdtInternalType.Number, _numbuf2)); - _vect[id] = tt; if (vec.IsNull) { _etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Null, new byte[0])); } @@ -140,21 +128,22 @@ namespace Cryville.Crtr { } _etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Vector, _vecbuf)); } - OnInput(id, proxy.Target); + OnInput(id, proxy.Target, ft, tt); + _vect[id] = tt; _etor.ContextCascadeDiscard(); } } } static readonly int _var_fv = IdentifierManager.SharedInstance.Request("fv"); static readonly int _var_tv = IdentifierManager.SharedInstance.Request("tv"); - unsafe void OnInput(InputIdentifier id, string target) { + unsafe void OnInput(InputIdentifier id, Identifier target, float ft, float tt) { var def = _ruleset.inputs[target]; if (def.pass != null) { foreach (var p in def.pass) { _etor.ContextCascadeInsert(); _arbop.Name = _var_value; _etor.Evaluate(_arbop, p.Value); - OnInput(id, p.Key); + OnInput(id, p.Key, ft, tt); _etor.ContextCascadeDiscard(); } } @@ -164,11 +153,12 @@ namespace Cryville.Crtr { if (!_vecs.TryGetValue(pid, out fv)) fv = new PropSrc.Arbitrary(PdtInternalType.Null, new byte[0]); if (fv.Type != PdtInternalType.Null || tv.Type != PdtInternalType.Null) { _etor.ContextCascadeInsert(); - _etor.ContextCascadeUpdate(_var_tv, tv); _etor.ContextCascadeUpdate(_var_fv, fv); - _judge.Feed(target); + _etor.ContextCascadeUpdate(_var_tv, tv); + _judge.Feed(target, ft, tt); _etor.ContextCascadeDiscard(); } + _judge.Cleanup(target, ft, tt); _vecs[pid] = tv; } } @@ -194,7 +184,7 @@ namespace Cryville.Crtr { public struct ProxiedInputIdentifier : IEquatable { public InputIdentifier Source { get; set; } - public string Target { get; set; } + public Identifier Target { get; set; } public override bool Equals(object obj) { if (obj == null || !(obj is ProxiedInputIdentifier)) return false; return Equals((ProxiedInputIdentifier)obj); diff --git a/Assets/Cryville/Crtr/Judge.cs b/Assets/Cryville/Crtr/Judge.cs index 18db621..0a4e92a 100644 --- a/Assets/Cryville/Crtr/Judge.cs +++ b/Assets/Cryville/Crtr/Judge.cs @@ -31,8 +31,11 @@ namespace Cryville.Crtr { } list.Add(time + def.clip[0], new JudgeEvent { EndTime = time + def.clip[1], Definition = def, State = container }); } - public void Feed(InputEvent ev) { - + public void Feed(string target, float ft, float tt) { + Logger.Log("main", 0, "Judge", "Feed {0}: {1}->{2}", target, ft, tt); + } + public void Cleanup(string target, float ft, float tt) { + Logger.Log("main", 0, "Judge", "Cleanup {0}: {1}->{2}", target, ft, tt); } public readonly Dictionary scoreDefs = new Dictionary(); public readonly Dictionary scores = new Dictionary();