예제 #1
0
        private void OnVesselWasModified(Vessel v)
        {
            bool wasDecoupled = decoupled;

            CheckDecoupled();
            if (!wasDecoupled && decoupled)
            {
                OnMoving.Fire(0, 1);
                OnStop.Fire(1);
            }
        }
예제 #2
0
 private void OnVesselWasModified(Vessel v)
 {
     if ((object)v != null && v == vessel)
     {
         if (!(isDecoupling || isDecoupled))
         {
             if ((object)part.FindAttachNode(this.explosiveNodeID).attachedPart == null)
             {
                 isDecoupling = true;
                 OnMoving.Fire(0f, 1f);
                 OnStop.Fire(1f);
             }
         }
     }
 }
예제 #3
0
 public void Decouple()
 {
     OnMoving.Fire(0, 1);
     if (decoupler != null && !decoupler.isDecoupled)
     {
         decoupler.Decouple();
     }
     foreach (ModuleDecouple d in panels)
     {
         if (!d.isDecoupled)
         {
             d.Decouple();
         }
     }
     OnStop.Fire(1);
 }
예제 #4
0
        private void OnEditorToggleJettisoned(BaseField field, object oldValue)
        {
            if (!HighLogic.LoadedSceneIsEditor)
            {
                return;
            }

            OnMoving.Fire(isJettisoned ? 0 : 1, isJettisoned ? 1 : 0);

            if (jettisons.Length > 0)
            {
                SetJettisoned(isJettisoned);
            }

            OnStop.Fire(isJettisoned ? 1 : 0);
        }
예제 #5
0
        public void Jettison()
        {
            if (isJettisoned)
            {
                return;
            }

            if (jettisons.Length == 0)
            {
                return;
            }

            OnMoving.Fire(0, 1);

            for (int i = 0; i < jettisons.Length; i++)
            {
                Rigidbody rb = physicalObject.ConvertToPhysicalObject(part, jettisons[i].gameObject).rb;
                rb.useGravity         = true;
                rb.mass               = jettisonedObjectMass / jettisons.Length;
                rb.maxAngularVelocity = PhysicsGlobals.MaxAngularVelocity;
                rb.angularVelocity    = part.Rigidbody.angularVelocity;
                rb.velocity           = part.Rigidbody.velocity + Vector3.Cross(part.Rigidbody.worldCenterOfMass - vessel.CurrentCoM, vessel.angularVelocity);

                Vector3 d = jettisonDirection;
                if (d == Vector3.zero)
                {
                    d = Vector3.Normalize(rb.transform.position - part.transform.position);
                }
                else
                {
                    d = part.transform.TransformDirection(d);
                }

                //rb.AddForce(part.transform.TransformDirection(jettisonDirection) * (jettisonForce * 0.5f), ForceMode.Force);
                rb.AddForceAtPosition(d * (jettisonForce * 0.5f), part.transform.position, ForceMode.Force);
                rb.AddTorque(d * jettisonTorque, ForceMode.VelocityChange);
                //part.Rigidbody.AddForce(d * (-jettisonForce * 0.5f), ForceMode.Force);
            }

            jettisons = new Transform[0];

            isJettisoned = true;

            SetJettisoned(isJettisoned);

            OnStop.Fire(1);
        }
예제 #6
0
 private void OnVesselWasModified(Vessel v)
 {
     if ((object)v != null && v == vessel)
     {
         if (!(isDecoupling || isDecoupled))
         {
             Part p;
             p = this.ExplosiveNode.attachedPart;
             if (p = null)
             {
                 isDecoupling = true;
                 OnMoving.Fire(0f, 1f);
                 OnStop.Fire(1f);
             }
         }
     }
 }
예제 #7
0
 public void SetDeployed(bool newState)
 {
     if (deployed != newState)
     {
         if (newState)
         {
             OnMoving.Fire(stowedAnchor, deployedAnchor);
         }
         else
         {
             OnMoving.Fire(deployedAnchor, stowedAnchor);
         }
         OnStop.Fire(SpringAnchor());
     }
     deployed = newState;
     Events["Deploy"].guiActive     = !deployed;
     Actions["DeployAction"].active = !deployed;
 }
예제 #8
0
        public void FixedUpdate() // Clean this up and use OnVesselWasModified to catch decouple by other means
        {
            foreach (var anim in animationStates)
            {
                if (anim.normalizedTime >= 1)
                {
                    anim.speed          = 0;
                    anim.normalizedTime = 1;
                }

                if (HighLogic.LoadedSceneIsFlight && !decoupled && decoupler != null && decoupler.isDecoupled)
                {
                    decoupled = true;
                    PlayAnimation(1);
                }

                if (anim.normalizedTime < 0)
                {
                    anim.speed          = 0;
                    anim.normalizedTime = 0;
                }
                animPosition = anim.normalizedTime;
                animSpeed    = anim.speed;
            }

            if (HighLogic.LoadedSceneIsFlight && animPosition >= waitForAnimation && animSpeed > 0)
            {
                if (decoupler != null && !decoupler.isDecoupled)
                {
                    decoupler.Decouple();
                }
                decoupled = true;
                if (payloadDecoupler != null)
                {
                    payloadDecoupler.isEnabled = true;
                }
            }

            if (playing && animSpeed == 0f)
            {
                playing = false;
                OnStop.Fire(animPosition);
            }
        }
예제 #9
0
        public void Jettison()
        {
            if (isJettisoned)
            {
                return;
            }

            if (jettisons.Length == 0)
            {
                return;
            }

            OnMoving.Fire(0, 1);

            for (int i = 0; i < jettisons.Length; i++)
            {
                Rigidbody rb = physicalObject.ConvertToPhysicalObject(part, jettisons[i].gameObject).rb;
                rb.useGravity         = true;
                rb.mass               = jettisonedObjectMass / jettisons.Length;
                rb.maxAngularVelocity = PhysicsGlobals.MaxAngularVelocity;
                rb.angularVelocity    = part.Rigidbody.angularVelocity;
                rb.velocity           = part.Rigidbody.velocity + Vector3.Cross(part.Rigidbody.worldCenterOfMass - vessel.CurrentCoM, vessel.angularVelocity);

                Vector3 d = jettisonDirection;
                if (d == Vector3.zero)
                {
                    d = Vector3.Normalize(rb.transform.position - part.transform.position);
                }
                else
                {
                    d = part.transform.TransformDirection(d);
                }

                //rb.AddForce(part.transform.TransformDirection(jettisonDirection) * (jettisonForce * 0.5f), ForceMode.Force);
                rb.AddForceAtPosition(d * (jettisonForce * 0.5f), part.transform.position, ForceMode.Force);
                part.Rigidbody.AddForce(d * (-jettisonForce * 0.5f), ForceMode.Force);
            }

            jettisons = new Transform[0];

            if (part.temperature < part.skinMaxTemp)
            {
                part.skinTemperature = part.temperature;
            }

            isJettisoned = true;

            SetJettisoned(isJettisoned);

            OnStop.Fire(1);

            EnableOtherModules();

            FXGroup effect = part.findFxGroup(fxGroupName);

            if (effect != null)
            {
                effect.Burst();
            }

            GameEvents.onVesselWasModified.Fire(vessel);
        }
 private void DoStopAnimation(float pos)
 {
     OnStop.Fire(animPosition);
     part.Effect("deploy", 0f);
     part.Effect("deployed");
 }