本文整理汇总了C#中FloatCurve.Load方法的典型用法代码示例。如果您正苦于以下问题:C# FloatCurve.Load方法的具体用法?C# FloatCurve.Load怎么用?C# FloatCurve.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatCurve
的用法示例。
在下文中一共展示了FloatCurve.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public void Load(ConfigNode node)
{
if (node.HasValue("scope"))
scope = node.GetValue("scope").ToLower();
if (node.HasNode("reliabilityCurve"))
{
reliabilityCurve = new FloatCurve();
reliabilityCurve.Load(node.GetNode("reliabilityCurve"));
}
}
示例2: OnLoad
public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
if (node.HasNode("cycle"))
{
cycle = new FloatCurve();
cycle.Load(node.GetNode("cycle"));
}
else
cycle = null;
}
示例3: OnLoad
public override void OnLoad(ConfigNode node)
{
// As of v1.3 we dont' need to worry about reliability bodies anymore, just a simple FloatCurve
if (node.HasNode("reliabilityCurve"))
{
reliabilityCurve = new FloatCurve();
reliabilityCurve.Load(node.GetNode("reliabilityCurve"));
}
// if (node.HasNode("RELIABILITY_BODY"))
// {
// if (reliabilityBodies == null)
// reliabilityBodies = new List<ReliabilityBodyConfig>();
// foreach (ConfigNode bodyNode in node.GetNodes("RELIABILITY_BODY"))
// {
// ReliabilityBodyConfig reliabilityBody = new ReliabilityBodyConfig();
// reliabilityBody.Load(bodyNode);
// reliabilityBodies.Add(reliabilityBody);
// }
// }
base.OnLoad(node);
}
示例4: FixPressure
void FixPressure(FloatCurve curve, double topLayer)
{
List<double[]> list = ReadCurve(curve); /* Avoid Bad Curves ==> */ if (list.Count < 2) { UnityEngine.Debug.Log("SigmaLog: This pressure curve has " + (list.Count == 0 ? "no keys" : "just one key") + ". I don't know what you expect me to do with that."); return; }
double maxAltitude = list.Last()[0];
bool smoothEnd = list.Last()[1] == 0 && list.Count > 2;
double smoothRange = list.Last()[0] - list[list.Count - 2][0];
if (smoothEnd) list.RemoveAt(list.Count - 1);
if (topLayer > maxAltitude)
{
Extend(list, topLayer);
maxAltitude = list.Last()[0];
}
if (topLayer < maxAltitude)
{
Trim(list, topLayer);
}
if (smoothEnd)
{
Smooth(list, smoothRange);
}
curve.Load(WriteCurve(list));
}
示例5: Load
public void Load(ConfigNode node)
{
if (node.HasNode("PROPELLER"))
node = node.GetNode("PROPELLER");
if (node.HasValue("name"))
name = node.GetValue("name");
if (node.HasValue("ixx"))
Ixx = double.Parse(node.GetValue("ixx"));
if (node.HasValue("ixxFTLB"))
Ixx = double.Parse(node.GetValue("ixxFTLB")) * FTLBTOJ;
if (node.HasValue("diameterIN"))
Diameter = double.Parse(node.GetValue("diameterIN")) * INTOM;
if (node.HasValue("diameterFT"))
Diameter = double.Parse(node.GetValue("diameterFT")) * FTTOM;
if (node.HasValue("diameter"))
Diameter = double.Parse(node.GetValue("diameter"));
if (node.HasValue("numblades"))
numBlades = int.Parse(node.GetValue("numblades"));
if (node.HasValue("gearratio"))
GearRatio = double.Parse(node.GetValue("gearratio"));
if (node.HasValue("minpitch"))
MinPitch = double.Parse(node.GetValue("minpitch"));
if (node.HasValue("maxpitch"))
MaxPitch = double.Parse(node.GetValue("maxpitch"));
if (node.HasValue("minrpm"))
MinRPM = double.Parse(node.GetValue("minrpm"));
if (node.HasValue("maxrpm"))
{
MaxRPM = double.Parse(node.GetValue("maxrpm"));
ConstantSpeed = 1;
}
if (node.HasValue("constspeed"))
ConstantSpeed = int.Parse(node.GetValue("constspeed"));
if (node.HasValue("reversepitch"))
ReversePitch = double.Parse(node.GetValue("reversepitch"));
if (node.HasNode("cThrust"))
cThrust = new FGTable(node.GetNode("cThrust"));
if (node.HasNode("cThrustFP"))
{
cThrustFP = new FloatCurve();
cThrustFP.Load(node.GetNode("cThrustFP"));
}
if (node.HasNode("cPower"))
cPower = new FGTable(node.GetNode("cPower"));
if (node.HasNode("cPowerFP"))
{
cPowerFP = new FloatCurve();
cPowerFP.Load(node.GetNode("cPowerFP"));
}
if (node.HasNode("CtMach"))
{
CtMach = new FloatCurve();
CtMach.Load(node.GetNode("CtMach"));
}
if (node.HasNode("CpMach"))
{
CpMach = new FloatCurve();
CpMach.Load(node.GetNode("CpMach"));
}
if (node.HasNode("MachDrag"))
{
MachDrag = new FloatCurve();
MachDrag.Load(node.GetNode("MachDrag"));
}
if (node.HasValue("sense"))
Sense = double.Parse(node.GetValue("sense"));
SetSense(Sense >= 0.0 ? 1.0 : -1.0);
if (node.HasValue("P_Factor"))
P_Factor = double.Parse(node.GetValue("P_Factor"));
if (node.HasValue("ct_factor"))
SetCtFactor(double.Parse(node.GetValue("ct_factor")));
if (node.HasValue("cp_factor"))
SetCpFactor(double.Parse(node.GetValue("cp_factor")));
CalcDefaults();
// persistent values
if (node.HasValue("RPM"))
RPM = double.Parse(node.GetValue("RPM"));
if (node.HasValue("Pitch"))
Pitch = double.Parse(node.GetValue("Pitch"));
if (node.HasValue("Feathered"))
Feathered = bool.Parse(node.GetValue("Feathered"));
if (node.HasValue("Reversed"))
Reversed = bool.Parse(node.GetValue("Reversed"));
}
示例6: GetInfo
public override string GetInfo()
{
if (!compatible)
return "";
if (configs.Count < 2)
return TLTInfo();
string info = TLTInfo() + "\nAlternate configurations:\n";
//Unused as yet
/*TechLevel moduleTLInfo = new TechLevel();
if (techNodes != null)
moduleTLInfo.Load(techNodes, techLevel);
else
moduleTLInfo = null;*/
foreach (ConfigNode config in configs) {
TechLevel cTL = new TechLevel();
if (!cTL.Load(config, techNodes, engineType, techLevel))
cTL = null;
if(!config.GetValue ("name").Equals (configuration)) {
info += " " + config.GetValue ("name") + "\n";
if(config.HasValue (thrustRating))
info += " (" + (scale * ThrustTL(config.GetValue (thrustRating), config)).ToString("0.00") + " Thrust";
else
info += " (Unknown Thrust";
float cst;
if(config.HasValue("cost") && float.TryParse(config.GetValue("cost"), out cst))
info += " (" + (scale*cst).ToString("N0") + " extra cost)"; // FIXME should get cost from TL, but this should be safe
// because it will always be the cost for the original TL, and thus unmodified.
FloatCurve isp = new FloatCurve();
if(config.HasNode ("atmosphereCurve")) {
isp.Load (config.GetNode ("atmosphereCurve"));
info += ", "
+ isp.Evaluate (isp.maxTime).ToString() + "-"
+ isp.Evaluate (isp.minTime).ToString() + "Isp";
}
else if (config.HasValue("IspSL") && config.HasValue("IspV"))
{
float ispSL = 1.0f, ispV = 1.0f;
float.TryParse(config.GetValue("IspSL"), out ispSL);
float.TryParse(config.GetValue("IspV"), out ispV);
if (cTL != null)
{
ispSL *= ispSLMult * cTL.AtmosphereCurve.Evaluate(1);
ispV *= ispVMult * cTL.AtmosphereCurve.Evaluate(0);
info += ", " + ispSL.ToString("0") + "-" + ispV.ToString("0") + "Isp";
}
}
float gimbalR = -1f;
if (config.HasValue("gimbalRange"))
gimbalR = float.Parse(config.GetValue("gimbalRange"));
// Don't do per-TL checks here, they're misleading.
/*else if (!gimbalTransform.Equals("") || useGimbalAnyway)
{
if (cTL != null)
gimbalR = cTL.GimbalRange;
}*/
if (gimbalR != -1f)
info += ", Gimbal " + gimbalR.ToString("N1");
if (config.HasValue("ullage"))
info += ", " + (config.GetValue("ullage").ToLower() == "true" ? "ullage" : "no ullage");
if (config.HasValue("pressureFed") && config.GetValue("pressureFed").ToLower() == "true")
info += ", pfed";
if (config.HasValue("ignitions"))
{
int ignitions;
if (int.TryParse(config.GetValue("ignitions"), out ignitions))
{
if (ignitions > 0)
info += ", " + ignitions + " ignition" + (ignitions > 1 ? "s" : "");
else
info += ", unl. ignitions";
}
}
info += ")\n";
}
}
return info;
}
示例7: ModifyCurveKeys
public static FloatCurve ModifyCurveKeys(ConfigNode tempNode, float vacMult, float atmMult, bool extendToZero)
{
FloatCurve initialCurve = new FloatCurve();
initialCurve.Load(tempNode);
string[] keyStrings = tempNode.GetValues("key");
float maxTime, ispAtMaxTime, secondTime, ispAtSecondTime, maxPressure;
maxTime = ispAtMaxTime = secondTime = ispAtSecondTime = maxPressure = 0;
FloatCurve newAtmosphereCurve = new FloatCurve();
maxTime = initialCurve.maxTime;
for (int i = 0; i < keyStrings.Length; i++)
{
string[] splitKey = keyStrings[i].Split(' ');
float scalar = vacMult + Convert.ToSingle(splitKey[0]) * (atmMult - vacMult);
if (!extendToZero)
scalar = Mathf.Clamp(scalar, Mathf.Min(atmMult, vacMult), Mathf.Max(atmMult, vacMult));
if (Convert.ToSingle(splitKey[0]) != 0)
newAtmosphereCurve.Add(Convert.ToSingle(splitKey[0]), Convert.ToSingle(splitKey[1]) * scalar, Convert.ToSingle(splitKey[2]) * scalar, Convert.ToSingle(splitKey[3]) * scalar);
else
newAtmosphereCurve.Add(Convert.ToSingle(splitKey[0]), Convert.ToSingle(splitKey[1]) * scalar, 0, 0);
if (i == keyStrings.Length - 2)
{
secondTime = Convert.ToSingle(splitKey[0]);
ispAtSecondTime = Convert.ToSingle(splitKey[1]) * scalar;
}
}
ispAtMaxTime = newAtmosphereCurve.Evaluate(maxTime);
if (extendToZero && (ispAtSecondTime - ispAtMaxTime) >= 0.0001f)
{
maxPressure = maxTime + (0.01f - ispAtMaxTime) / (ispAtSecondTime - ispAtMaxTime) * (secondTime - maxTime);
newAtmosphereCurve.Add(maxPressure, 0.01f, 0, 0);
}
return newAtmosphereCurve;
}
示例8: OnLoad
public override void OnLoad(ConfigNode node)
{
if (thrustCurve == null)
thrustCurve = new FloatCurve();
base.OnLoad(node);
// Manually reload ignitions if not in editor
if(!HighLogic.LoadedSceneIsEditor)
node.TryGetValue("ignited", ref ignited);
int pCount = propellants.Count;
// thrust curve
useThrustCurve = false;
if (node.HasNode("thrustCurve") && node.HasValue("curveResource"))
{
if (node.GetValue("curveResource") != curveResource)
{
Debug.Log("*RFE* ERROR: curveResource doesn't match node's!");
curveResource = node.GetValue("curveResource");
}
if (thrustCurve == null)
{
Debug.Log("*RFE* ERROR: have curve node but thrustCurve is null!");
thrustCurve = new FloatCurve();
thrustCurve.Load(node.GetNode("thrustCurve"));
}
if (curveResource != "")
{
for (int i = 0; i < pCount; ++i)
{
if (propellants[i].name.Equals(curveResource))
{
curveProp = i;
break;
}
}
if (curveProp != -1)
{
useThrustCurve = true;
}
}
}
// Set from propellants
bool instantThrottle = true;
for (int i = 0; i < pCount; ++i)
{
if (RFSettings.Instance.instantThrottleProps.Contains(propellants[i].name))
{
instantThrottle = false;
}
// any other stuff
}
// FIXME calculating throttle change rate
if (!instantThrottle)
throttleResponseRate = (float)(10d / Math.Sqrt(Math.Sqrt(part.mass * maxThrust)));
else
throttleResponseRate = 1000000f;
// set fields
Fields["thrustCurveDisplay"].guiActive = useThrustCurve;
CreateEngine();
if (ullageSet == null)
ullageSet = new Ullage.UllageSet(this);
// Get thrust axis (only on create prefabs)
if (part.partInfo == null || part.partInfo.partPrefab == null)
{
thrustAxis = Vector3.zero;
foreach(Transform t in part.FindModelTransforms(thrustVectorTransformName))
{
thrustAxis -= t.forward;
}
thrustAxis = thrustAxis.normalized;
}
ullageSet.SetThrustAxis(thrustAxis);
// ullage
if (node.HasNode("Ullage"))
{
ullageSet.Load(node.GetNode("Ullage"));
}
ullageSet.SetUllageEnabled(ullage);
// load ignition resources
if (node.HasNode("IGNITOR_RESOURCE"))
ignitionResources.Clear();
foreach (ConfigNode n in node.GetNodes("IGNITOR_RESOURCE"))
{
ModuleResource res = new ModuleResource();
res.Load(n);
ignitionResources.Add(res);
}
}
示例9: ConfigNode
//.........这里部分代码省略.........
else if (fi.FieldType == typeof(float))
{
float val;
if (modNode.HasValue(name))
if (float.TryParse(modNode.GetValue(name), out val))
fi.SetValue(m, val);
}
else if (fi.FieldType == typeof(double))
{
double val;
if (modNode.HasValue(name))
if (double.TryParse(modNode.GetValue(name), out val))
fi.SetValue(m, val);
}
else if (fi.FieldType == typeof(MapSO))
{
if (modNode.HasValue(name))
{
MapSO map = fi.GetValue(m) as MapSO;
if (map.Depth == MapSO.MapDepth.Greyscale)
{
Configuration.MapSOParser_GreyScale<MapSO> newMap = new Configuration.MapSOParser_GreyScale<MapSO>();
newMap.SetFromString(modNode.GetValue(name));
if (newMap.value != null)
fi.SetValue(m, newMap.value);
}
else
{
Configuration.MapSOParser_RGB<MapSO> newMap = new Configuration.MapSOParser_RGB<MapSO>();
newMap.SetFromString(modNode.GetValue(name));
if (newMap.value != null)
fi.SetValue(m, newMap.value);
}
}
}
else if (fi.FieldType == typeof(AnimationCurve))
{
if (modNode.HasNode(name))
{
FloatCurve fc = new FloatCurve();
fc.Load(modNode.GetNode(name));
fi.SetValue(m, fc.Curve);
}
}
else if (fi.FieldType == typeof(FloatCurve))
{
if (modNode.HasNode(name))
{
FloatCurve fc = new FloatCurve();
fc.Load(modNode.GetNode(name));
fi.SetValue(m, fc);
}
}
else if (fi.FieldType == typeof(Texture2D))
{
if (modNode.HasValue(name))
{
Configuration.Texture2DParser newParser = new Configuration.Texture2DParser();
newParser.SetFromString(name);
if (newParser.value != null)
fi.SetValue(m, newParser.value);
else
{
Texture2D newTex = Utility.LoadTexture(name, true, false, false);
if (newTex != null)
fi.SetValue(m, newParser.value);
}
}
}
else if (fi.FieldType == typeof(PQSLandControl.LandClass))
{
if(modNode.HasNode(name))
{
PQSLandControl.LandClass lc = fi.GetValue(m) as PQSLandControl.LandClass;
ParseObject(lc, modNode.GetNode(name));
}
}
else if (fi.FieldType == typeof(PQSMod_CelestialBodyTransform.AltitudeFade))
{
if (modNode.HasNode(name))
{
PQSMod_CelestialBodyTransform.AltitudeFade af = fi.GetValue(m) as PQSMod_CelestialBodyTransform.AltitudeFade;
ParseObject(af, modNode.GetNode(name));
}
}
else if (fi.FieldType == typeof(PQSMod_CelestialBodyTransform.AltitudeFade[]))
{
if (modNode.HasNode(name))
{
PQSMod_CelestialBodyTransform.AltitudeFade[] secFades = fi.GetValue(m) as PQSMod_CelestialBodyTransform.AltitudeFade[];
ConfigNode newNodes = new ConfigNode();
modNode.GetNode(name).CopyTo(newNodes);
foreach (PQSMod_CelestialBodyTransform.AltitudeFade af in secFades)
{
ParseObject(af, newNodes.nodes[0]);
newNodes.nodes.Remove(newNodes.nodes[0]);
}
}
}
}
示例10: Mod
public static FloatCurve Mod(FloatCurve fc, float sMult, float vMult)
{
//print("Modding this");
ConfigNode curve = new ConfigNode("atmosphereCurve");
fc.Save(curve);
foreach (ConfigNode.Value k in curve.values)
{
string[] val = k.value.Split(' ');
//print("Got string !" + k.value + ", split into " + val.Count() + " elements");
float atmo = float.Parse(val[0]);
float isp = float.Parse(val[1]);
isp = isp * ((sMult * atmo) + (vMult * (1f - atmo))); // lerp between vac and SL
val[1] = Math.Round(isp,1).ToString(); // round for neatness
string newVal = "";
foreach (string s in val)
newVal += s + " ";
k.value = newVal;
}
FloatCurve retCurve = new FloatCurve();
retCurve.Load(curve);
return retCurve;
}
示例11: SetConfiguration
//.........这里部分代码省略.........
if (v == null) //just in case...
continue;
try
{
part.stackIcon.RemoveInfo(v);
}
catch (Exception e)
{
print("*MFS* Trying to remove info box: " + e.Message);
}
}
boxes.Clear();
}
}
}
if (type.Equals("ModuleRCS") || type.Equals("ModuleRCSFX"))
{
ModuleRCS rcs = (ModuleRCS)pModule;
if (rcs != null)
{
rcs.G = 9.80665f;
/*bool oldRes = config.HasValue("resourceName");
string resource = "";
if (oldRes)
{
resource = config.GetValue("resourceName");
rcs.resourceName = resource;
}*/
DoConfig(config);
if (config.HasNode("PROPELLANT"))
{
rcs.propellants.Clear();
}
pModule.Load(config);
/*if (oldRes)
{
rcs.resourceName = resource;
rcs.SetResource(resource);
}*/
// PROPELLANT handling is automatic.
fastRCS = rcs;
if(type.Equals("ModuleRCS") && !part.Modules.Contains("ModuleRCSFX"))
fastType = ModuleType.MODULERCS;
else
fastType = ModuleType.MODULERCSFX;
}
}
else
{ // is an ENGINE
if (type.Equals("ModuleEngines"))
{
ModuleEngines mE = (ModuleEngines)pModule;
if (mE != null)
{
configMaxThrust = mE.maxThrust;
configMinThrust = mE.minThrust;
fastEngines = mE;
fastType = ModuleType.MODULEENGINES;
mE.g = 9.80665f;
if (config.HasNode("PROPELLANT"))
{
mE.propellants.Clear();
}
}
if (config.HasValue("maxThrust"))
{
示例12: DoConfig
virtual public void DoConfig(ConfigNode cfg)
{
// fix propellant ratios to not be rounded
if (cfg.HasNode("PROPELLANT"))
{
foreach (ConfigNode pNode in cfg.GetNodes("PROPELLANT"))
{
if (pNode.HasValue("ratio"))
{
double dtmp;
if (double.TryParse(pNode.GetValue("ratio"), out dtmp))
pNode.SetValue("ratio", (dtmp * 100.0).ToString());
}
}
}
float heat = -1;
if (cfg.HasValue("heatProduction")) // ohai amsi: allow heat production to be changed by multiplier
{
heat = (float)Math.Round(float.Parse(cfg.GetValue("heatProduction")) * heatMult, 0);
cfg.SetValue("heatProduction", heat.ToString());
}
// load throttle (for later)
curThrottle = throttle;
if (cfg.HasValue("throttle"))
float.TryParse(cfg.GetValue("throttle"), out curThrottle);
else if(cfg.HasValue("minThrust") && cfg.HasValue("maxThrust"))
curThrottle = float.Parse(cfg.GetValue("minThrust")) / float.Parse(cfg.GetValue("maxThrust"));
float TLMassMult = 1.0f;
if (techLevel != -1)
{
// load techlevels
TechLevel cTL = new TechLevel();
//print("For engine " + part.name + ", config " + configuration + ", max TL: " + TechLevel.MaxTL(cfg, techNodes, engineType));
cTL.Load(cfg, techNodes, engineType, techLevel);
TechLevel oTL = new TechLevel();
oTL.Load(cfg, techNodes, engineType, origTechLevel);
// set atmosphereCurve
if (cfg.HasValue("IspSL") && cfg.HasValue("IspV"))
{
cfg.RemoveNode("atmosphereCurve");
ConfigNode curve = new ConfigNode("atmosphereCurve");
float ispSL, ispV;
float.TryParse(cfg.GetValue("IspSL"), out ispSL);
float.TryParse(cfg.GetValue("IspV"), out ispV);
FloatCurve aC = new FloatCurve();
aC = Mod(cTL.atmosphereCurve, ispSL, ispV);
aC.Save(curve);
cfg.AddNode(curve);
}
// set heatProduction and dissipation
if (heat > 0)
{
cfg.SetValue("heatProduction", MassTL(heat).ToString("0"));
part.heatDissipation = 0.12f / MassTL(1.0f);
}
// set thrust and throttle
if (cfg.HasValue(thrustRating))
{
float thr;
float.TryParse(cfg.GetValue(thrustRating), out thr);
configMaxThrust = ThrustTL(thr);
cfg.SetValue(thrustRating, configMaxThrust.ToString("0.0000"));
if (cfg.HasValue("minThrust"))
{
float.TryParse(cfg.GetValue("minThrust"), out thr);
configMinThrust = ThrustTL(thr);
cfg.SetValue("minThrust", configMinThrust.ToString("0.0000"));
}
else
{
if (thrustRating.Equals("thrusterPower"))
{
configMinThrust = configMaxThrust * 0.5f;
}
else
{
configMinThrust = configMaxThrust;
if (curThrottle > 1.0f)
{
if (techLevel >= curThrottle)
curThrottle = 1.0f;
else
curThrottle = -1.0f;
}
if (curThrottle >= 0.0f)
{
curThrottle = (float)((double)curThrottle * cTL.Throttle());
configMinThrust *= curThrottle;
}
cfg.SetValue("minThrust", configMinThrust.ToString("0.0000"));
}
}
curThrottle = configMinThrust / configMaxThrust;
if(origMass > 0)
TLMassMult = MassTL(1.0f);
//.........这里部分代码省略.........
示例13: GetInfo
public override string GetInfo ()
{
if (configs.Count < 2)
return TLTInfo();
string info = TLTInfo() + "\nAlternate configurations:\n";
TechLevel moduleTLInfo = new TechLevel();
if (techNodes != null)
moduleTLInfo.Load(techNodes, techLevel);
else
moduleTLInfo = null;
foreach (ConfigNode config in configs) {
if(!config.GetValue ("name").Equals (configuration)) {
info += " " + config.GetValue ("name") + "\n";
if(config.HasValue (thrustRating))
info += " (" + ThrustTL(config.GetValue (thrustRating), config).ToString("0.00") + " Thrust";
else
info += " (Unknown Thrust";
FloatCurve isp = new FloatCurve();
if(config.HasNode ("atmosphereCurve")) {
isp.Load (config.GetNode ("atmosphereCurve"));
info += ", "
+ isp.Evaluate (isp.maxTime).ToString() + "-"
+ isp.Evaluate (isp.minTime).ToString() + "Isp";
}
else if (config.HasValue("IspSL") && config.HasValue("IspV"))
{
float ispSL = 1.0f, ispV = 1.0f;
float.TryParse(config.GetValue("IspSL"), out ispSL);
float.TryParse(config.GetValue("IspV"), out ispV);
TechLevel cTL = new TechLevel();
if (cTL.Load(config, techNodes, engineType, techLevel))
{
ispSL *= ispSLMult * cTL.atmosphereCurve.Evaluate(1);
ispV *= ispVMult * cTL.atmosphereCurve.Evaluate(0);
info += ", " + ispSL.ToString("0") + "-" + ispV.ToString("0") + "Isp";
}
}
info += ")\n";
}
}
return info;
}
示例14: DoConfig
public virtual void DoConfig(ConfigNode cfg)
{
// fix propellant ratios to not be rounded
if (cfg.HasNode("PROPELLANT"))
{
foreach (ConfigNode pNode in cfg.GetNodes("PROPELLANT"))
{
if (pNode.HasValue("ratio"))
{
double dtmp;
if (double.TryParse(pNode.GetValue("ratio"), out dtmp))
pNode.SetValue("ratio", (dtmp * 100.0).ToString());
}
}
}
float heat = -1;
if (cfg.HasValue("heatProduction")) // ohai amsi: allow heat production to be changed by multiplier
{
heat = (float)Math.Round(float.Parse(cfg.GetValue("heatProduction")) * heatMult, 0);
cfg.SetValue("heatProduction", heat.ToString());
}
// load throttle (for later)
curThrottle = throttle;
if (cfg.HasValue("throttle"))
float.TryParse(cfg.GetValue("throttle"), out curThrottle);
else if(cfg.HasValue("minThrust") && cfg.HasValue("maxThrust"))
curThrottle = float.Parse(cfg.GetValue("minThrust")) / float.Parse(cfg.GetValue("maxThrust"));
float TLMassMult = 1.0f;
float gimbal = -1f;
if (cfg.HasValue("gimbalRange"))
gimbal = float.Parse(cfg.GetValue("gimbalRange"));
float cost = 0f;
if(cfg.HasValue("cost"))
cost = float.Parse(cfg.GetValue("cost"));
if (techLevel != -1)
{
// load techlevels
TechLevel cTL = new TechLevel();
//print("For engine " + part.name + ", config " + configuration + ", max TL: " + TechLevel.MaxTL(cfg, techNodes, engineType));
cTL.Load(cfg, techNodes, engineType, techLevel);
TechLevel oTL = new TechLevel();
oTL.Load(cfg, techNodes, engineType, origTechLevel);
// set atmosphereCurve
if (cfg.HasValue("IspSL") && cfg.HasValue("IspV"))
{
cfg.RemoveNode("atmosphereCurve");
ConfigNode curve = new ConfigNode("atmosphereCurve");
float ispSL, ispV;
float.TryParse(cfg.GetValue("IspSL"), out ispSL);
float.TryParse(cfg.GetValue("IspV"), out ispV);
FloatCurve aC = new FloatCurve();
aC = Mod(cTL.AtmosphereCurve, ispSL, ispV);
aC.Save(curve);
cfg.AddNode(curve);
}
// set heatProduction and dissipation
if (heat > 0)
{
cfg.SetValue("heatProduction", MassTL(heat).ToString("0"));
part.heatDissipation = 0.12f / MassTL(1.0f);
}
// set thrust and throttle
if (cfg.HasValue(thrustRating))
{
float thr;
float.TryParse(cfg.GetValue(thrustRating), out thr);
configMaxThrust = ThrustTL(thr);
cfg.SetValue(thrustRating, configMaxThrust.ToString("0.0000"));
if (cfg.HasValue("minThrust"))
{
float.TryParse(cfg.GetValue("minThrust"), out thr);
configMinThrust = ThrustTL(thr);
cfg.SetValue("minThrust", configMinThrust.ToString("0.0000"));
}
else
{
if (thrustRating.Equals("thrusterPower"))
{
configMinThrust = configMaxThrust * 0.5f;
}
else
{
configMinThrust = configMaxThrust;
if (curThrottle > 1.0f)
{
if (techLevel >= curThrottle)
curThrottle = 1.0f;
else
curThrottle = -1.0f;
}
if (curThrottle >= 0.0f)
{
curThrottle = (float)((double)curThrottle * cTL.Throttle());
//.........这里部分代码省略.........
示例15: GetConfigInfo
public string GetConfigInfo(ConfigNode config)
{
TechLevel cTL = new TechLevel();
if (!cTL.Load(config, techNodes, engineType, techLevel))
cTL = null;
string info = " " + config.GetValue("name") + "\n";
if (config.HasValue("description"))
info += " " + config.GetValue("description") + "\n";
if (config.HasValue(thrustRating))
{
info += " " + (scale * ThrustTL(config.GetValue(thrustRating), config)).ToString("G3") + " kN";
// add throttling info if present
if (config.HasValue("minThrust"))
info += ", min " + (float.Parse(config.GetValue("minThrust")) / float.Parse(config.GetValue(thrustRating)) * 100f).ToString("N0") + "%";
else if (config.HasValue("throttle"))
info += ", min " + (float.Parse(config.GetValue("throttle")) * 100f).ToString("N0") + "%";
}
else
info += " Unknown Thrust";
if (origMass > 0f)
{
float cMass = scale;
float ftmp;
if (config.HasValue("massMult"))
if (float.TryParse(config.GetValue("massMult"), out ftmp))
cMass *= ftmp;
cMass = origMass * cMass * RFSettings.Instance.EngineMassMultiplier;
info += ", " + cMass.ToString("N3") + "t";
}
info += "\n";
FloatCurve isp = new FloatCurve();
if (config.HasNode("atmosphereCurve"))
{
isp.Load(config.GetNode("atmosphereCurve"));
info += " Isp: "
+ isp.Evaluate(isp.maxTime).ToString() + " - "
+ isp.Evaluate(isp.minTime).ToString() + "s\n";
}
else if (config.HasValue("IspSL") && config.HasValue("IspV"))
{
float ispSL = 1.0f, ispV = 1.0f;
float.TryParse(config.GetValue("IspSL"), out ispSL);
float.TryParse(config.GetValue("IspV"), out ispV);
if (cTL != null)
{
ispSL *= ispSLMult * cTL.AtmosphereCurve.Evaluate(1);
ispV *= ispVMult * cTL.AtmosphereCurve.Evaluate(0);
info += " Isp: " + ispSL.ToString("0") + " - " + ispV.ToString("0") + "s\n";
}
}
float gimbalR = -1f;
if (config.HasValue("gimbalRange"))
gimbalR = float.Parse(config.GetValue("gimbalRange"));
// Don't do per-TL checks here, they're misleading.
/*else if (!gimbalTransform.Equals("") || useGimbalAnyway)
{
if (cTL != null)
gimbalR = cTL.GimbalRange;
}*/
if (gimbalR != -1f)
info += " Gimbal " + gimbalR.ToString("N1") + "d\n";
if (config.HasValue("ullage") || config.HasValue("ignitions") || config.HasValue("pressureFed"))
{
info += " ";
bool comma = false;
if (config.HasValue("ullage"))
{
info += (config.GetValue("ullage").ToLower() == "true" ? "ullage" : "no ullage");
comma = true;
}
if (config.HasValue("pressureFed") && config.GetValue("pressureFed").ToLower() == "true")
{
if (comma)
info += ", ";
info += "pfed";
comma = true;
}
if (config.HasValue("ignitions"))
{
int ignitions;
if (int.TryParse(config.GetValue("ignitions"), out ignitions))
{
if (comma)
info += ", ";
if (ignitions > 0)
info += ignitions + " ignition" + (ignitions > 1 ? "s" : "");
else
info += "unl. ignitions";
}
}
info += "\n";
}
float cst;
//.........这里部分代码省略.........