def generate_eve_compatibility_config(scale, compatibility_path): config_path = os.path.join(compatibility_path, eve_compatibility_config_name) cloud_layer_pack_module = Module("@CLOUD_LAYER_PACK") kerbin_cloud_layer = Module("@CLOUD_LAYER:HAS[@DEFAULTS:HAS[#body[Kerbin]]]") kerbin_defaults = Module("@DEFAULTS") kerbin_main_texture = Module("@main_texture") kerbin_main_texture_speed = Module("@speed") kerbin_main_texture_speed.add_parameter("@x /= %s" % format_float(5 * scale)) kerbin_main_texture.add_child(kerbin_main_texture_speed) kerbin_defaults.add_child(kerbin_main_texture) kerbin_detail_texture = Module("@detail_texture") kerbin_detail_texture_speed = Module("@speed") kerbin_detail_texture_speed.add_parameter("@x /= %s" % format_float(5 * scale)) kerbin_detail_texture.add_child(kerbin_detail_texture_speed) kerbin_defaults.add_child(kerbin_detail_texture) kerbin_cloud_layer.add_child(kerbin_defaults) cloud_layer_pack_module.add_child(kerbin_cloud_layer) laythe_cloud_layer = Module("@CLOUD_LAYER:HAS[@DEFAULTS:HAS[#body[Laythe]]]") laythe_defaults = Module("@DEFAULTS") laythe_main_texture = Module("@main_texture") laythe_main_texture_speed = Module("@speed") laythe_main_texture_speed.add_parameter("@x /= %s" % format_float(scale)) laythe_main_texture.add_child(laythe_main_texture_speed) laythe_defaults.add_child(laythe_main_texture) laythe_detail_texture = Module("@detail_texture") laythe_detail_texture_speed = Module("@speed") laythe_detail_texture_speed.add_parameter("@x /= %s" % format_float(scale)) laythe_detail_texture.add_child(laythe_detail_texture_speed) laythe_defaults.add_child(laythe_detail_texture) laythe_cloud_layer.add_child(laythe_defaults) cloud_layer_pack_module.add_child(laythe_cloud_layer) cloud_layer_pack_module.write_to_file(config_path)
def generate_kopernicus_config(scale, mod_path): config_path = os.path.join(mod_path, kopernicus_config_name) this_bodies = copy.deepcopy(bodies) if scale == "generic": generate_generic_config(config_path) return main_module = Module("@Kopernicus:AFTER[Kopernicus]") for body in this_bodies: if scale != 1: body.rescale(scale) if body.name != "Eeloo": body_module = Module("@Body[%s]" % body.name) else: body_module = Module("@Body[%s]:NEEDS[!OPM]" % body.name) if scale != 1: body_module.add_parameter( "%%cacheFile = %s/Cache/Stock/%s.bin" % (mod_name_format % format_float(scale), body.name) ) orbit_module = Module("@Orbit") if isinstance(body, PlanetaryBody): body.rotate_orbit(x_rot=axial_tilt) orbit_module = Module("@Orbit") if scale != 1: orbit_module.add_parameter("semiMajorAxis = %d" % round(body.a)) if not body.no_rotate: orbit_module.add_parameter("inclination = %s" % format_float(body.i)) orbit_module.add_parameter("longitudeOfAscendingNode = %s" % format_float(body.o)) orbit_module.add_parameter("argumentOfPeriapsis = %s" % format_float(body.w)) if not orbit_module.is_empty: body_module.add_child(orbit_module) properties_module = Module("@Properties") if scale != 1 and not body.is_potato: properties_module.add_parameter("radius = %d" % round(body.r)) if not body.is_tidally_locked: if body.name == "Kerbin": rot_speed = round(body.rot / 7200.0) * 7200 else: rot_speed = body.rot properties_module.add_parameter("rotationPeriod = %s" % format_float(rot_speed)) if body.gee_ASL is not None: properties_module.add_parameter("geeASL = %s" % format_float(body.gee_ASL)) if scale != 1 and not body.is_potato: science_module = Module("@ScienceValues") if body.high_space_alt is not None: science_module.add_parameter("spaceAltitudeThreshold = %s" % format_float(body.high_space_alt)) if body.is_gas_giant and body.high_flying_alt is not None: science_module.add_parameter("flyingAltitudeThreshold = %s" % format_float(body.high_flying_alt)) properties_module.add_child(science_module) if not properties_module.is_empty: body_module.add_child(properties_module) if body.name == "Kerbin": body_module.add_child(generate_space_center_module(scale)) if not body_module.is_empty: main_module.add_child(body_module) main_module.write_to_file(config_path)
def generate_space_center_module(scale): ksc_module = Module("SpaceCenter") ksc_module.add_parameter("latitude = 28.608389") ksc_module.add_parameter("longitude = -19.7") ksc_module.add_parameter("lodvisibleRangeMult = 6") ksc_module.add_parameter("repositionRadiusOffset = 53") ksc_module.add_parameter("reorientFinalAngle = 289.75") ksc_module.add_parameter("decalLatitude = 28.608389") ksc_module.add_parameter("decalLongitude = -19.7") ksc_module.add_parameter("heightMapDeformity = 80") ksc_module.add_parameter("absoluteOffset = 0") ksc_module.add_parameter("absolute = true") ksc_module.add_parameter("radius = 10000") return ksc_module
def generate_opm_compatibility_config(scale, compatibility_path): config_path = os.path.join(compatibility_path, opm_compatibility_config_name) this_bodies = copy.deepcopy(opm_bodies) main_module = Module("@Kopernicus:AFTER[OPM]") for body in this_bodies: if scale != 1: body.rescale(scale) body_module = Module("@Body[%s]" % body.name) if scale != 1: body_module.add_parameter( "%%cacheFile = %s/Cache/OPM/%s.bin" % (mod_name_format % format_float(scale), body.name) ) orbit_module = Module("@Orbit") if isinstance(body, PlanetaryBody): body.rotate_orbit(x_rot=axial_tilt) if scale != 1: orbit_module.add_parameter("%%semiMajorAxis = %d" % round(body.a)) if not body.no_rotate: orbit_module.add_parameter("%%inclination = %s" % format_float(body.i)) orbit_module.add_parameter("%%longitudeOfAscendingNode = %s" % format_float(body.o)) orbit_module.add_parameter("%%argumentOfPeriapsis = %s" % format_float(body.w)) if not orbit_module.is_empty: body_module.add_child(orbit_module) properties_module = Module("@Properties") if scale != 1 and not body.is_potato: properties_module.add_parameter("-mass = dummy") properties_module.add_parameter("%%radius = %d" % round(body.r)) if not body.is_tidally_locked: properties_module.add_parameter("%%rotationPeriod = %s" % format_float(body.rot)) if body.gee_ASL is not None: properties_module.add_parameter("%%geeASL = %s" % format_float(body.gee_ASL)) if scale != 1 and not body.is_potato: science_module = Module("@ScienceValues") if body.high_space_alt is None: science_module.add_parameter("@spaceAltitudeThreshold *= %s" % format_float(scale)) else: science_module.add_parameter("%%spaceAltitudeThreshold = %s" % format_float(body.high_space_alt)) if body.is_gas_giant: if body.high_flying_alt is None: science_module.add_parameter("@flyingAltitudeThreshold *= %s" % format_float(scale)) else: science_module.add_parameter("%%flyingAltitudeThreshold = %s" % format_float(body.high_flying_alt)) properties_module.add_child(science_module) if not properties_module.is_empty: body_module.add_child(properties_module) if not body_module.is_empty: main_module.add_child(body_module) main_module.write_to_file(config_path)
def generate_generic_config(config_path): this_bodies = copy.deepcopy(bodies) main_module = Module("@Kopernicus:FINAL") for body in this_bodies: body_module = Module("@Body[%s]" % body.name) orbit_module = Module("@Orbit") if isinstance(body, PlanetaryBody): body.rotate_orbit(x_rot=axial_tilt) orbit_module = Module("@Orbit") if not body.no_rotate: orbit_module.add_parameter("%%inclination = %s" % format_float(body.i)) orbit_module.add_parameter("%%longitudeOfAscendingNode = %s" % format_float(body.o)) orbit_module.add_parameter("%%argumentOfPeriapsis = %s" % format_float(body.w)) if not orbit_module.is_empty: body_module.add_child(orbit_module) properties_module = Module("@Properties") if body.gee_ASL is not None: properties_module.add_parameter("-mass = dummy") properties_module.add_parameter("geeASL = %s" % format_float(body.gee_ASL)) if not properties_module.is_empty: body_module.add_child(properties_module) if not body_module.is_empty: main_module.add_child(body_module) main_module.write_to_file(config_path)
def generate_kopernicus_config(scale, mod_path): config_path = os.path.join(mod_path, kopernicus_config_name) this_bodies = copy.deepcopy(bodies) if scale == 'generic': generate_generic_config(config_path) return main_module = Module("@Kopernicus:AFTER[Kopernicus]") for body in this_bodies: if scale != 1: body.rescale(scale) if body.name != "Eeloo": body_module = Module("@Body[%s]" % body.name) else: body_module = Module("@Body[%s]:NEEDS[!OPM]" % body.name) if scale != 1: body_module.add_parameter("%%cacheFile = %s/Cache/Stock/%s.bin" % (mod_name_format % format_float(scale), body.name)) orbit_module = Module("@Orbit") if isinstance(body, PlanetaryBody): body.rotate_orbit(x_rot=axial_tilt) orbit_module = Module("@Orbit") if scale != 1: orbit_module.add_parameter("semiMajorAxis = %d" % round(body.a)) if not body.no_rotate: orbit_module.add_parameter("inclination = %s" % format_float(body.i)) orbit_module.add_parameter("longitudeOfAscendingNode = %s" % format_float(body.o)) orbit_module.add_parameter("argumentOfPeriapsis = %s" % format_float(body.w)) if not orbit_module.is_empty: body_module.add_child(orbit_module) properties_module = Module("@Properties") if scale != 1 and not body.is_potato: properties_module.add_parameter("radius = %d" % round(body.r)) if not body.is_tidally_locked: if body.name == "Kerbin": rot_speed = round(body.rot / 7200.0) * 7200 else: rot_speed = body.rot properties_module.add_parameter("rotationPeriod = %s" % format_float(rot_speed)) if body.gee_ASL is not None: properties_module.add_parameter("geeASL = %s" % format_float(body.gee_ASL)) if scale != 1 and not body.is_potato: science_module = Module("@ScienceValues") if body.high_space_alt is not None: science_module.add_parameter("spaceAltitudeThreshold = %s" % format_float(body.high_space_alt)) if body.is_gas_giant and body.high_flying_alt is not None: science_module.add_parameter("flyingAltitudeThreshold = %s" % format_float(body.high_flying_alt)) properties_module.add_child(science_module) if not properties_module.is_empty: body_module.add_child(properties_module) if body.name == "Kerbin": body_module.add_child(generate_space_center_module(scale)) if not body_module.is_empty: main_module.add_child(body_module) main_module.write_to_file(config_path)
def generate_opm_compatibility_config(scale, compatibility_path): config_path = os.path.join(compatibility_path, opm_compatibility_config_name) this_bodies = copy.deepcopy(opm_bodies) main_module = Module("@Kopernicus:AFTER[OPM]") for body in this_bodies: if scale != 1: body.rescale(scale) body_module = Module("@Body[%s]" % body.name) if scale != 1: body_module.add_parameter("%%cacheFile = %s/Cache/OPM/%s.bin" % (mod_name_format % format_float(scale), body.name)) orbit_module = Module("@Orbit") if isinstance(body, PlanetaryBody): body.rotate_orbit(x_rot=axial_tilt) if scale != 1: orbit_module.add_parameter("%%semiMajorAxis = %d" % round(body.a)) if not body.no_rotate: orbit_module.add_parameter("%%inclination = %s" % format_float(body.i)) orbit_module.add_parameter("%%longitudeOfAscendingNode = %s" % format_float(body.o)) orbit_module.add_parameter("%%argumentOfPeriapsis = %s" % format_float(body.w)) if not orbit_module.is_empty: body_module.add_child(orbit_module) properties_module = Module("@Properties") if scale != 1 and not body.is_potato: properties_module.add_parameter("-mass = dummy") properties_module.add_parameter("%%radius = %d" % round(body.r)) if not body.is_tidally_locked: properties_module.add_parameter("%%rotationPeriod = %s" % format_float(body.rot)) if body.gee_ASL is not None: properties_module.add_parameter("%%geeASL = %s" % format_float(body.gee_ASL)) if scale != 1 and not body.is_potato: science_module = Module("@ScienceValues") if body.high_space_alt is None: science_module.add_parameter("@spaceAltitudeThreshold *= %s" % format_float(scale)) else: science_module.add_parameter("%%spaceAltitudeThreshold = %s" % format_float(body.high_space_alt)) if body.is_gas_giant: if body.high_flying_alt is None: science_module.add_parameter("@flyingAltitudeThreshold *= %s" % format_float(scale)) else: science_module.add_parameter("%%flyingAltitudeThreshold = %s" % format_float(body.high_flying_alt)) properties_module.add_child(science_module) if not properties_module.is_empty: body_module.add_child(properties_module) if not body_module.is_empty: main_module.add_child(body_module) main_module.write_to_file(config_path)