コード例 #1
0
ファイル: GDTools.cs プロジェクト: mh-godot/GodotCSTools
        /// <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);
        }
コード例 #2
0
ファイル: CharacterInput.cs プロジェクト: c0d3p0/GodotFPC
 public void GetDirection(Godot.Object response)
 {
     response.EmitSignal(SignalKey.SET_DATA, direction);
 }
コード例 #3
0
ファイル: CharacterPhysics.cs プロジェクト: c0d3p0/GodotFPC
 public void GetMoveAndSlideVelocity(Godot.Object response)
 {
     response.EmitSignal(SignalKey.SET_DATA, masVelocity);
 }