private void OnTelescopeScience(TSTSpaceTelescope.TargetableObject lookingAt) { if (target.name == lookingAt.name) { SetComplete(); } }
public static Contract.ContractPrestige getTelescopePrestige(TSTSpaceTelescope.TargetableObject body) { double distance = 0f; if (body.type == typeof(TSTGalaxy)) { Vector3d bodyPos = body.position; CelestialBody HmePlanet = Planetarium.fetch.Home; Vector3d hmeplntPos = HmePlanet.getPositionAtUT(0); distance = Math.Sqrt(Math.Pow(bodyPos.x - hmeplntPos.x, 2) + Math.Pow(bodyPos.y - hmeplntPos.y, 2) + Math.Pow(bodyPos.z - hmeplntPos.z, 2)); } else { distance = Utilities.DistanceFromHomeWorld(body.name); } if (distance < 13000000000) { return(Contract.ContractPrestige.Trivial); } if (distance < 20000000000) { return(Contract.ContractPrestige.Significant); } return(Contract.ContractPrestige.Exceptional); }
public static void OnTelescopePicture(TSTSpaceTelescope.TargetableObject body) { if (isActive) { List <TelescopeListener> listeners = new List <TelescopeListener>(Instance.TelescopeListeners); foreach (TelescopeListener listener in listeners) { listener(body); } } }
public static bool HasTelescopeCompleted(TSTSpaceTelescope.TargetableObject body) { return(!isActive || Instance.TelescopeData[body.name]); }
public static void setTelescopeContractComplete(TSTSpaceTelescope.TargetableObject body) { Instance.TelescopeData[body.name] = true; }
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); }