public bool FixGame(string module) { if (!Features.Deploy) { PartModule thisModule = Lib.FindModule(part, module); if (thisModule != null) { GetIsActive(); part.RemoveModule(thisModule); } return(true); } return(false); }
public static void update(Vessel v, vessel_info vi, vessel_data vd, vessel_resources resources, double elapsed_s) { // get most used resource handlers resource_info ec = resources.Info(v, "ElectricCharge"); // for each part foreach (ProtoPartSnapshot p in v.protoVessel.protoPartSnapshots) { // a part can contain multiple resource converters int converter_index = 0; // get part prefab (required for module properties) Part part_prefab = PartLoader.getPartInfoByName(p.partName).partPrefab; // for each module foreach (ProtoPartModuleSnapshot m in p.modules) { // get the module prefab PartModule module_prefab = Lib.FindModule(part_prefab, m.moduleName); // if the prefab doesn't contain this module, skip it if (!module_prefab) { continue; } // process modules switch (m.moduleName) { case "Reliability": Reliability.BackgroundUpdate(v, m, module_prefab as Reliability, elapsed_s); break; case "Scrubber": Scrubber.BackgroundUpdate(v, m, module_prefab as Scrubber, vi, resources, elapsed_s); break; case "Recycler": Recycler.BackgroundUpdate(v, m, module_prefab as Recycler, resources, elapsed_s); break; case "Greenhouse": Greenhouse.BackgroundUpdate(v, p, m, module_prefab as Greenhouse, vi, resources, elapsed_s); break; case "GravityRing": GravityRing.BackgroundUpdate(v, p, m, module_prefab as GravityRing, resources, elapsed_s); break; case "Emitter": Emitter.BackgroundUpdate(v, p, m, module_prefab as Emitter, ec, elapsed_s); break; case "ModuleCommand": ProcessCommand(v, p, m, module_prefab as ModuleCommand, resources, elapsed_s); break; case "ModuleDeployableSolarPanel": ProcessPanel(v, p, m, module_prefab as ModuleDeployableSolarPanel, vi, ec, elapsed_s); break; case "ModuleGenerator": ProcessGenerator(v, p, m, module_prefab as ModuleGenerator, resources, elapsed_s); break; case "ModuleResourceConverter": case "ModuleKPBSConverter": case "FissionReactor": ProcessConverter(v, p, m, part_prefab, converter_index++, resources, elapsed_s); break; case "ModuleResourceHarvester": ProcessHarvester(v, p, m, module_prefab as ModuleResourceHarvester, resources, elapsed_s); break; case "ModuleAsteroidDrill": ProcessAsteroidDrill(v, p, m, module_prefab as ModuleAsteroidDrill, resources, elapsed_s); break; case "ModuleScienceConverter": ProcessLab(v, p, m, module_prefab as ModuleScienceConverter, ec, elapsed_s); break; case "ModuleLight": case "ModuleColoredLensLight": case "ModuleMultiPointSurfaceLight": ProcessLight(v, p, m, module_prefab as ModuleLight, ec, elapsed_s); break; case "SCANsat": case "ModuleSCANresourceScanner": ProcessScanner(v, p, m, module_prefab, part_prefab, vd, ec, elapsed_s); break; case "ModuleCurvedSolarPanel": ProcessCurvedPanel(v, p, m, module_prefab, part_prefab, vi, ec, elapsed_s); break; case "FissionGenerator": ProcessFissionGenerator(v, p, m, module_prefab, ec, elapsed_s); break; case "ModuleRadioisotopeGenerator": ProcessRadioisotopeGenerator(v, p, m, module_prefab, ec, elapsed_s); break; case "ModuleCryoTank": ProcessCryoTank(v, p, m, module_prefab, resources, elapsed_s); break; } } } }
void boot_devices(Vessel v) { // store stuff string filename; Device device; // index counters int scrubber_i = 0; int recycler_i = 0; int greenhouse_i = 0; int ring_i = 0; int emitter_i = 0; int light_i = 0; int panel_i = 0; int generator_i = 0; int converter_i = 0; int drill_i = 0; // loaded vessel if (v.loaded) { foreach(PartModule m in v.FindPartModulesImplementing<PartModule>()) { switch(m.moduleName) { case "Scrubber": filename = Lib.BuildString("scrubber/", scrubber_i++.ToString()); device = new ScrubberDevice(m as Scrubber); break; case "Recycler": filename = Lib.BuildString("recycler/", recycler_i++.ToString()); device = new RecyclerDevice(m as Recycler); break; case "Greenhouse": filename = Lib.BuildString("greenhouse/", greenhouse_i++.ToString()); device = new GreenhouseDevice(m as Greenhouse); break; case "GravityRing": filename = Lib.BuildString("ring/", ring_i++.ToString()); device = new RingDevice(m as GravityRing); break; case "Emitter": if ((m as Emitter).ec_rate <= double.Epsilon) continue; //< skip non-tweakable emitters filename = Lib.BuildString("emitter/", emitter_i++.ToString()); device = new EmitterDevice(m as Emitter); break; case "ModuleDeployableSolarPanel": filename = Lib.BuildString("panel/", panel_i++.ToString()); device = new PanelDevice(m as ModuleDeployableSolarPanel); break; case "ModuleGenerator": filename = Lib.BuildString("generator/", generator_i++.ToString()); device = new GeneratorDevice(m as ModuleGenerator); break; case "ModuleResourceConverter": case "ModuleKPBSConverter": case "FissionReactor": filename = Lib.BuildString("converter/", converter_i++.ToString()); device = new ConverterDevice(m as ModuleResourceConverter); break; case "ModuleResourceHarvester": filename = Lib.BuildString("drill/", drill_i++.ToString()); device = new DrillDevice(m as ModuleResourceHarvester); break; case "ModuleLight": case "ModuleColoredLensLight": case "ModuleMultiPointSurfaceLight": filename = Lib.BuildString("light/", light_i++.ToString()); device = new LightDevice(m as ModuleLight); break; default: continue; } // add device file files.Add(filename, new File(device)); } } // unloaded vessel else { foreach(ProtoPartSnapshot p in v.protoVessel.protoPartSnapshots) { // a part can contain multiple resource converters int converter_index = 0; // get part prefab Part part_prefab = PartLoader.getPartInfoByName(p.partName).partPrefab; // for each modules foreach(ProtoPartModuleSnapshot m in p.modules) { // get the module prefab, skip if prefab doesn't contain the module PartModule module_prefab = Lib.FindModule(part_prefab, m.moduleName); if (!module_prefab) continue; // depending on module name switch(m.moduleName) { case "Scrubber": filename = Lib.BuildString("scrubber/", scrubber_i++.ToString()); device = new ProtoScrubberDevice(m); break; case "Recycler": filename = Lib.BuildString("recycler/", recycler_i++.ToString()); device = new ProtoRecyclerDevice(m); break; case "Greenhouse": filename = Lib.BuildString("greenhouse/", greenhouse_i++.ToString()); device = new ProtoGreenhouseDevice(m); break; case "GravityRing": filename = Lib.BuildString("ring/", ring_i++.ToString()); device = new ProtoRingDevice(m); break; case "Emitter": if ((module_prefab as Emitter).ec_rate <= double.Epsilon) continue; //< skip non-tweakable emitters filename = Lib.BuildString("emitter/", emitter_i++.ToString()); device = new ProtoEmitterDevice(m); break; case "ModuleDeployableSolarPanel": filename = Lib.BuildString("panel/", panel_i++.ToString()); device = new ProtoPanelDevice(m, module_prefab as ModuleDeployableSolarPanel); break; case "ModuleGenerator": filename = Lib.BuildString("generator/", generator_i++.ToString()); device = new ProtoGeneratorDevice(m, module_prefab as ModuleGenerator); break; case "ModuleResourceConverter": case "ModuleKPBSConverter": case "FissionReactor": var converter_prefabs = part_prefab.Modules.GetModules<ModuleResourceConverter>(); if (converter_index >= converter_prefabs.Count) continue; module_prefab = converter_prefabs[converter_index++]; filename = Lib.BuildString("converter/", converter_i++.ToString()); device = new ProtoConverterDevice(m, module_prefab as ModuleResourceConverter); break; case "ModuleResourceHarvester": ProtoPartModuleSnapshot deploy = p.modules.Find(k => k.moduleName == "ModuleAnimationGroup"); filename = Lib.BuildString("drill/", drill_i++.ToString()); device = new ProtoDrillDevice(m, module_prefab as ModuleResourceHarvester, deploy); break; case "ModuleLight": case "ModuleColoredLensLight": case "ModuleMultiPointSurfaceLight": filename = Lib.BuildString("light/", light_i++.ToString()); device = new ProtoLightDevice(m); break; default: continue; } // add device file files.Add(filename, new File(device)); } } } }