Beispiel #1
0
        /// <summary>
        /// Emit a signal based on a <see cref="SignalAttribute"/> delegate.
        /// </summary>
        /// <remarks>
        /// This is recommended over <see cref="Godot.Object.EmitSignal(string, object[])"/> when using <see cref="SignalAttribute"/> (though they can be mixed) as it retrieves the signal
        /// name from the delegate's attribute. If you change the name of the signal in the attribute, you will not have to change anything when calling this function.
        /// </remarks>
        /// <typeparam name="Signal">The delegate type.</typeparam>
        /// <param name="obj">The object to emit from.</param>
        /// <param name="args">Arguments passed to the signal.</param>
        public static void EmitSignal <Signal>(this Godot.Object obj, params object[] args)
        {
            if (!typeof(Signal).IsSubclassOf(typeof(Delegate)))
            {
                throw new GodotCSToolException($"Invalid EmitSignal<T>() call, T was {typeof(Signal).FullName}");
            }

            var attr = typeof(Signal).GetCustomAttribute <SignalAttribute>();

            if (attr == null)
            {
                throw new GodotCSToolException($"Delegate {typeof(Signal).FullName} does not have a SignalAttribute");
            }

            var name = string.IsNullOrEmpty(attr.SignalName) ? typeof(Signal).Name : attr.SignalName;

            obj.EmitSignal(name, args);
        }
Beispiel #2
0
 public void GetDirection(Godot.Object response)
 {
     response.EmitSignal(SignalKey.SET_DATA, direction);
 }
Beispiel #3
0
 public void GetMoveAndSlideVelocity(Godot.Object response)
 {
     response.EmitSignal(SignalKey.SET_DATA, masVelocity);
 }