本文整理汇总了C#中FloatCurve.Save方法的典型用法代码示例。如果您正苦于以下问题:C# FloatCurve.Save方法的具体用法?C# FloatCurve.Save怎么用?C# FloatCurve.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatCurve
的用法示例。
在下文中一共展示了FloatCurve.Save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoConfig
public virtual void DoConfig(ConfigNode cfg)
{
configMaxThrust = configMinThrust = configHeat = -1f;
// Get thrusts
if (config.HasValue(thrustRating))
{
float thr;
if (float.TryParse(config.GetValue(thrustRating), out thr))
configMaxThrust = scale * thr;
}
if (config.HasValue("minThrust"))
{
float thr;
if (float.TryParse(config.GetValue("minThrust"), out thr))
configMinThrust = scale * thr;
}
// Get, multiply heat
if (cfg.HasValue("heatProduction"))
{
float heat;
if(float.TryParse(cfg.GetValue("heatProduction"), out heat))
configHeat = (float)Math.Round(heat * RFSettings.Instance.heatMultiplier, 0);
}
// load throttle (for later)
configThrottle = throttle;
if (cfg.HasValue("throttle"))
float.TryParse(cfg.GetValue("throttle"), out configThrottle);
else if (configMinThrust >= 0f && configMaxThrust >= 0f)
configThrottle = configMinThrust / configMaxThrust;
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 = scale * float.Parse(cfg.GetValue("cost"));
if (techLevel != -1)
{
// load techlevels
TechLevel cTL = new TechLevel();
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");
// get the multipliers
float ispSL = 1f, ispV = 1f;
float.TryParse(cfg.GetValue("IspSL"), out ispSL);
float.TryParse(cfg.GetValue("IspV"), out ispV);
// Mod the curve by the multipliers
FloatCurve newAtmoCurve = new FloatCurve();
newAtmoCurve = Utilities.Mod(cTL.AtmosphereCurve, ispSL, ispV);
newAtmoCurve.Save(curve);
cfg.AddNode(curve);
}
// set heatProduction
if (configHeat > 0)
{
configHeat = MassTL(configHeat);
}
// set thrust and throttle
if (configMaxThrust >= 0)
{
configMaxThrust = ThrustTL(configMaxThrust);
if (configMinThrust >= 0)
{
configMinThrust = ThrustTL(configMinThrust);
}
else if (thrustRating.Equals("thrusterPower"))
{
configMinThrust = configMaxThrust * 0.5f;
}
else
{
configMinThrust = configMaxThrust;
if (configThrottle > 1.0f)
{
if (techLevel >= configThrottle)
configThrottle = 1.0f;
else
configThrottle = -1.0f;
}
if (configThrottle >= 0.0f)
{
//.........这里部分代码省略.........
示例2: ModifyCurveKeys
public static FloatCurve ModifyCurveKeys(FloatCurve initialCurve, float vacMult, float atmMult, bool extendToZero)
{
ConfigNode tempNode = new ConfigNode();
initialCurve.Save(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;
}
示例3: GetKeysFromFloatCurve
public List<float> GetKeysFromFloatCurve(FloatCurve curve)
{
try
{
ConfigNode myConfigNode = new ConfigNode("CurveNode");
curve.Save(myConfigNode);
Debug.Log("Curve data acquired.");
List<float> result = new List<float>(myConfigNode.values.Count * 2);
for (int i = 0; i < myConfigNode.values.Count; ++i)
{
string keyValue = myConfigNode.values[i].value;
Debug.Log(keyValue);
string[] keyValueParts = keyValue.Split(' ');
result.Add(Convert.ToSingle(keyValueParts[0]));
result.Add(Convert.ToSingle(keyValueParts[1]));
}
return result;
}
catch (Exception e)
{
Debug.Log(e.Message);
return null;
}
}
示例4: ReadCurve
// Readers
List<double[]> ReadCurve(FloatCurve curve)
{
ConfigNode config = new ConfigNode();
List<double[]> list = new List<double[]>();
NumericCollectionParser<double> value = new NumericCollectionParser<double>();
curve.Save(config);
foreach (string k in config.GetValues("key"))
{
value.SetFromString(k);
list.Add(value.value.ToArray());
}
return list;
}
示例5: PrintCurve
void PrintCurve(FloatCurve curve, string name)
{
ConfigNode config = new ConfigNode();
curve.Save(config);
Debug.Log(name);
foreach (string key in config.GetValues("key"))
{
Debug.Log("key = " + key);
}
}
示例6: 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;
}
示例7: 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);
//.........这里部分代码省略.........
示例8: 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());
//.........这里部分代码省略.........