public override void Export(Asset asset, string path) { Model model = asset as Model; if (model.SupportingDocuments.ContainsKey("SystemsDamage")) { ((SystemsDamage)model.SupportingDocuments["SystemsDamage"]).Save(path); } else { SystemsDamageSystemUnit unit; SystemsDamage systemsDamage = new SystemsDamage(); unit = new SystemsDamageSystemUnit { UnitType = "bodywork" }; unit.Settings = new SystemsDamageUnitCode(); unit.Settings.SetParametersForMethod("CrushablePart", "Part", model.Root.Name, "A", 1.0f, "B", 0.15f); unit.Settings.SetParametersForMethod("WastedLinearContribution", "A", 1.0f, "B", 0.5f, "C", 0.5f); systemsDamage.Units.Add(unit); unit = new SystemsDamageSystemUnit { UnitType = "fl_wheel" }; unit.Settings = new SystemsDamageUnitCode(); unit.Settings.SetParametersForMethod("ComplicatedWheel", "Wheel", "Wheel_FL", "A", 1.0f); unit.Settings.SetParametersForMethod("SolidPart", "Part", "Wheel_FL", "A", 0.25f, "B", 1.0f); unit.Settings.SetParameterForMethod("WastedContribution", "Factor", 0.08f); unit.Settings.SetParameterForMethod("DamageEffect_Brakes", "Factor", 0.5f); systemsDamage.Units.Add(unit); unit = new SystemsDamageSystemUnit { UnitType = "fr_wheel" }; unit.Settings = new SystemsDamageUnitCode(); unit.Settings.SetParametersForMethod("ComplicatedWheel", "Wheel", "Wheel_FR", "A", 1.0f); unit.Settings.SetParametersForMethod("SolidPart", "Part", "Wheel_FR", "A", 0.25f, "B", 1.0f); unit.Settings.SetParameterForMethod("WastedContribution", "Factor", 0.08f); unit.Settings.SetParameterForMethod("DamageEffect_Brakes", "Factor", 0.5f); systemsDamage.Units.Add(unit); unit = new SystemsDamageSystemUnit { UnitType = "rl_wheel" }; unit.Settings = new SystemsDamageUnitCode(); unit.Settings.SetParametersForMethod("ComplicatedWheel", "Wheel", "Wheel_RL", "A", 1.0f); unit.Settings.SetParametersForMethod("SolidPart", "Part", "Wheel_RL", "A", 0.25f, "B", 1.0f); unit.Settings.SetParameterForMethod("WastedContribution", "Factor", 0.08f); systemsDamage.Units.Add(unit); unit = new SystemsDamageSystemUnit { UnitType = "rr_wheel" }; unit.Settings = new SystemsDamageUnitCode(); unit.Settings.SetParametersForMethod("ComplicatedWheel", "Wheel", "Wheel_RR", "A", 1.0f); unit.Settings.SetParametersForMethod("SolidPart", "Part", "Wheel_RR", "A", 0.25f, "B", 1.0f); unit.Settings.SetParameterForMethod("WastedContribution", "Factor", 0.08f); systemsDamage.Units.Add(unit); systemsDamage.Save(path); } }
public static void OpenVehicle(string path) { SceneManager.Current.SetCoordinateSystem(CoordinateSystem.LeftHanded); SceneManager.Current.Reset(); string assetFolder = Path.GetDirectoryName(path); Model vehicle = (Model)SceneManager.Current.Add(SceneManager.Current.Content.Load <Model, CNTImporter>(Path.GetFileName(path), assetFolder)); // Load supporting documents if (File.Exists(Path.Combine(assetFolder, "setup.lol"))) { vehicle.SupportingDocuments["Setup"] = Setup.Load(Path.Combine(assetFolder, "setup.lol")); } if (File.Exists(Path.Combine(assetFolder, "Structure.xml"))) { List <string> findMaterials(StructurePart part) { List <string> materials = new List <string>(); materials.AddRange(part.DamageSettings.Methods.Where(m => m.Name == "CrushDamageMaterial" && m.HasBeenSet).Select(m => m.Parameters[2].Value.ToString())); foreach (StructurePart child in part.Parts) { materials.AddRange(findMaterials(child)); } return(materials); } Structure structure = Structure.Load(Path.Combine(assetFolder, "Structure.xml")); foreach (string material in findMaterials(structure.Root)) { SceneManager.Current.Content.Load <Material, MT2Importer>(material, assetFolder, true); } vehicle.SupportingDocuments["Structure"] = structure; } if (File.Exists(Path.Combine(assetFolder, "SystemsDamage.xml"))) { vehicle.SupportingDocuments["SystemsDamage"] = SystemsDamage.Load(Path.Combine(assetFolder, "SystemsDamage.xml")); } if (File.Exists(Path.Combine(assetFolder, "vehicle_setup.cfg"))) { vehicle.SupportingDocuments["VehicleSetupConfig"] = VehicleSetupConfig.Load(Path.Combine(assetFolder, "vehicle_setup.cfg")); foreach (VehicleMaterialMap materialMap in vehicle.GetSupportingDocument <VehicleSetupConfig>("VehicleSetupConfig").MaterialMaps) { foreach (KeyValuePair <string, string> kvp in materialMap.Substitutions) { SceneManager.Current.Content.Load <Material, MT2Importer>(kvp.Value, assetFolder, true); } } } if (File.Exists(Path.Combine(assetFolder, "vehicle_setup.lol"))) { vehicle.SupportingDocuments["VehicleSetup"] = VehicleSetup.Load(Path.Combine(assetFolder, "vehicle_setup.lol")); } if (File.Exists(Path.Combine(assetFolder, "vfx_anchors.lol"))) { vehicle.SupportingDocuments["VFXAnchors"] = VFXAnchors.Load(Path.Combine(assetFolder, "vfx_anchors.lol")); } if (File.Exists(Path.Combine(assetFolder, "collision.cnt"))) { vehicle.SupportingDocuments["Collision"] = SceneManager.Current.Content.Load <Model, CNTImporter>("collision.cnt", assetFolder); } if (File.Exists(Path.Combine(assetFolder, "opponent_collision.cnt"))) { vehicle.SupportingDocuments["OpponentCollision"] = SceneManager.Current.Content.Load <Model, CNTImporter>("opponent_collision.cnt", assetFolder); } //if (File.Exists(assetFolder + "CrashSoundsConfig_Car.xml")) { vehicle.SupportingDocuments["SystemsDamage"] = SystemsDamage.Load(assetFolder + "SystemsDamage.xml"); } foreach (ModelBone bone in vehicle.Bones) { string boneName = bone.Name.ToLower(); // Name = bone.Name if (boneName.StartsWith("wheel_")) { Core.Entities.Wheel wheel = new Core.Entities.Wheel(); wheel.LinkWith(bone); SceneManager.Current.Entities.Add(wheel); } else if (boneName.StartsWith("vfx_")) { VFX vfx = new VFX(); vfx.LinkWith(bone); SceneManager.Current.Entities.Add(vfx); } else if (boneName.StartsWith("driver")) { Driver driver = new Driver(); driver.LinkWith(bone); SceneManager.Current.Entities.Add(driver); } } SceneManager.Current.SetContext("Carmageddon Max Damage", ContextMode.Car); }