private void OnVesselWasModified(Vessel v) { bool wasDecoupled = decoupled; CheckDecoupled(); if (!wasDecoupled && decoupled) { OnMoving.Fire(0, 1); OnStop.Fire(1); } }
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); } } } }
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); }
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); }
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); }
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); } } } }
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; }
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); } }
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"); }