Beispiel #1
0
    // Token: 0x06002162 RID: 8546
    private IEnumerator CreateCar(Transform t)
    {
        GameObject go2 = new GameObject();

        go2.transform.position    = t.position;
        go2.transform.eulerAngles = t.eulerAngles;
        go2.name = "CarPosition";
        go2.AddComponent <CarLoader>();
        go2.GetComponent <CarLoader>().addInteractiveObject = true;
        go2.GetComponent <CarLoader>().groundPosition       = go2.transform;
        go2.AddComponent <CarDebug>();
        List <CarsIdWithConfig> listOfAviableCars = Singleton <CarBundleLoader> .Instance.GetCarsSpawnsInScene(SceneType.Junkyard);

        CarsIdWithConfig randomCar = listOfAviableCars[UnityEngine.Random.Range(0, listOfAviableCars.Count)];
        CarLoader        cl        = go2.GetComponent <CarLoader>();

        cl.ConfigVersion = randomCar.ConfigVersion;
        base.StartCoroutine(cl.LoadCar(randomCar.CarID));
        while (!cl.IsCarLoaded())
        {
            yield return(new WaitForEndOfFrame());
        }
        LicensePlate licensePlate = Singleton <GameInventory> .Instance.GetRandomLicensePlate();

        cl.ChangeLicencePlateTexture(cl.GetCarPart("license_plate_front"), licensePlate.name);
        cl.ChangeLicencePlateTexture(cl.GetCarPart("license_plate_rear"), licensePlate.name);
        CarDoorOpenBlocker doorBlocker = t.GetComponent <CarDoorOpenBlocker>();

        if (doorBlocker)
        {
            cl.LockObject("door_front_left", doorBlocker.openLeftSide);
            cl.LockObject("door_rear_left", doorBlocker.openLeftSide);
            cl.LockObject("door_front_right", doorBlocker.openRightSide);
            cl.LockObject("door_rear_right", doorBlocker.openRightSide);
        }
        cl.PlaceAtPosition();
        cl.SetRandomCarColor();
        yield return(new WaitForEndOfFrame());

        cl.SetRandomMissingPanels(this.percMissingPanels);
        yield return(new WaitForEndOfFrame());

        cl.SetRandomPartsConditions(this.rangePartsCondition.x, this.rangePartsCondition.y);
        yield return(new WaitForEndOfFrame());

        cl.SetRustRandomParts(this.rangeBodyPartsCondition.x, this.rangeBodyPartsCondition.y);
        yield return(new WaitForEndOfFrame());

        cl.SetRandomMissingParts((int)this.percRangeUnmountIO.x, (int)this.percRangeUnmountIO.y);
        yield return(new WaitForEndOfFrame());

        base.StartCoroutine(cl.SetRandomColorPanels(this.percRandomPartsColor, this.rangeColorPartsCondition.x, this.rangeColorPartsCondition.y));
        yield return(new WaitForEndOfFrame());

        cl.SetRandomCarLivery();
        yield return(new WaitForEndOfFrame());

        cl.SetNegotiationPriceMod(UnityEngine.Random.Range(this.rangeNegotationMod.x, this.rangeNegotationMod.y));
        yield return(new WaitForEndOfFrame());

        cl.RunInstantExamine();
        yield return(new WaitForEndOfFrame());

        CarHelper.SetRandomFactoryColor(cl);
        cl.EnableDust(true);
        cl.EnableRustOutside(null, true);
        cl.SetRandomMileage(SceneType.Auction);
        if (go2)
        {
            go2.transform.position    = t.position;
            go2.transform.eulerAngles = t.eulerAngles;
            t.gameObject.SetActive(false);
        }
        yield break;
    }