Пример #1
0
        static GameObject Postfix(GameObject __result)
        {
            //ModLogs.Log(__result.name);
            string[] meshConfigurations = File.ReadAllLines(ModLoader.PatchesPath + "/Parts Meshes Replacer.conf");
            foreach (string meshConfigLine in meshConfigurations)
            {
                //ModLogs.Log(__result.name);
                string[] meshConfig = meshConfigLine.Split('|');
                //ModLogs.Log("MeshConfig: " + meshConfig[0]);
                if (__result.name.Equals(meshConfig[0], StringComparison.OrdinalIgnoreCase))
                {
                    ModLogs.Log("Loading Mesh Replace " + __result.name);
                    Mesh         mesh        = AssetBundles.LoadOBJMesh(meshConfig[1]);
                    MeshFilter[] meshFilters = __result.GetComponentsInChildren <MeshFilter>(true);
                    foreach (MeshFilter meshFilter in meshFilters)
                    {
                        meshFilter.mesh = mesh;
                    }
                    //MeshFilter meshFilter = __result.GetComponent<MeshFilter>();
                    //ModLogs.Log(meshFilter.name);
                    // meshFilter.mesh = mesh;
                }
            }

            /*MeshFilter[] meshFilters = __result.GetComponentsInChildren<MeshFilter>(true);
             * foreach (MeshFilter meshFilter in meshFilters)
             * {
             *  if (meshFilter.mesh != null && typeof(Mesh).IsInstanceOfType(meshFilter.mesh))
             *  {
             *      //ModLogs.Log(meshFilter.mesh.name); - SHOWS ALL THE MESHES NAMES
             *      foreach (string meshConfigLine in meshConfigurations)
             *      {
             *          string[] meshConfig = meshConfigLine.Split('|');
             *          //ModLogs.Log(meshConfig[0] + "a.");
             *          if (meshFilter.mesh.name.Equals(meshConfig[0], StringComparison.OrdinalIgnoreCase))
             *          {
             *              //ModLogs.Log(meshConfig[0]);
             *              Mesh mesh = AssetBundles.LoadOBJMesh("titanx.obj");
             *              meshFilter.mesh = mesh;
             *              //ModLogs.Log("Replacing Mesh " + meshFilter.mesh);
             *          }
             *      }
             *  }
             * }*/
            return(__result);
        }
Пример #2
0
        public static void Init()
        {
            ModLogs.EnableLogs();

            SceneManager.sceneLoaded += OnSceneLoaded;

            if (ModLoaderLoaded || Instance)
            {
                ModLogs.Log("----- PCBSModloader is already loaded! -----\n");
                return;
            }

            GameObject ModHandler = new GameObject();

            ModHandler.AddComponent <ModLoader>();
            ModHandler.AddComponent <Textures>();
            ModHandler.AddComponent <AssetBundles>();
            Instance         = ModHandler.GetComponent <ModLoader>();
            loadTextures     = ModHandler.GetComponent <Textures>();
            loadAssetBundles = ModHandler.GetComponent <AssetBundles>();
            GameObject.DontDestroyOnLoad(ModHandler);

            ModLogs.Log("----- Initializing PCBSModloader... -----\n");
            ModLoaderLoaded = false;
            LoadedMods      = new List <Mod>();

            ModLogs.Log("Initializing harmony...");
            Harmony = HarmonyInstance.Create("com.github.harmony.pcbs.mod");

            if (!Directory.Exists(ModsPath))
            {
                Directory.CreateDirectory(ModsPath);
            }

            ModLogs.Log("Loading internal mods...");
            LoadMod(new ModUI());
            LoadMod(new ModConsole());
            //LoadMod(new Parts());

            ModLogs.Log("Loading mods...");
            LoadMods();

            ModLoaderLoaded = true;
            ModLogs.Log("Finished loading.");
        }