internal static unsafe godot_bool Set(IntPtr godotObjectGCHandle, godot_string_name *name, godot_variant *value) { try { var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) { throw new InvalidOperationException(); } if (godotObject.SetGodotClassPropertyValue(CustomUnsafe.AsRef(name), CustomUnsafe.AsRef(value))) { return(godot_bool.True); } var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue( NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name))); Variant valueManaged = Variant.CreateCopyingBorrowed(*value); return(godotObject._Set(nameManaged, valueManaged).ToGodotBool()); } catch (Exception e) { ExceptionUtils.LogException(e); return(godot_bool.False); } }
internal static unsafe godot_bool HasMethodUnknownParams(IntPtr godotObjectGCHandle, godot_string_name *method) { try { var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) { return(godot_bool.False); } return(godotObject.HasGodotClassMethod(CustomUnsafe.AsRef(method)).ToGodotBool()); } catch (Exception e) { ExceptionUtils.LogException(e); return(godot_bool.False); } }
internal static unsafe godot_bool Get(IntPtr godotObjectGCHandle, godot_string_name *name, godot_variant *outRet) { try { var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) { throw new InvalidOperationException(); } if (godotObject.GetGodotClassPropertyValue(CustomUnsafe.AsRef(name), out godot_variant outRetValue)) { *outRet = outRetValue; return(godot_bool.True); } var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue( NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name))); Variant ret = godotObject._Get(nameManaged); if (ret.VariantType == Variant.Type.Nil) { *outRet = default; return(godot_bool.False); } *outRet = Marshaling.ConvertManagedObjectToVariant(ret); return(godot_bool.True); } catch (Exception e) { ExceptionUtils.LogException(e); *outRet = default; return(godot_bool.False); } }
internal static unsafe godot_bool Call(IntPtr godotObjectGCHandle, godot_string_name *method, godot_variant **args, int argCount, godot_variant_call_error *refCallError, godot_variant *ret) { try { var godotObject = (Object)GCHandle.FromIntPtr(godotObjectGCHandle).Target; if (godotObject == null) { *ret = default; (*refCallError).Error = godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL; return(godot_bool.False); } bool methodInvoked = godotObject.InvokeGodotClassMethod(CustomUnsafe.AsRef(method), new NativeVariantPtrArgs(args), argCount, out godot_variant retValue); if (!methodInvoked) { *ret = default; // This is important, as it tells Object::call that no method was called. // Otherwise, it would prevent Object::call from calling native methods. (*refCallError).Error = godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD; return(godot_bool.False); } *ret = retValue; return(godot_bool.True); } catch (Exception e) { ExceptionUtils.LogException(e); *ret = default; return(godot_bool.False); } }