public static void UpdateMaterials( FrameContainer frames, int[] colors, float[] lights, MaterialPropertyBlock materialPropertyBlock) { var indices = CarColors.FromIndices(colors); Color32 headLightColor = new Color32(255, 255, 255, 255); Color32 tailLightColor = new Color32(255, 255, 255, 255); // compute car colors Color32[] carColors = new [] { new Color32(255, 255, 255, 255), indices[0], indices[1], indices[2], indices[3], headLightColor, headLightColor, tailLightColor, tailLightColor, }; // compute car emissions float[] carEmissions = new[] { 0f, 0f, 0f, 0f, 0f, Mathf.Exp(lights[0] * 2) - 1, Mathf.Exp(lights[1] * 2) - 1, Mathf.Exp(lights[2] * 2) - 1, Mathf.Exp(lights[3] * 2) - 1, }; foreach (var frame in frames) { var mr = frame.GetComponent <MeshRenderer>(); if (mr == null) { continue; } // get color index from each material, and assign properties accordingly var materials = mr.sharedMaterials; for (int i = 0; i < materials.Length; i++) { int carColorIndex = materials[i].GetInt(Importing.Conversion.Geometry.CarColorIndexId); materialPropertyBlock.SetColor(CarColorPropertyId, carColors[carColorIndex]); materialPropertyBlock.SetFloat(CarEmissionPropertyId, carEmissions[carColorIndex]); mr.SetPropertyBlock(materialPropertyBlock, i); } } }
void LateUpdate() { car_colors = G.Sys.ProfileManager_.CurrentProfile_.CarColors_; if (customize_menu != null && (customize_menu.editColorsPanel_.IsTop_ || customize_menu.colorPickerPanel_.IsTop_ || customize_menu.colorPresetPanel_.IsTop_)) { car_colors = customize_menu.colorPickerPanel_.IsTop_ ? customize_menu.pickerCarColor_.Colors_ : customize_menu.CurrentCarColor_.Colors_; } if (scene_name != "MainMenu" && car_logic != null) { car_colors = car_logic.PlayerData_.originalColors_.Colors_; } color = car_colors.glow_; color.a = 255; lamp_light_material.SetColor("_EmitColor", color); lamp_light.color = color; color = car_colors.primary_; color.a = 255; lamp_panel_material.SetColor("_Color", color); lamp_panel_material.SetColor("_SpecColor", color); //lamp.transform.position = transform.position; //lamp.transform.rotation = transform.rotation; }
static void LoadCarColors(Section settings, ref CarColors colors) { try { LoadColor(settings.GetItem <Section>("primary"), ref colors.primary_); } catch { } try { LoadColor(settings.GetItem <Section>("secondary"), ref colors.secondary_); } catch { } try { LoadColor(settings.GetItem <Section>("glow"), ref colors.glow_); } catch { } try { LoadColor(settings.GetItem <Section>("sparkle"), ref colors.sparkle_); } catch { } }
public Automobile(string make, string model, int year, CarColors carColor) { Make = make; Model = model; Year = year; CarColor = carColor; }
static void Sample(string[] args) { //pass by value double x = 1, y = 2; swapValues(x, y); Console.WriteLine("From main \n x : {0}, y : {1}", x, y); //using the out parameter double squared; SquareIt(15, out squared); Console.WriteLine("{0}^2 = {1}", 15, squared); //pass by reference swapReferences(ref x, ref y); Console.WriteLine("From main \n x : {0}, y : {1}", x, y); //params Console.WriteLine("Sum of: 1,2,3,4,5 is : {0}", getSum(1, 2, 3, 4, 5)); //different way of passing parameters in functions //without maintaining the hierarchy PrintInfo(city: "Wales", name: "Bruno"); //method overloading Console.WriteLine("Sum of: 1,2,3 is : {0}", getSum("1", "2", "3")); //enum CarColors cc = CarColors.Yellow; Console.WriteLine("The car was painted in {0} with the color code of {1}", cc, (int)cc); }
public void LoadAll() { ProfileManager profileManager = G.Sys.ProfileManager_; List <Profile> allProfiles = profileManager.profiles_; foreach (Profile currentProfile in allProfiles) { CarColors[] carColors = new CarColors[Mod.TotalCarCount]; for (int carIndex = 0; carIndex < profileManager.CarInfos_.Length; carIndex++) { if (carIndex < Mod.DefaultCarCount) { carColors[carIndex] = currentProfile.carColorsList_[carIndex]; continue; } CarInfo carInfo = profileManager.CarInfos_[carIndex]; CarColors colors = GetCarColors(currentProfile.FileName_, carInfo.name_); carColors[carIndex] = colors; } currentProfile.carColorsList_ = carColors; } }
public Car(string mrk, string mld, CarColors clr, DateTime dt, double prc) { Color = clr; Mark = mrk; Model = mld; Date = dt; Price = prc; }
public Car InitCar() { string model, mark; double price; CarColors colors = 0; string color; DateTime date; Console.WriteLine("Enter the car mark: "); mark = Console.ReadLine(); Console.WriteLine("Enter the car model: "); model = Console.ReadLine(); Console.WriteLine("Enter the car price: "); price = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Enter the date of issue"); date = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine("Enter the car color: "); color = Console.ReadLine(); for (int i = 0; i < color.Length; i++) { if ((int)color[i] >= 41) { Convert.ToChar((int)color[i] - 32); } } switch (color) { case "red": colors = CarColors.Red; break; case "orange": colors = CarColors.Orange; break; case "yellow": colors = CarColors.Yellow; break; case "green": colors = CarColors.Green; break; case "ligthblue": colors = CarColors.Ligth_Blue; break; case "blue": colors = CarColors.Blue; break; case "purple": colors = CarColors.Purple; break; } return(new Car(mark, model, colors, date, price)); }
internal static void Postfix(Profile __instance) { CarColors[] carColors = new CarColors[G.Sys.ProfileManager_.carInfos_.Length]; for (int colorIndex = 0; colorIndex < carColors.Length; colorIndex++) { carColors[colorIndex] = G.Sys.ProfileManager_.carInfos_[colorIndex].colors_; } __instance.carColorsList_ = carColors; }
public void createCars(CarInfos infos) { m_infos = infos; var cars = loadAssetsBundle(); List <CreateCarReturnInfos> carsInfos = new List <CreateCarReturnInfos>(); foreach (var car in cars) { carsInfos.Add(createCar(car)); } var profileManager = G.Sys.ProfileManager_; var oldCars = profileManager.carInfos_.ToArray(); profileManager.carInfos_ = new CarInfo[oldCars.Length + cars.Count]; var unlocked = (Dictionary <string, int>)profileManager.GetType().GetField("unlockedCars_", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(profileManager); for (int i = 0; i < profileManager.carInfos_.Length; i++) { if (i < oldCars.Length) { profileManager.carInfos_[i] = oldCars[i]; continue; } int index = i - oldCars.Length; var car = new CarInfo(); car.name_ = carsInfos[index].car.name; car.prefabs_ = new CarPrefabs(); car.prefabs_.carPrefab_ = carsInfos[index].car; car.colors_ = carsInfos[index].colors; profileManager.carInfos_[i] = car; unlocked.Add(car.name_, i); } var carColors = new CarColors[oldCars.Length + cars.Count]; for (int i = 0; i < carColors.Length; i++) { carColors[i] = G.Sys.ProfileManager_.carInfos_[i].colors_; } for (int i = 0; i < profileManager.ProfileCount_; i++) { Profile p = profileManager.GetProfile(i); var field = p.GetType().GetField("carColorsList_", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(p, carColors); } }
void getBaseCar() { var prefab = G.Sys.ProfileManager_.carInfos_[0].prefabs_.carPrefab_; if (prefab == null) { ErrorList.add("Can't find the refractor base car prefab"); return; } baseCar = prefab; defaultColors = G.Sys.ProfileManager_.carInfos_[0].colors_; }
private void GetBaseCar() { var prefab = G.Sys.ProfileManager_.carInfos_[0].prefabs_.carPrefab_; if (prefab == null) { Mod.Instance.Errors.Add("Can't find the refractor base car prefab"); return; } baseCar = prefab; defaultColors = G.Sys.ProfileManager_.carInfos_[0].colors_; }
//constructor public MSSACar(CarColors color, int year, CarMake make, int mpg, double fuelLevel, bool IsFirstOwner, string Model) { Color = color; _year = year; Make = make; this.TotalMiles = 0; this.MPG = mpg; this.FuelLevel = fuelLevel; this.IsFirstOwner = IsFirstOwner; this.Model = Model; //counter++; //VIN = counter; }
static void Postfix(Profile __instance) { var carColors = new CarColors[G.Sys.ProfileManager_.carInfos_.Length]; for (int i = 0; i < carColors.Length; i++) { carColors[i] = G.Sys.ProfileManager_.carInfos_[i].colors_; } var field = __instance.GetType().GetField("carColorsList_", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, carColors); }
internal static bool Prefix(Profile __instance, CarColors cc) { CarColors[] carColors = new CarColors[G.Sys.ProfileManager_.carInfos_.Length]; for (int i = 0; i < carColors.Length; i++) { carColors[i] = cc; } __instance.carColorsList_ = carColors; __instance.dataModified_ = true; return(false); }
protected CarColors GetCarColors(string profileName, string vehicleName) { Section vehicle = Vehicle(profileName, vehicleName); CarColors colors = new CarColors { primary_ = GetColor(vehicle, "primary", Colors.whiteSmoke), secondary_ = GetColor(vehicle, "secondary", Colors.darkGray), glow_ = GetColor(vehicle, "glow", Colors.cyan), sparkle_ = GetColor(vehicle, "sparkle", Colors.lightSlateGray) }; SetCarColors(profileName, vehicleName, colors); return(colors); }
protected void SetCarColors(string profileName, string vehicleName, CarColors colors) { Section vehicle = Vehicle(profileName, vehicleName); vehicle["primary"] = ToSection(colors.primary_); vehicle["secondary"] = ToSection(colors.secondary_); vehicle["glow"] = ToSection(colors.glow_); vehicle["sparkle"] = ToSection(colors.sparkle_); Section profile = Profile(profileName); profile[vehicleName] = vehicle; Config[profileName] = profile; }
public void LateUpdate() { lamp_?.SetActive(Mod.Instance.Config.Enabled); if (!Mod.Instance.Config.Enabled) { return; } carColors_ = G.Sys.ProfileManager_.CurrentProfile_.CarColors_; // If color picker is open take input as colors, otherwise select profile car colors if (customizeColorsMenu_ && (customizeColorsMenu_.editColorsPanel_.IsTop_ || customizeColorsMenu_.colorPickerPanel_.IsTop_ || customizeColorsMenu_.colorPresetPanel_.IsTop_)) { carColors_ = customizeColorsMenu_.colorPickerPanel_.IsTop_ ? customizeColorsMenu_.pickerCarColor_.Colors_ : customizeColorsMenu_.CurrentCarColor_.Colors_; } else if (!string.Equals(sceneName_, "MainMenu", StringComparison.InvariantCultureIgnoreCase) && carLogic_) { carColors_ = carLogic_.PlayerData_.originalColors_.Colors_; } Color color = Color.white; color = carColors_.glow_; color.a = 255; materialLampLight_.SetColor("_Color", color); materialLampLight_.SetColor("_Emit", color); materialLampPanel_.SetColor("_EmitColor", color); light_.color = color; if (flare_) { flare_.lensFlare_.color = color; } foreach (LensFlare flare in flares_) { flare.color = color; } color = carColors_.primary_; color.a = 255; materialLampPanel_.SetColor("_Color", color); materialLampPanel_.SetColor("_SpecColor", color); }
static bool Prefix(Profile __instance, CarColors cc) { var carColors = new CarColors[G.Sys.ProfileManager_.carInfos_.Length]; for (int i = 0; i < carColors.Length; i++) { carColors[i] = cc; } var field = __instance.GetType().GetField("carColorsList_", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, carColors); field = __instance.GetType().GetField("dataModified_", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(__instance, true); return(false); }
// Equivalent of Spectrum's Initialize call (which happens after GameManager initialization) public void LateInitialize(IManager _) { ProfileManager profileManager = G.Sys.ProfileManager_; DefaultCarCount = profileManager.CarInfos_.Length; CarInfos carInfos = new CarInfos(); carInfos.CollectInfos(); CarBuilder carBuilder = new CarBuilder(); carBuilder.CreateCars(carInfos); TotalCarCount = profileManager.CarInfos_.Length; CarColors.LoadAll(); Errors.Show(); }
public static void SetColors(FrameContainer frames, int[] colors) { var props = new MaterialPropertyBlock(); var indices = CarColors.FromIndices(colors); int[] vehicleColorIds = Vehicle.CarColorIds; for (int i = 0; i < vehicleColorIds.Length; ++i) { props.SetColor(vehicleColorIds[i], indices[i]); } foreach (var mr in frames.Select(f => f.GetComponent <MeshRenderer>()).Where(mr => mr != null)) { mr.SetPropertyBlock(props); } }
public static void LoadAll() { var profileManager = G.Sys.ProfileManager_; if (profileManager == null) { return; } var settings = new Settings("CustomCars"); var profiles = profileManager.GetType().GetField("profiles_", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(profileManager) as List <Profile>; foreach (var profile in profiles) { var colors = profile.GetType().GetField("carColorsList_", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(profile) as CarColors[]; int carInfosLength = G.Sys.ProfileManager_.carInfos_.Length; if (carInfosLength > colors.Length) { var colors2 = new CarColors[carInfosLength]; for (int i = 0; i < colors.Length; i++) { colors2[i] = colors[i]; } colors = colors2; } Section[] sProfile = null; try { sProfile = settings.GetItem <Section[]>(profile.Name_); } catch { } if (sProfile == null) { continue; } for (int i = 0; i < sProfile.Length; i++) { LoadCarColors(sProfile[i], ref colors[i + CustomCarsPatchInfos.baseCarCount]); } profile.GetType().GetField("carColorsList_", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(profile, colors); } }
static void SaveCarsColors(Section settings, CarColors colors) { var sPrimary = new Section(); SaveColor(sPrimary, colors.primary_); var sSecondary = new Section(); SaveColor(sSecondary, colors.secondary_); var sGlow = new Section(); SaveColor(sGlow, colors.glow_); var sSparkle = new Section(); SaveColor(sSparkle, colors.sparkle_); settings["primary"] = sPrimary; settings["secondary"] = sSecondary; settings["glow"] = sGlow; settings["sparkle"] = sSparkle; }
private void UpdateColors() { _colorsChanged = false; var indices = CarColors.FromIndices(_colors); for (var i = 0; i < 4; ++i) { _props.SetColor(CarColorIds[i], indices[i]); } _props.SetVector(LightsId, new Vector4(_lights[0], _lights[1], _lights[2], _lights[3])); foreach (var frame in _frames) { var mr = frame.GetComponent <MeshRenderer>(); if (mr == null) { continue; } mr.SetPropertyBlock(_props); } }
public void SaveAll() { ProfileManager profileManager = G.Sys.ProfileManager_; List <Profile> allProfiles = profileManager.profiles_; foreach (Profile currentProfile in allProfiles) { for (int carIndex = 0; carIndex < profileManager.CarInfos_.Length; carIndex++) { if (carIndex < Mod.DefaultCarCount) { continue; } CarInfo carInfo = profileManager.CarInfos_[carIndex]; CarColors colors = currentProfile.carColorsList_[carIndex]; SetCarColors(currentProfile.FileName_, carInfo.name_, colors); } } Save(); }
private void Awake() { if (HasLoaded) { return; } var archivePaths = Config.GetPaths("archive_paths"); IArchive[] archives; using (Utilities.Profiler.Start("Archive load time")) { archives = archivePaths.Select(x => File.Exists(x) ? (IArchive)ArchiveManager.LoadImageArchive(x) : Directory.Exists(x) ? ArchiveManager.LoadLooseArchive(x) : null).Where(x => x != null).ToArray(); } using (Utilities.Profiler.Start("Collision load time")) { foreach (var archive in archives) { foreach (var colFile in archive.GetFileNamesWithExtension(".col")) { CollisionFile.Load(colFile); } } } using (Utilities.Profiler.Start("Item info load time")) { foreach (var path in Config.GetPaths("item_paths")) { var ext = Path.GetExtension(path).ToLower(); switch (ext) { case ".dat": Item.ReadLoadList(path); break; case ".ide": Item.ReadIde(path); break; case ".ipl": Item.ReadIpl(path); break; } } } using (Utilities.Profiler.Start("Handling info load time")) { Handling.Load(Config.GetPath("handling_path")); } using (Utilities.Profiler.Start("Animation group info load time")) { foreach (var path in Config.GetPaths("anim_groups_paths")) { AnimationGroup.Load(path); } } using (Utilities.Profiler.Start("Car color info load time")) { CarColors.Load(Config.GetPath("car_colors_path")); } HasLoaded = true; }
private static void StepLoadCarColors() { CarColors.Load(ArchiveManager.PathToCaseSensitivePath(Config.GetPath("car_colors_path"))); }
private void Initialize(VehicleDef def, int[] colors = null) { Definition = def; if (colors != null && colors[0] != -1) { SetColors(colors); } else { var defaultClrs = CarColors.GetCarDefaults(Definition.ModelName); if (defaultClrs != null) { SetColors(defaultClrs[UnityEngine.Random.Range(0, defaultClrs.Count)]); } else { Debug.LogWarningFormat("No colours defined for {0}!", def.GameName); } } name = Definition.GameName; _geometryParts = LoadGeometryParts(Definition); _frames = _geometryParts.AttachFrames(transform, MaterialFlags.Vehicle); var wheelFrame = _frames.FirstOrDefault(x => x.Name == "wheel"); if (wheelFrame == null) { Debug.LogWarningFormat("No wheels defined for {0}!", def.GameName); Destroy(gameObject); return; } var engineFrame = _frames.FirstOrDefault(x => x.Name == "engine"); if (engineFrame != null) { this.EngineTransform = engineFrame.transform; } var petrolcapFrame = _frames.FirstOrDefault(x => x.Name == "petrolcap"); if (petrolcapFrame != null) { this.PetrolcapTransform = petrolcapFrame.transform; } foreach (var frame in _frames) { if (!frame.Name.StartsWith("wheel_")) { continue; } if (!frame.Name.EndsWith("_dummy")) { continue; } var childFrames = _frames.Where(x => x.ParentIndex == frame.Index); // disable all children of wheel dummies foreach (var childFrame in childFrames) { childFrame.gameObject.SetActive(false); } var wheelAlignment = GetWheelAlignment(frame.Name); Wheel inst; // see if this wheel dummy has a wheel child var wheel = childFrames.FirstOrDefault(x => x.Name == "wheel"); if (wheel == null) { var copy = Instantiate(wheelFrame.transform); copy.SetParent(frame.transform, false); _wheels.Add(inst = new Wheel { Alignment = wheelAlignment, Parent = frame.transform, Child = copy, }); } else { // all children of wheel dummies get set to inactive so activate this one wheel.gameObject.SetActive(true); _wheels.Add(inst = new Wheel { Alignment = wheelAlignment, Parent = frame.transform, Child = wheel.transform, }); } if (inst.IsLeftHand) { frame.transform.Rotate(Vector3.up, 180.0f); } inst.Complement = _wheels.FirstOrDefault(x => (x.Alignment & WheelAlignment.LeftRightMask) != (inst.Alignment & WheelAlignment.LeftRightMask) && (x.Alignment & WheelAlignment.FrontMidRearMask) == (inst.Alignment & WheelAlignment.FrontMidRearMask)); if (inst.Complement != null) { inst.Complement.Complement = inst; } } InitializePhysics(); this.Health = this.MaxHealth = Mathf.Pow(this.HandlingData.Mass, VehicleManager.Instance.massToHealthExponent); //this.SetupDoorsHingeJoints(); var frontSeat = GetPart("ped_frontseat"); var backSeat = GetPart("ped_backseat"); if (frontSeat != null) { var frontSeatMirror = new GameObject("ped_frontseat").transform; frontSeatMirror.SetParent(frontSeat.parent, false); frontSeatMirror.localPosition = Vector3.Scale(frontSeat.localPosition, new Vector3(-1f, 1f, 1f)); if (frontSeat.localPosition.x > 0f) { AttachSeat(frontSeat, SeatAlignment.FrontRight); AttachSeat(frontSeatMirror, SeatAlignment.FrontLeft); } else { AttachSeat(frontSeatMirror, SeatAlignment.FrontRight); AttachSeat(frontSeat, SeatAlignment.FrontLeft); } DriverTransform = GetSeat(SeatAlignment.FrontLeft).Parent; } if (backSeat != null) { var backSeatMirror = new GameObject("ped_backseat").transform; backSeatMirror.SetParent(backSeat.parent, false); backSeatMirror.localPosition = Vector3.Scale(backSeat.localPosition, new Vector3(-1f, 1f, 1f)); if (backSeat.localPosition.x > 0f) { AttachSeat(backSeat, SeatAlignment.BackRight); AttachSeat(backSeatMirror, SeatAlignment.BackLeft); } else { AttachSeat(backSeatMirror, SeatAlignment.BackRight); AttachSeat(backSeat, SeatAlignment.BackLeft); } } // Add vehicle damage /* * var dam = gameObject.AddComponent<VehicleDamage>(); * dam.damageParts = new Transform[] { transform.GetChild(0).Find("engine") }; * dam.deformMeshes = gameObject.GetComponentsInChildren<MeshFilter>(); * dam.displaceParts = gameObject.GetComponentsInChildren<Transform>().Where(x => x.GetComponent<Frame>() != null || x.GetComponent<FrameContainer>() != null).ToArray(); * dam.damageFactor = VehicleAPI.constDamageFactor; * dam.collisionIgnoreHeight = -.4f; * dam.collisionTimeGap = .1f; * * //OptimizeVehicle(); * * dam.deformColliders = gameObject.GetComponentsInChildren<MeshCollider>(); */ gameObject.SetLayerRecursive(Layer); SetupHighDetailMesh(); }
private static void StepLoadCarColors() { CarColors.Load(Config.GetPath("car_colors_path")); }
private void Initialize(VehicleDef def, int[] colors = null) { Definition = def; if (colors != null && colors[0] != -1) { SetColors(colors); } else { var defaultClrs = CarColors.GetCarDefaults(Definition.ModelName); if (defaultClrs != null) { SetColors(defaultClrs[UnityEngine.Random.Range(0, defaultClrs.Count)]); } else { Debug.LogWarningFormat("No colours defined for {0}!", def.GameName); } } name = Definition.GameName; _geometryParts = Geometry.Load(Definition.ModelName, TextureDictionary.Load(Definition.TextureDictionaryName), TextureDictionary.Load("vehicle"), TextureDictionary.Load("misc")); _frames = _geometryParts.AttachFrames(transform, MaterialFlags.Vehicle); var wheelFrame = _frames.FirstOrDefault(x => x.Name == "wheel"); if (wheelFrame == null) { Debug.LogWarningFormat("No wheels defined for {0}!", def.GameName); Destroy(gameObject); return; } foreach (var frame in _frames) { if (!frame.Name.StartsWith("wheel_")) { continue; } if (!frame.Name.EndsWith("_dummy")) { continue; } var childFrames = _frames.Where(x => x.ParentIndex == frame.Index); // disable all children of wheel dummies foreach (var childFrame in childFrames) { childFrame.gameObject.SetActive(false); } var wheelAlignment = GetWheelAlignment(frame.Name); Wheel inst; // see if this wheel dummy has a wheel child var wheel = childFrames.FirstOrDefault(x => x.Name == "wheel"); if (wheel == null) { var copy = Instantiate(wheelFrame.transform); copy.SetParent(frame.transform, false); _wheels.Add(inst = new Wheel { Alignment = wheelAlignment, Parent = frame.transform, Child = copy, }); } else { // all children of wheel dummies get set to inactive so activate this one wheel.gameObject.SetActive(true); _wheels.Add(inst = new Wheel { Alignment = wheelAlignment, Parent = frame.transform, Child = wheel.transform, }); } if (inst.IsLeftHand) { frame.transform.Rotate(Vector3.up, 180.0f); } inst.Complement = _wheels.FirstOrDefault(x => (x.Alignment & WheelAlignment.LeftRightMask) != (inst.Alignment & WheelAlignment.LeftRightMask) && (x.Alignment & WheelAlignment.FrontMidRearMask) == (inst.Alignment & WheelAlignment.FrontMidRearMask)); if (inst.Complement != null) { inst.Complement.Complement = inst; } } InitializePhysics(); foreach (var pair in _frames.Where(x => x.Name.StartsWith("door_"))) { var doorAlignment = GetDoorAlignment(pair.Name); if (doorAlignment == DoorAlignment.None) { continue; } var hinge = pair.gameObject.AddComponent <HingeJoint>(); hinge.axis = Vector3.up; hinge.useLimits = true; var limit = 90.0f * ((doorAlignment == DoorAlignment.LeftFront || doorAlignment == DoorAlignment.LeftRear) ? 1.0f : -1.0f); hinge.limits = new JointLimits { min = Mathf.Min(0, limit), max = Mathf.Max(0, limit), }; hinge.connectedBody = gameObject.GetComponent <Rigidbody>(); } var frontSeat = GetPart("ped_frontseat"); var backSeat = GetPart("ped_backseat"); if (frontSeat != null) { var frontSeatMirror = new GameObject("ped_frontseat").transform; frontSeatMirror.SetParent(frontSeat.parent, false); frontSeatMirror.localPosition = Vector3.Scale(frontSeat.localPosition, new Vector3(-1f, 1f, 1f)); if (frontSeat.localPosition.x > 0f) { AttachSeat(frontSeat, SeatAlignment.FrontRight); AttachSeat(frontSeatMirror, SeatAlignment.FrontLeft); } else { AttachSeat(frontSeatMirror, SeatAlignment.FrontRight); AttachSeat(frontSeat, SeatAlignment.FrontLeft); } DriverTransform = GetSeat(SeatAlignment.FrontLeft).Parent; } if (backSeat != null) { var backSeatMirror = new GameObject("ped_backseat").transform; backSeatMirror.SetParent(backSeat.parent, false); backSeatMirror.localPosition = Vector3.Scale(backSeat.localPosition, new Vector3(-1f, 1f, 1f)); if (backSeat.localPosition.x > 0f) { AttachSeat(backSeat, SeatAlignment.BackRight); AttachSeat(backSeatMirror, SeatAlignment.BackLeft); } else { AttachSeat(backSeatMirror, SeatAlignment.BackRight); AttachSeat(backSeat, SeatAlignment.BackLeft); } } gameObject.SetLayerRecursive(Layer); }