Exemplo n.º 1
0
        private void Awake()
        {
            Log             = new Log(Logger);
            contentProvider = new ContentProvider();

#if DEBUG
            Chen.Helpers.GeneralHelpers.MultiplayerTest.Enable(Log);
#endif
            Log.Debug("Initializing config file...");
            cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true);

            Log.Debug("Loading asset bundle...");
            BundleInfo bundleInfo = new BundleInfo("Chen.Qb.assetbundle", BundleType.UnityAssetBundle);
            assetBundle = new AssetsManager(bundleInfo).Register();
            assetBundle.ConvertShaders();

            Log.Debug("Registering Qb Drone...");
            dronesList = DroneCatalog.Initialize(ModGuid, cfgFile);
            DroneCatalog.ScopedSetupAll(dronesList);

            contentProvider.Initialize();
        }
Exemplo n.º 2
0
        private void Awake()
        {
            Log = new Log(Logger);

            Log.Debug("Performing plugin setup:");

#if DEBUG
            MultiplayerTest.Enable(Logger, "Running test build with debug enabled! Report to CHEN if you're seeing this!");
#endif

            Log.Debug("Loading assets...");
            BundleInfo bundleInfo = new BundleInfo("Chen.ClassicItems.chensclassicitems_assets", BundleType.UnityAssetBundle);
            assetBundle = new AssetsManager(bundleInfo).Register();
            assetBundle.ConvertShaders();

            cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true);

            Log.Debug("Loading global configs...");
            globalCfg.BindAll(cfgFile, ModName, "Global");

            Log.Debug("Instantiating item classes...");
            chensItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo
            {
                displayName     = "Chen's Classic Items",
                longIdentifier  = "ChensClassicItems",
                shortIdentifier = "CCI",
                mainConfigFile  = cfgFile
            });

            Log.Debug("Loading item configs...");
            foreach (CatalogBoilerplate x in chensItemList)
            {
                x.SetupConfig();
                x.ConfigEntryChanged += (sender, args) =>
                {
                    if ((args.flags & AutoConfigUpdateActionTypes.InvalidateLanguage) == 0)
                    {
                        return;
                    }
                    var y = sender as CatalogBoilerplate;
                    if (y.pickupDef != null)
                    {
                        var c = y.pickupDef.displayPrefab;
                        if (!c)
                        {
                            return;
                        }
                        var ctsf   = c.transform;
                        var cfront = ctsf.Find("cardfront");
                        if (!cfront)
                        {
                            return;
                        }

                        cfront.Find("carddesc").GetComponent <TextMeshPro>().text = Language.GetString(longDesc ? y.descToken : y.pickupToken);
                        cfront.Find("cardname").GetComponent <TextMeshPro>().text = Language.GetString(y.nameToken);
                    }
                    if (y.logbookEntry != null)
                    {
                        y.logbookEntry.modelPrefab = y.pickupDef.displayPrefab;
                    }
                };
            }

            Log.Debug("Registering item attributes...");
            foreach (CatalogBoilerplate x in chensItemList)
            {
                string mpnOvr = null;
                if (x is Item item)
                {
                    mpnOvr = "Assets/ClassicItems/models/" + modelNameMap[item.itemTier] + ".prefab";
                }
                else if (x is Equipment eqp)
                {
                    mpnOvr = "Assets/ClassicItems/models/" + (eqp.isLunar ? "LqpCard.prefab" : "EqpCard.prefab");
                }
                var ipnOvr = "Assets/ClassicItems/icons/" + x.name + "_icon.png";

                if (mpnOvr != null)
                {
                    typeof(CatalogBoilerplate).GetProperty(nameof(CatalogBoilerplate.modelResource)).SetValue(x, assetBundle.LoadAsset <GameObject>(mpnOvr));
                    typeof(CatalogBoilerplate).GetProperty(nameof(CatalogBoilerplate.iconResource)).SetValue(x, assetBundle.LoadAsset <Sprite>(ipnOvr));
                }

                x.SetupAttributes();
            }

            Log.Debug("Registering item behaviors...");
            foreach (CatalogBoilerplate x in chensItemList)
            {
                x.SetupBehavior();
            }

            Log.Debug("Performing early finalization...");
            T2Module.SetupAll_PluginStart(chensItemList);

            new ContentProvider().Initialize();

            if (globalCfg.logEvolutionItemList)
            {
                RunArtifactManager.onArtifactEnabledGlobal  += OnEvolutionEnable;
                RunArtifactManager.onArtifactDisabledGlobal += OnEvolutionDisable;
            }

            Log.Debug("Initial setup done!");
        }
Exemplo n.º 3
0
 /// <summary>
 /// Replaces all the shaders of the materials in the specified asset bundle.
 /// Uses the prefix "Fake RoR" as a prefix to match materials whose shaders will be replaced.
 /// It also uses RoR2Helpers.DefaultData.ShaderReplacements dictionary as reference for replacements.
 /// </summary>
 /// <param name="assetBundle">Asset bundle whose materials will be converted</param>
 public static void ConvertShaders(this AssetBundle assetBundle) => assetBundle.ConvertShaders(ShaderReplacements, "Fake RoR");