public mode(ConfigNode cn, Part p) { maxec = 10; foreach (ConfigNode.Value cnv in cn.values ?? new ConfigNode.ValueList()) { switch (cnv.name) { case "MaxEC": { maxec = float.Parse(cnv.value); break; } } } ConfigNode.ValueList vl = cn.GetNode("FUELS").values; // No null coalescing intentional here fuels = new fuel[vl.Count]; for (byte n = 0; n < vl.Count; n++) { fuels[n] = new fuel(vl[n]); } vl = (cn.GetNode("BYPRODUCTS") ?? new ConfigNode()).values; bypr = new fuel[vl.Count]; for (byte n = 0; n < vl.Count; n++) { bypr[n] = new fuel(vl[n], true); } tanks = (cn.GetNode("TANKS") ?? new ConfigNode()).values; vl = (cn.GetNode("EMITTERS") ?? new ConfigNode()).values; emttrs = new emttr[vl.Count]; for (byte n = 0; n < vl.Count; n++) { emttrs[n] = new emttr(vl[n]); } foreach (ConfigNode.Value cnv in (cn.GetNode("EMITSCALE") ?? new ConfigNode()).values) { Array.Find(emttrs, x => x.name == cnv.name).scale = float.Parse(cnv.value); } vl = (cn.GetNode("LIGHTS") ?? new ConfigNode()).values; lights = new light[vl.Count]; for (byte n = 0; n < vl.Count; n++) { lights[n] = new light(vl[n], p); } }
private void uds(states newstate, Double gen, Double max) { if (gen != lgen || max != lmax) { lgen = gen; lmax = max; ecs_t = gen.ToString(FTFMT) + " / " + max.ToString(FTFMT); } if (state != newstate) { state = newstate; switch (state) { case states.fuelDepr: { state_t = "Fuel Deprived"; break; } case states.noDeman: { state_t = "No Demand"; break; } case states.nominal: { state_t = "Nominal"; break; } case states.deploy: { state_t = "Deploying"; amfd(-1); break; } case states.retract: { state_t = "Retracting"; amfd(1); break; } case states.off: { state_t = "Off"; break; } #if DEBUG default: { state_t = "ERROR!"; break; } #endif } } Double tf = gen / max * ratelmt; if (tf != ltf || fm != lfm) { ltf = tf; lfm = fm; foreach (light l in c.ms[fm].lights) { foreach (Light lim in part.FindModelComponents <Light>(l.name) ?? new List <Light>()) { lim.intensity = Convert.ToSingle(l.mmag * tf); } } tf *= c.em; int min = (state == states.nominal ? 1 : 0); foreach (KSPParticleEmitter kpe in part.FindModelComponents <KSPParticleEmitter>()) { emttr e = Array.Find(c.ms[fm].emttrs, x => x.name == kpe.name); kpe.minEmission = kpe.maxEmission = Math.Max((int)(tf * (e == default(emttr) ? 1 : e.scale)), min); } } }