Ejemplo n.º 1
0
        internal static unsafe void SignalCallback(IntPtr awaiterGCHandlePtr, godot_variant **args, int argCount,
                                                   godot_bool *outAwaiterIsNull)
        {
            try
            {
                var awaiter = (SignalAwaiter)GCHandle.FromIntPtr(awaiterGCHandlePtr).Target;

                if (awaiter == null)
                {
                    *outAwaiterIsNull = godot_bool.True;
                    return;
                }

                *outAwaiterIsNull = godot_bool.False;

                awaiter._completed = true;

                Variant[] signalArgs = new Variant[argCount];

                for (int i = 0; i < argCount; i++)
                {
                    signalArgs[i] = Variant.CreateCopyingBorrowed(*args[i]);
                }

                awaiter._result = signalArgs;

                awaiter._continuation?.Invoke();
            }
            catch (Exception e)
            {
                ExceptionUtils.LogException(e);
                *outAwaiterIsNull = godot_bool.False;
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }