Beispiel #1
0
        void Awake()
        {
            DepInjector.AddClient(new ProviderManager());

            var harmony = new Harmony(GUID);

            harmony.PatchAll();
        }
Beispiel #2
0
        /// <summary>
        /// Called on startup. Executes all Harmony patches anywhere in the framework's assembly.
        /// </summary>
        private void Awake()
        {
            DepInjector.AddClient(new ProviderManager());

            // Load the Trainworks Bundle, which will be used by the framework for templating
            var assembly = this.GetType().Assembly;

            APIBasePath      = Path.GetDirectoryName(assembly.Location);
            TrainworksBundle = AssetBundle.LoadFromFile(Path.Combine(APIBasePath, "trainworks"));

            var harmony = new Harmony(GUID);

            harmony.PatchAll();
        }
        /// <summary>
        /// Called on startup. Executes all Harmony patches anywhere in the framework's assembly.
        /// </summary>
        private void Awake()
        {
            DepInjector.AddClient(new ProviderManager());

            // Load the Trainworks Bundle, which will be used by the framework for templating
            var assembly = this.GetType().Assembly;

            APIBasePath      = Path.GetDirectoryName(assembly.Location);
            TrainworksBundle = AssetBundle.LoadFromFile(Path.Combine(APIBasePath, "trainworks"));

            // Register in order to provide dummy synthesis data for compatibility reasons
            PluginManager.RegisterPlugin(this);

            var harmony = new Harmony(GUID);

            harmony.PatchAll();
        }
Beispiel #4
0
        public void Initialize()
        {
            Trainworks.Trainworks.Log("Initializing");
            Harmony harmony = new Harmony("io.github.crazyjackel.Stoker");

            harmony.PatchAll();
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Initializing AssetBundle");
            //Load Assets
            var assembly = Assembly.GetExecutingAssembly();

            PluginManager.PluginGUIDToPath.TryGetValue("io.github.crazyjackel.Stoker", out basePath);
            info = new BundleAssetLoadingInfo
            {
                PluginPath = basePath,
                FilePath   = bundleName,
            };
            BundleManager.RegisterBundle(GUIDGenerator.GenerateDeterministicGUID(info.FullPath), info);
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Loaded AssetBundle");

            //Instantiate then Hide Canvas
            var GameObj = BundleManager.LoadAssetFromBundle(info, assetName_Canvas) as GameObject;

            Logger.Log(BepInEx.Logging.LogLevel.Info, "Loaded Main Asset: " + GameObj.name);
            Canvas = GameObject.Instantiate(GameObj);
            DontDestroyOnLoad(Canvas);
            Canvas.SetActive(false);

            //Load Prefab to Instantiate Later
            SelectionButtonPrefab = BundleManager.LoadAssetFromBundle(info, assetName_SelectionButton) as GameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Loaded Button Prefab");

            //Find local Buttons and add Listeners
            //Load Content where to add Selection Buttons
            DeckContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Deck Content");
            CardDatabaseContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground2}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Card Database Content");
            RelicDatabaseContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground3}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Relic Database Content");
            RelicContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground4}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Relic Content");
            UpgradeContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground5}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Upgrade Content");
            UpgradeDatabaseContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground6}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Upgrade Database Content");

            //Get Buttons and Input Fields
            RemoveButton = Canvas.transform.Find($"{name_mainBackground}/{name_removeBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Remove Button");
            RemoveButton.GetComponent <Button>().onClick.AddListener(AttemptToRemoveSelectedCard);
            AddButton = Canvas.transform.Find($"{name_mainBackground}/{name_addBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Add Button");
            AddButton.GetComponent <Button>().onClick.AddListener(AttemptToAddSelectedCardData);
            DuplicateButton = Canvas.transform.Find($"{name_mainBackground}/{name_duplicateBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Duplication Button");
            DuplicateButton.GetComponent <Button>().onClick.AddListener(AttemptToDuplicateSelectedCard);
            AddRelicButton = Canvas.transform.Find($"{name_mainBackground}/{name_addRelicBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Add Relic Button");
            AddRelicButton.GetComponent <Button>().onClick.AddListener(AttemptToAddSelectedRelicData);
            RemoveRelicButton = Canvas.transform.Find($"{name_mainBackground}/{name_removeRelicBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Remove Relic Button");
            RemoveRelicButton.GetComponent <Button>().onClick.AddListener(AttemptToRemoveSelectedRelic);
            AddUpgradeButton = Canvas.transform.Find($"{name_mainBackground}/{name_addUpgradeBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Add Upgrade Button");
            AddUpgradeButton.GetComponent <Button>().onClick.AddListener(AttemptToUpgradeCardState);
            RemoveUpgradeButton = Canvas.transform.Find($"{name_mainBackground}/{name_removeUpgradeBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Remove Upgrade Button");
            RemoveUpgradeButton.GetComponent <Button>().onClick.AddListener(AttemptToRemoveUpgradeState);
            ImportButton = Canvas.transform.Find($"{name_mainBackground}/{name_importBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Import Button");
            ImportButton.GetComponent <Button>().onClick.AddListener(LoadFromTxtFile);
            ExportButton = Canvas.transform.Find($"{name_mainBackground}/{name_exportBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Export Button");
            ExportButton.GetComponent <Button>().onClick.AddListener(ExportStateToTxtFile);
            SearchBar = Canvas.transform.Find($"{name_mainBackground}/{name_searchBarBackground}/{name_searchBar}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Search Bar");
            SearchBar.GetComponent <InputField>().onValueChanged.AddListener(UpdateDatabases);
            FileNameBar = Canvas.transform.Find($"{name_mainBackground}/{name_presetNameBackground}/{name_searchBar}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found File Name Bar");
            FileNameBar.GetComponent <InputField>().onValueChanged.AddListener(UpdateFileName);

            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Elements");
            //Subscribe as Client
            DepInjector.AddClient(this);
            this.Logger.LogInfo("Stoker Plugin Initialized");
        }