public override void recalcCurve(ModuleControlledFirework mcf, out FloatCurve fc, out float timeScale) { float tda = mcf.throttleDownAmount / 100f, tdp = mcf.throttleDownPoint / 100f, tua = mcf.throttleUpAmount / 100f; // T = { u - (u-a)P/p [P < p] or 1 [P > p] }, where a = tda, p = tdp, u = tua // t = (p ln (a/u))/(a - u) + (1 - p) // special cases: // tda = 0 => t is infinite // tda = 1 => t = 1 // tua = 0 => t is infinite Debug.LogFormat("[bfer] Recalculating thrust curve: step-linear, tda = {0:F3}, tdp = {1:F3}, tua = {2:F3}", tda, tdp, tua); if (tda <= 0f) { Debug.LogErrorFormat("[bfer] bad tda, falling back to 1.0"); tda = 1f; } if (tua <= 0f) { Debug.LogErrorFormat("[bfer] bad tua, falling back to 1.0"); tua = 1f; } if (tdp <= mcf.rampWidth) { Debug.LogErrorFormat("[bfer] bad tdp, falling back to {0:F3}", mcf.rampWidth); tdp = mcf.rampWidth; } if (tda >= 1f) { // degenerate to Flat timeScale = 1f; fc = new FloatCurve(); fc.Add(0f, 1f, 0f, 0f); fc.Add(1f, 1f, 0f, 0f); } else { timeScale = tdp * (float)Math.Log(tda / tua) / (tda - tua) + 1f - tdp; fc = new FloatCurve(); fc.Add(0f, timeScale * tua, 0f, (tda - tua) / tdp); fc.Add(tdp - mcf.rampWidth, timeScale * tda, (tda - tua) / tdp, 0f); fc.Add(tdp + mcf.rampWidth, timeScale, 0f, 0f); fc.Add(1f, timeScale, 0f, 0f); } }
public override void setFieldVisibility(ModuleControlledFirework mcf) { base.setFieldVisibility(mcf); setFieldVisible(mcf, "throttleDownPoint"); setFieldVisible(mcf, "throttleDownAmount"); setFieldVisible(mcf, "throttleUpAmount"); }
private void setFieldVisibleState(ModuleControlledFirework mcf, string fieldName, bool state) { mcf.Fields[fieldName].guiActive = state; mcf.Fields[fieldName].guiActiveEditor = state; }
public override void recalcCurve(ModuleControlledFirework mcf, out FloatCurve fc, out float timeScale) { float tdp = mcf.throttleDownPoint / 100f, tda = mcf.throttleDownAmount / 100f; Debug.LogFormat("[bfer] Recalculating thrust curve: step, tdp = {0:F3}, tda = {1:F3}", tdp, tda); // Have to multiply curve points by this to scale maxThrust (almost) correctly timeScale = (1f - tdp) + (tda > 0f ? tdp / tda : 0f); fc = new FloatCurve(); // Curve is backwards, because that's how thrustCurve works fc.Add(0f, tda * timeScale, 0f, 0f); fc.Add(tdp - mcf.rampWidth, tda * timeScale, 0f, 0f); fc.Add(tdp + mcf.rampWidth, timeScale, 0f, 0f); fc.Add(1f, timeScale, 0f, 0f); }
public virtual void setFieldVisibility(ModuleControlledFirework mcf) { setFieldInvisible(mcf, "throttleDownPoint"); setFieldInvisible(mcf, "throttleDownAmount"); setFieldInvisible(mcf, "throttleUpAmount"); }
public void setFieldVisible(ModuleControlledFirework mcf, string fieldName) { setFieldVisibleState(mcf, fieldName, true); }
public abstract void recalcCurve(ModuleControlledFirework mcf, out FloatCurve fc, out float timeScale);
public bool isAvailable(ModuleControlledFirework mcf) { if (disable) return false; if (!string.IsNullOrEmpty(techRequired) && ResearchAndDevelopment.GetTechnologyState(techRequired) != RDTech.State.Available) return false; return true; }
public override void recalcCurve(ModuleControlledFirework mcf, out FloatCurve fc, out float timeScale) { // T = 1 - 0.2P // t = integ[1/(1-0.2P) dP] = (1/0.2) ln (1/(1-0.2P)) // so burn time = 5 ln (1.25) Debug.LogFormat("[bfer] Recalculating thrust curve: progressive"); // Have to multiply curve points by this to scale maxThrust (almost) correctly timeScale = (float)(5f * Math.Log(1.25)); fc = new FloatCurve(); fc.Add(0f, timeScale, 0f, -0.2f); fc.Add(1f, timeScale * 0.8f, -0.2f, 0f); }
public override void recalcCurve(ModuleControlledFirework mcf, out FloatCurve fc, out float timeScale) { float tda = mcf.throttleDownAmount / 100f; // T = tda + P(1-tda); let a = tda, b = 1-tda; then T = a + bP // t = integ[1/(a+bP) dP] = 1/b ln((a+b) / a) = (1/(1-tda)) ln(1/tda) = ln(tda) / (tda-1) // special cases: // tda = 0 => b = 1 => t = -ln(0) is infinite // tda = 1 => b = 0 => t = integ[dP] = 1 Debug.LogFormat("[bfer] Recalculating thrust curve: linear, tda = {0:F3}", tda); if (tda <= 0f) { Debug.LogErrorFormat("[bfer] bad tda, falling back to 1.0"); tda = 1f; } if (tda >= 1f) { // degenerate to Flat timeScale = 1f; fc = new FloatCurve(); fc.Add(0f, 1f, 0f, 0f); fc.Add(1f, 1f, 0f, 0f); } else { timeScale = (float)Math.Log(tda) / (tda - 1f); fc = new FloatCurve(); fc.Add(0f, timeScale * tda, 0f, (1f - tda)); fc.Add(1f, timeScale, (1f - tda), 0f); } }
public override void recalcCurve(ModuleControlledFirework mcf, out FloatCurve fc, out float timeScale) { float tda = mcf.throttleDownAmount / 100f; Debug.LogFormat("[bfer] Recalculating thrust curve: flat, tda = {0:F3}", tda); timeScale = tda > 0f ? 1f / tda : 0f; fc = new FloatCurve(); // Curve is backwards, because that's how thrustCurve works fc.Add(0f, 1f, 0f, 0f); fc.Add(1f, 1f, 0f, 0f); }