private void UpdateTickEvent(object sender, EventArgs e) { if (this.ModConfig == null || Game1.currentLocation == null) { return; } MouseState currentMouseState = Mouse.GetState(); KeyboardState currentKeyboardState = Keyboard.GetState(); if (Keyboard.GetState().IsKeyDown(ModConfig.updateConfig)) { ModConfig = this.Helper.ReadConfig <TractorConfig>(); } DoAction(currentKeyboardState, currentMouseState); }
private void AppendTractorParamsToStartTask( PoolConfigurationModel poolConfiguration, RenderingEnvironment environment, StartTask startTask, TractorConfig tractorConfig, InstallationPackage tractorPackage, bool isWindows) { var commandLine = startTask.CommandLine; var resourceFiles = new List <ResourceFile>(startTask.ResourceFiles); if (environment.KeyVaultServicePrincipal != null) { commandLine += GetParameterSet(isWindows, "tenantId", environment.KeyVaultServicePrincipal.TenantId.ToString()); commandLine += GetParameterSet(isWindows, "applicationId", environment.KeyVaultServicePrincipal.ApplicationId.ToString()); commandLine += GetParameterSet(isWindows, "keyVaultCertificateThumbprint", environment.KeyVaultServicePrincipal.Thumbprint); commandLine += GetParameterSet(isWindows, "keyVaultName", environment.KeyVault.Name); } var groups = $"azure,{poolConfiguration.PoolName}"; if (poolConfiguration.AdditionalGroups != null && poolConfiguration.AdditionalGroups.Any()) { groups += $",{string.Join(',', poolConfiguration.AdditionalGroups)}"; } if (!string.IsNullOrWhiteSpace(tractorConfig.EngineIpOrHostnameAndPort)) { commandLine += GetParameterSet(isWindows, "engineHost", tractorConfig.EngineIpOrHostnameAndPort); } if (!string.IsNullOrWhiteSpace(groups)) { commandLine += GetParameterSet(isWindows, "groups", groups); } if (tractorPackage != null && !string.IsNullOrEmpty(tractorPackage.Container)) { resourceFiles.Add(GetContainerResourceFile(tractorPackage.Container, tractorPackage.PackageName)); commandLine += GetParameterSet(isWindows, "installerPath", tractorPackage.PackageName); } commandLine += ";"; startTask.CommandLine = commandLine; startTask.ResourceFiles = resourceFiles; }
/********* ** Public methods *********/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { this.ModConfig = helper.ReadConfig <TractorConfig>(); this.mouseHoldDelayCount = this.mouseHoldDelay; // spawn tractor & remove it before save TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted; LocationEvents.CurrentLocationChanged += this.LocationEvents_CurrentLocationChanged; SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; // so that weird shit wouldnt happen MenuEvents.MenuChanged += this.MenuEvents_MenuChanged; MenuEvents.MenuClosed += this.MenuEvents_MenuClosed; // handle player interaction GameEvents.UpdateTick += this.UpdateTickEvent; }