Пример #1
0
		// pseudo-ctor
		public override void OnStart(StartState state)
		{
			// don't break tutorial scenarios
			if (Lib.DisableScenario(this)) return;

			// get animations
			deploy_anim = new Animator(part, deploy);
			rotate_anim = new Animator(part, rotate);

			// if is using Transform
			rotate_transf = new Transformator(part, rotate, SpinRate, SpinAccelerationRate);

			// set animation state / invert animation
			deploy_anim.still(deployed ? 1.0f : 0.0f);
			deploy_anim.stop();

			if (deployed)
			{
				rotate_transf.Play();
				rotate_anim.play(false, true);
			}

			// show the deploy toggle if it is deployable
			Events["Toggle"].active = deploy.Length > 0;
		}
Пример #2
0
		private void Set_rotation(bool rotate)
		{
			if (rotate)
			{
				if (rotateIsTransform) rotate_transf.Play();
				else
				{
					rotate_anim.Resume(false);
					if (!rotate_anim.Playing()) rotate_anim.Play(false, true);
				}
			}
			else
			{
				if (rotateIsTransform) rotate_transf.Stop();
				else rotate_anim.Pause();
			}
		}
Пример #3
0
 private void Set_rotation(bool rotate)
 {
     if (rotate)
     {
         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);
             }
         }
     }
     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();
             }
         }
     }
 }
Пример #4
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();
                        }
                    }
                }
            }
        }
Пример #5
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();
		}