예제 #1
0
        public void OnSaving(object sender, SavingEventArgs e)
        {
            if (this.serverManager.IsActive && this.ActiveSaveData != null)
            {
                // Restore Data so when someone uses it with his normal character, it doesn't get saved
                // This could possible get the headless client suck at perk selection
                this.monitor.Log($"Restoring {nameof(HostPlayerData)}", LogLevel.Info);
                HostPlayerData.RestoreHostData(this.helper);
                this.monitor.Log($"Backuping {nameof(HostPlayerData)}", LogLevel.Info);
                HostPlayerData.BackupHostData(this.helper);

                if (Game1.activeClickableMenu is ShippingMenu menu)
                {
                    var totalString = "----";
                    var totals      = this.helper.Reflection.GetFieldValueEx <List <int> >(menu, "categoryTotals", null, this.monitor);
                    var totalIndex  = (int)ShippingMenuTotal.Total;
                    if (totals != null && totals.Count >= totalIndex)
                    {
                        totalString = totals[totalIndex].ToString();
                    }

                    this.monitor.Log($"Skipping {nameof(ShippingMenu)}. Total {totalString}G received for {Game1.dayOfMonth - 1} {Game1.CurrentSeasonDisplayName}", LogLevel.Info);

                    // okClicked is getting invoked by reflection since ShippingMenu checks for CanReceiveInput and so blocks leftClicks
                    this.helper.Reflection.GetMethod(menu, "okClicked").Invoke();
                }
            }
        }
예제 #2
0
        private void StartServerMode()
        {
            this.monitor.Log($"Backuping {nameof(HostPlayerData)}", LogLevel.Info);
            HostPlayerData.BackupHostData(this.helper);

            this.monitor.Log($"Backuping {nameof(HostGameOptions)}", LogLevel.Info);
            HostGameOptions.BackupHostOptions(this.helper);

            this.monitor.Log("Headless mode is now activated!", LogLevel.Info);
            Game1.chatBox.addInfoMessage($"[{nameof(SVHeadlessHost)}] The Host ACTIVATED headless mode!");
        }