/// <inheritdoc/> public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result) { switch (binder.Operation) { case ExpressionType.Equal: case ExpressionType.NotEqual: if (binder.ReturnType == typeof(bool) || binder.ReturnType.IsAssignableFrom(typeof(bool))) { if (arg == null) { bool boolResult = Object.IsInstanceValid(Value); if (binder.Operation == ExpressionType.Equal) { boolResult = !boolResult; } result = boolResult; return(true); } if (arg is Object other) { bool boolResult = (Value == other); if (binder.Operation == ExpressionType.NotEqual) { boolResult = !boolResult; } result = boolResult; return(true); } } break; default: // We're not implementing operators <, <=, >, and >= (LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual). // These are used on the actual pointers in variant_op.cpp. It's better to let the user do that explicitly. break; } return(base.TryBinaryOperation(binder, arg, out result)); }
private static Object GetGdFileUtils() { if (_gdFileUtils != null && Object.IsInstanceValid(_gdFileUtils)) { return(_gdFileUtils); } GDScript script = GD.Load <GDScript>("res://Addons/Wayfarer/file_utils.gd"); _gdFileUtils = (Object)script.New(); if (_gdFileUtils == null) { throw new NullReferenceException(); } return(_gdFileUtils); }