From 65d86ed72d87e7c2e723f076b290c9f5b647d6d1 Mon Sep 17 00:00:00 2001 From: PopSlime Date: Sun, 6 Nov 2022 14:52:05 +0800 Subject: [PATCH] Modify logic for "and" and "or" operator and in_area function. Add null marshaling for input proxy. --- Assets/Cryville/Crtr/InputProxy.cs | 5 +++++ Assets/Cryville/Crtr/PdtEvaluator.cs | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Assets/Cryville/Crtr/InputProxy.cs b/Assets/Cryville/Crtr/InputProxy.cs index 5b06440..64173c2 100644 --- a/Assets/Cryville/Crtr/InputProxy.cs +++ b/Assets/Cryville/Crtr/InputProxy.cs @@ -117,10 +117,15 @@ namespace Cryville.Crtr { readonly byte[] _vecbuf = new byte[3 * sizeof(float) + sizeof(int)]; unsafe void OnInput(InputIdentifier id, InputVector vec, string target) { _etor.ContextCascadeInsert(); + if (vec.IsNull) { + _etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Null, new byte[0])); + } + else { fixed (byte* ptr = _vecbuf) { *(Vector3*)ptr = vec.Vector; } _etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Vector, _vecbuf)); + } OnInput(id, target); _etor.ContextCascadeDiscard(); } diff --git a/Assets/Cryville/Crtr/PdtEvaluator.cs b/Assets/Cryville/Crtr/PdtEvaluator.cs index aa3cc77..c8de6fa 100644 --- a/Assets/Cryville/Crtr/PdtEvaluator.cs +++ b/Assets/Cryville/Crtr/PdtEvaluator.cs @@ -87,8 +87,8 @@ namespace Cryville.Crtr { static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&"); static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|"); protected override bool Collapse(int name, PdtVariableMemory param) { - if (name == _colop_and) return param.AsNumber() == 0; - else if(name == _colop_or) return param.AsNumber() != 0; + if (name == _colop_and) return param.AsNumber() <= 0; + else if (name == _colop_or) return param.AsNumber() > 0; else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name)); } @@ -391,7 +391,7 @@ namespace Cryville.Crtr { if (arg.Type == PdtInternalType.Error) { throw new InvalidOperationException("Error"); } - else if (arg.Type == PdtInternalType.Number && arg.AsNumber() >= 0) { + else if (arg.Type == PdtInternalType.Number && arg.AsNumber() <= 0) { GetReturnFrame(PdtInternalType.Null, 0); } else {