예제 #1
0
 public bool Is_rotating()
 {
     if (rotateIsTransform)
     {
         return(rotate_transf.IsRotating() && !rotate_transf.IsStopping());
     }
     return(rotate_anim.Playing());
 }
예제 #2
0
        private void Set_rotation(bool rotation)
        {
            if (rotation)
            {
                if (rotateIsTransform)
                {
                    // Call Play() only if necessary
                    if (!rotate_transf.IsRotating())
                    {
                        rotate_transf.Play();
                    }
                }
                else
                {
                    rotate_anim.Resume(false);
                    // Call Play() only if necessary
                    if (!rotate_anim.Playing())
                    {
                        rotate_anim.Play(false, true);
                    }
                }

                if (counterWeightRotateIsTransform)
                {
                    // Call Play() only if necessary
                    if (!counterWeightRotate_transf.IsRotating())
                    {
                        Lib.Log("KGR: set rotation -> play " + rotation);
                        counterWeightRotate_transf.Play();
                    }
                }
                else
                {
                    if (counterWeightRotate_anim != null)
                    {
                        counterWeightRotate_anim.Resume(false);
                        // Call Play() only if necessary
                        if (!counterWeightRotate_anim.Playing())
                        {
                            counterWeightRotate_anim.Play(false, true);
                        }
                    }
                }
            }
            else
            {
                if (rotateIsTransform)
                {
                    // Call Stop only if necessary
                    if (!rotate_transf.IsStopping())
                    {
                        rotate_transf.Stop();
                    }
                }
                else
                {
                    // Call Stop only if necessary
                    if (rotate_anim.Playing())
                    {
                        rotate_anim.Pause();
                    }
                }

                if (counterWeightRotateIsTransform)
                {
                    // Call Stop only if necessary
                    if (!counterWeightRotate_transf.IsStopping())
                    {
                        Lib.Log("KGR: set rotation -> stop " + rotation);
                        counterWeightRotate_transf.Stop();
                    }
                }
                else
                {
                    if (counterWeightRotate_anim != null)
                    {
                        // Call Stop only if necessary
                        if (counterWeightRotate_anim.Playing())
                        {
                            counterWeightRotate_anim.Pause();
                        }
                    }
                }
            }
        }
예제 #3
0
		public void FixedUpdate()
		{
			// do nothing in the editor
			if (Lib.IsEditor()) return;

			// if deployed
			if (deployed || (animBackwards && !deployed))
			{
				// if there is no ec
				if (ResourceCache.Info(vessel, "ElectricCharge").amount < 0.01)
				{
					// pause rotate animation
					// - safe to pause multiple times
					if (rotateIsTransform && rotate_transf.IsRotating() && !rotate_transf.IsStopping()) rotate_transf.Stop();
					else rotate_anim.pause();
				}
				// if there is enough ec instead and is not deploying
				else if (!deploy_anim.playing())
				{
					// resume rotate animation
					// - safe to resume multiple times
					if (rotateIsTransform && (!rotate_transf.IsRotating() || rotate_transf.IsStopping())) rotate_transf.Play();
					else rotate_anim.resume(false);
				}
			}
			// stop loop animation if exist and we are retracting
			else
			{
				// Call transform.stop() if it is rotating and the Stop method wasn't called.
				if (rotateIsTransform && rotate_transf.IsRotating() && !rotate_transf.IsStopping()) rotate_transf.Stop();
				else rotate_anim.stop();
			}

			// When is not rotating
			if (waitRotation)
			{
				if (rotateIsTransform && !rotate_transf.IsRotating())
				{
					// start retract animation in the correct direction, when is not rotating
					if (animBackwards) deploy_anim.play(deployed, false);
					else deploy_anim.play(!deployed, false);
					waitRotation = false;
				}
				else if (!rotateIsTransform && !rotate_anim.playing())
				{
					if (animBackwards) deploy_anim.play(deployed, false);
					else deploy_anim.play(!deployed, false);
					waitRotation = false;
				}
			}

			// if has any animation playing, consume energy.
			if (deploy_anim.playing() || (rotate_transf.IsRotating() && !rotate_transf.IsStopping()) || rotate_anim.playing())
			{
				// get resource handler
				resource_info ec = ResourceCache.Info(vessel, "ElectricCharge");

				// consume ec
				ec.Consume(ec_rate * Kerbalism.elapsed_s);
			}

			if (rotateIsTransform && rotate_transf != null) rotate_transf.DoSpin();
		}