Add is function.

This commit is contained in:
2023-01-16 20:46:57 +08:00
parent 1003a0e199
commit 09e917dbe8
2 changed files with 21 additions and 1 deletions

View File

@@ -164,6 +164,7 @@ namespace Cryville.Crtr {
_shortops.Add(new PdtOperatorSignature("frame_seq", 3), new func_frame_seq());
_shortops.Add(new PdtOperatorSignature("in_area", 1), new func_in_area());
_shortops.Add(new PdtOperatorSignature("is", 2), new func_is());
}
#region Operators
#pragma warning disable IDE1006
@@ -346,6 +347,17 @@ namespace Cryville.Crtr {
hit.CopyTo(ret);
}
}
class func_is : PdtOperator {
public func_is() : base(2) { }
protected override unsafe void Execute() {
var op0 = GetOperand(0);
if (op0.Type == PdtInternalType.Error) throw new ArgumentException("Error");
var op1 = GetOperand(1);
if (op1.Type == PdtInternalType.Error) throw new ArgumentException("Error");
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
ret.SetNumber(op0.Equals(op1) ? 1 : 0);
}
}
#endregion
#region Contextual Functions
class func_screen_edge : PdtOperator {