private void Awake()
        {
            Log = new Log(Logger);

#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("ChensBombasticMod.chensbombasticmod_assets", BundleType.UnityAssetBundle);
            assetBundle = new AssetsManager(bundleInfo).Register();

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

            Log.Debug("Instantiating item classes...");
            chensItemList = T2Module.InitAll <CatalogBoilerplate>(new T2Module.ModInfo
            {
                displayName     = "Chen's Bombastic Mod",
                longIdentifier  = "ChensBombasticMod",
                shortIdentifier = "CBM",
                mainConfigFile  = cfgFile
            });

            T2Module.SetupAll_PluginAwake(chensItemList);
            T2Module.SetupAll_PluginStart(chensItemList);
        }
Пример #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!");
        }