public void FixedUpdate() { if (HighLogic.LoadedSceneIsFlight) { //print("hasInflated: " + hasInflated + " | isInflated: " + isInflated + " | isInflating: " + isInflating + " | isDeflating: " + isDeflating + " | hasBurst: " + hasBurst + " | isRepacked: " + isRepacked); float currentPressure = (float)FlightGlobals.getStaticPressure(this.part.transform.position); if (hasInflated && !hasBurst) { if (isInflated) { float lift = BalloonProperties.getLift(this); Rigidbody rb = this.part.Rigidbody; rb.AddForceAtPosition(vessel.upAxis * lift, liftPointObject.transform.position); Vector3 scale = new Vector3(BalloonProperties.getScale(this), BalloonProperties.getScale(this), BalloonProperties.getScale(this)); balloonObject.transform.localScale = scale; ropeObject.transform.rotation = Quaternion.Slerp(ropeObject.transform.rotation, Quaternion.LookRotation(vessel.upAxis, vessel.upAxis), BalloonProperties.getLift(this) / 10); balloonObject.transform.rotation = Quaternion.Slerp(balloonObject.transform.rotation, Quaternion.LookRotation(vessel.upAxis, vessel.upAxis), BalloonProperties.getLift(this) / 8); balloonObject.transform.position = balloonPointObject.transform.position; if (currentPressure < minAtmoPressure || currentPressure > maxAtmoPressure) { hasBurst = true; } } else if (isDeflating) { if (scaleInc > 0) { scaleInc -= BalloonProperties.getScale(this) / 100; balloonObject.transform.localScale = new Vector3(scaleInc, scaleInc, scaleInc); float progress = scaleInc / BalloonProperties.getScale(this); float lift = BalloonProperties.getLift(this) * progress; this.part.Rigidbody.AddForceAtPosition(vessel.upAxis * lift, liftPointObject.transform.position); ropeObject.transform.localScale = new Vector3(1, 1, progress); balloonObject.transform.position = balloonPointObject.transform.position; } else { balloonObject.SetActive(false); ropeObject.SetActive(false); isInflated = false; isDeflating = false; isRepacked = false; } } else if (!isInflated && !isInflating && !isDeflating && !isRepacked) { Events["repackBalloon"].active = true; } } else if (isInflating && !hasBurst) { if (scaleInc < BalloonProperties.getScale(this)) { scaleInc += BalloonProperties.getScale(this) / 200; balloonObject.transform.localScale = new Vector3(scaleInc, scaleInc, scaleInc); float progress = scaleInc / BalloonProperties.getScale(this); float lift = BalloonProperties.getLift(this) * progress; this.part.Rigidbody.AddForceAtPosition(vessel.upAxis * lift, liftPointObject.transform.position); ropeObject.transform.rotation = Quaternion.Slerp(ropeObject.transform.rotation, Quaternion.LookRotation(vessel.upAxis, vessel.upAxis), BalloonProperties.getLift(this) / 10); balloonObject.transform.rotation = Quaternion.Slerp(balloonObject.transform.rotation, Quaternion.LookRotation(vessel.upAxis, vessel.upAxis), BalloonProperties.getLift(this) / 8); ropeObject.transform.localScale = new Vector3(1, 1, progress); balloonObject.transform.position = balloonPointObject.transform.position; } else { hasInflated = true; isInflated = true; isInflating = false; } } else if (hasBurst && (isInflated || isInflating || isDeflating)) { this.part.Effect("burst"); isInflated = false; isInflating = false; isDeflating = false; balloonObject.SetActive(false); ropeObject.SetActive(false); Events["inflateBalloon"].active = false; Events["deflateBalloon"].active = false; Actions["inflateAction"].active = false; Actions["deflateAction"].active = false; } } }
public void FixedUpdate() { if (HighLogic.LoadedSceneIsFlight) { float num = (float)FlightGlobals.getStaticPressure(base.part.transform.position); if (hasInflated && !hasBurst) { if (isInflated) { float lift = BalloonProperties.getLift(this); base.part.AddForceAtPosition(base.vessel.upAxis * (double)lift, liftPointObject.transform.position); Vector3 localScale = new Vector3(BalloonProperties.getScale(this), BalloonProperties.getScale(this), BalloonProperties.getScale(this)); balloonObject.transform.localScale = localScale; ropeObject.transform.rotation = Quaternion.Slerp(ropeObject.transform.rotation, Quaternion.LookRotation(base.vessel.upAxis, base.vessel.upAxis), BalloonProperties.getLift(this) / 10f); balloonObject.transform.rotation = Quaternion.Slerp(balloonObject.transform.rotation, Quaternion.LookRotation(base.vessel.upAxis, base.vessel.upAxis), BalloonProperties.getLift(this) / 8f); balloonObject.transform.position = balloonPointObject.transform.position; if (!(num < minAtmoPressure) && !(num > maxAtmoPressure)) { return; } hasBurst = true; } else if (isDeflating) { if (scaleInc > 0f) { scaleInc -= BalloonProperties.getScale(this) / 100f; balloonObject.transform.localScale = new Vector3(scaleInc, scaleInc, scaleInc); float num2 = scaleInc / BalloonProperties.getScale(this); float num3 = BalloonProperties.getLift(this) * num2; base.part.AddForceAtPosition(base.vessel.upAxis * (double)num3, liftPointObject.transform.position); ropeObject.transform.localScale = new Vector3(1f, 1f, num2); balloonObject.transform.position = balloonPointObject.transform.position; } else { balloonObject.SetActive(false); ropeObject.SetActive(false); isInflated = false; isDeflating = false; isRepacked = false; } } else if (!isInflated && !isInflating && !isDeflating && !isRepacked) { base.Events["repackBalloon"].active = true; } } else if (isInflating && !hasBurst) { if (scaleInc < BalloonProperties.getScale(this)) { scaleInc += BalloonProperties.getScale(this) / 200f; balloonObject.transform.localScale = new Vector3(scaleInc, scaleInc, scaleInc); float num4 = scaleInc / BalloonProperties.getScale(this); float num5 = BalloonProperties.getLift(this) * num4; base.part.AddForceAtPosition(base.vessel.upAxis * (double)num5, liftPointObject.transform.position); ropeObject.transform.rotation = Quaternion.Slerp(ropeObject.transform.rotation, Quaternion.LookRotation(base.vessel.upAxis, base.vessel.upAxis), BalloonProperties.getLift(this) / 10f); balloonObject.transform.rotation = Quaternion.Slerp(balloonObject.transform.rotation, Quaternion.LookRotation(base.vessel.upAxis, base.vessel.upAxis), BalloonProperties.getLift(this) / 8f); ropeObject.transform.localScale = new Vector3(1f, 1f, num4); balloonObject.transform.position = balloonPointObject.transform.position; } else { hasInflated = true; isInflated = true; isInflating = false; } } else if (hasBurst) { if (!isInflated && !isInflating && !isDeflating) { return; } base.part.Effect("burst", -1); isInflated = false; isInflating = false; isDeflating = false; balloonObject.SetActive(false); ropeObject.SetActive(false); base.Events["inflateBalloon"].active = false; base.Events["deflateBalloon"].active = false; base.Actions["inflateAction"].active = false; base.Actions["deflateAction"].active = false; } } }