コード例 #1
0
ファイル: Singleton.cs プロジェクト: semickolon/GodotRx
        public static int RegisterInstanceTracker(InstanceTracker tracker, Object target)
        {
            var id = (int)_gdInstance.Call("inject_instance_tracker", target);

            _gdInstance.Connect("instance_tracker_freed", tracker, InstanceTracker.OnFreedMethod);
            return(id);
        }
コード例 #2
0
 public static Error EnsureConnect(
     this Object o,
     string signal,
     Object target,
     string method,
     Array binds = null,
     int flags   = 0) =>
 !o.IsConnected(signal, target, method) ? o.Connect(signal, target, method, binds, flags) : Error.AlreadyExists;
コード例 #3
0
ファイル: Match.cs プロジェクト: codecomedytv/CardGame
        private static void ConnectSignals(Object emitter, string signal, Object receiver, string method)
        {
            var error = emitter.Connect(signal, receiver, method);

            if (error != Error.Ok)
            {
                GD.PushWarning(error.ToString());
            }
        }
コード例 #4
0
ファイル: Login.cs プロジェクト: ben132473u/AdventureLearn
    /// <summary>
    /// Initialization
    /// </summary>
    public override void _Ready()
    {
        GDScript fb = (GDScript)GD.Load("res://API/Facebook.gd");

        fbScript = (Godot.Object)fb.New();
        GDScript google = (GDScript)GD.Load("res://API/Google.gd");

        googleScript = (Godot.Object)google.New();
        studentBL    = new StudentBL();
        fbBtn        = GetNode <TextureButton>("FbLogin");
        googleBtn    = GetNode <TextureButton>("GoogleLogin");

        fbScript.Connect("info", this, nameof(InsertFb));
        googleScript.Connect("info2", this, nameof(InsertGoogle));
    }
コード例 #5
0
ファイル: GDTools.cs プロジェクト: mh-godot/GodotCSTools
        /// <summary>
        /// Connect a signal based on a <see cref="SignalAttribute"/> delegate.
        /// </summary>
        /// <remarks>
        /// This is recommended over <see cref="Godot.Object.Connect(string, Godot.Object, string, object[], int)"/> 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 emitting the signal.</param>
        /// <param name="target">The target object to receive the signal.</param>
        /// <param name="method">The name of the target method.</param>
        /// <param name="binds"></param>
        /// <param name="flags"></param>
        public static void Connect <Signal>(this Godot.Object obj, Godot.Object target, string method, object[] binds = null, int flags = 0)
        {
            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.Connect(name, target, method, binds, flags);
        }
コード例 #6
0
        public static IObservable <IEnumerable <object> > FromSignal(this Object source, string signal)
        {
            Ensure.That(source, nameof(source)).IsNotNull();

            return(Observable.Create <IEnumerable <object> >(v =>
            {
                var tracker = new EventTracker();

                source.Connect(signal, tracker, EventTracker.TargetMethod);

                var subscription = tracker.OnSignal.Subscribe(v.OnNext);

                return Disposable.Create(() =>
                {
                    subscription.DisposeQuietly();
                    tracker.CallDeferred("free");
                });
            }));
        }
コード例 #7
0
ファイル: Game.cs プロジェクト: theowiik/tdws
        /// <summary>
        ///   Gets called when the players projectile shooter has been changed.
        ///   Connects the...
        ///   Does nothing if the projectile shooter is null.
        /// </summary>
        /// <param name="projectileShooter">
        ///   The new projectile shooter.
        /// </param>
        private void OnProjectileShooterChanged(Object projectileShooter)
        {
            if (projectileShooter == null)
            {
                return;
            }

            var alreadyConnected = projectileShooter.IsConnected(nameof(AbstractProjectileShooter.ProjectileAdded), this, nameof(AddProjectile));

            if (alreadyConnected)
            {
                return;
            }

            projectileShooter.Connect(
                nameof(AbstractProjectileShooter.ProjectileAdded),
                this,
                nameof(AddProjectile)
                );
        }
コード例 #8
0
ファイル: GodotExtensions.cs プロジェクト: ns-mkusper/OpenEQ
 public static void Connect <T>(this Godot.Object obj, string signal, Action <T> cb)
 {
     obj.Connect(signal, new SignalWrapper1 <T>(cb), "Signal");
 }