Exemple #1
0
        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);
            }
        }
Exemple #2
0
        public void Initialize(IManager manager, string ipcIdentifier)
        {
            try
            {
                var harmony = new Harmony("com.Larnin.CustomCar");

                harmony.PatchAll(Assembly.GetExecutingAssembly());
            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e.ToString());
            }

            //DebugShaderList.Exec();
            ShaderTool.Instanciate();
            //AudioPlayer.Init();

            try
            {
                CarInfos carInfos = new CarInfos();
                carInfos.collectInfos();
                CarBuilder builder = new CarBuilder();
                builder.createCars(carInfos);
            }
            catch (Exception e)
            {
                ErrorList.add("An error occured while trying to load cars assets");
                Console.Out.WriteLine(e.ToString());
            }

            ModdedCarsColors.LoadAll();

            //disable loging cars
            //LogCarPrefabs.logCars();

            Events.MainMenu.Initialized.Subscribe(data =>
            {
                if (ErrorList.haveErrors())
                {
                    ErrorList.show();
                }
            });
        }