예제 #1
0
 //If nothing is there, don't do anything.
 private void TryDisconnect(Godot.Object original, string signal, Godot.Object target, string method)
 {
     if (original.IsConnected(signal, target, method))
     {
         original.Disconnect(signal, target, method);
     }
 }
 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
파일: 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)
                );
        }