protected override void OnLoad(ConfigNode node) { if (node.HasValue("target")) { string t = node.GetValue("target"); target = FlightGlobals.Bodies.Find(b => b.name == t); if (target == null) { Utilities.Log_Debug("Checking Galaxies"); target = TSTGalaxies.Galaxies.Find(g => g.name == t); } } }
protected override bool Generate() { TSTTelescopeContract[] TSTTelescopeContracts = ContractSystem.Instance.GetCurrentContracts<TSTTelescopeContract>(); int offers = 0; int active = 0; for (int i = 0; i < TSTTelescopeContracts.Length; i++) { TSTTelescopeContract m = TSTTelescopeContracts[i]; if (m.ContractState == State.Offered) offers++; else if (m.ContractState == State.Active) active++; } Utilities.Log_Debug("Telescope Contracts check offers= {0} active= {1}" , offers.ToString(), active.ToString()); if (offers >= 1) return false; if (active >= 1) return false; Utilities.Log_Debug("Generating Telescope Contract"); agent = AgentList.Instance.GetAgent("Tarsier Space Technology"); SetExpiry(); expiryType = DeadlineType.None; deadlineType = DeadlineType.None; Utilities.Log_Debug("Creating Parameter"); TSTTelescopeContractParam param = new TSTTelescopeContractParam(); AddParameter(param); string target_name = TSTProgressTracker.GetNextTelescopeTarget(); if (target_name == default(string)) { Utilities.Log_Debug("target body is default (not set), cannot generate"); return false; } Utilities.Log_Debug("Target: {0}" , target_name); AvailablePart ap2 = PartLoader.getPartInfoByName("tarsierAdvSpaceTelescope"); if (!ResearchAndDevelopment.PartTechAvailable(ap2) && !ResearchAndDevelopment.PartModelPurchased(ap2) && target_name == "Galaxy1") { Utilities.Log_Debug("Contracts for Planets completed and Galaxy contracts require advanced space telescope"); return false; } Utilities.Log_Debug("Checking Celestial Bodies"); target = FlightGlobals.Bodies.Find(b => b.name == target_name); if (target == null) { Utilities.Log_Debug("Checking Galaxies"); target = TSTGalaxies.Galaxies.Find(g => g.name == target_name); } Utilities.Log_Debug("Using target: {0}" , target.ToString()); param.target = target; Utilities.Log_Debug("Creating Science Param"); TSTScienceParam param2 = new TSTScienceParam(); param2.matchFields.Add("TarsierSpaceTech.SpaceTelescope"); param2.matchFields.Add("LookingAt" + target.name); AddParameter(param2); Utilities.Log_Debug("Created Science Param"); prestige = TSTProgressTracker.getTelescopePrestige(target); if (TSTProgressTracker.HasTelescopeCompleted(target)) { SetScience(TSTMstStgs.Instance.TSTsettings.scienceDiscoveredScope, target.type == typeof(TSTGalaxy) ? null : (CelestialBody)target.BaseObject); SetFunds(TSTMstStgs.Instance.TSTsettings.fundsdiscoveredScope * 0.75f, TSTMstStgs.Instance.TSTsettings.fundsdiscoveredScope, target.type == typeof(TSTGalaxy) ? null : (CelestialBody)target.BaseObject); SetReputation(TSTMstStgs.Instance.TSTsettings.repDiscoveredScope, target.type == typeof(TSTGalaxy) ? null : (CelestialBody)target.BaseObject); } else { SetScience(TSTMstStgs.Instance.TSTsettings.scienceUndiscoveredScope, target.type == typeof(TSTGalaxy) ? null : (CelestialBody)target.BaseObject); SetFunds(TSTMstStgs.Instance.TSTsettings.fundsUndiscoveredScope * 0.75f, TSTMstStgs.Instance.TSTsettings.fundsUndiscoveredScope, target.type == typeof(TSTGalaxy) ? null : (CelestialBody)target.BaseObject); SetReputation(TSTMstStgs.Instance.TSTsettings.repUndiscoveredScope, target.type == typeof(TSTGalaxy) ? null : (CelestialBody)target.BaseObject); } return true; }