public override void Reset() { gameObject = null; useOverlapSphere = true; gravity = 6.25f; useOrbit = false; overlapSphereSize = 50; forceMultiplierTemp = 2; layerFilterOn = false; layer = 0; disableGravity = false; updateSelect = UpdateType.FixedUpdate; forceType = ForceType.None; orbitType = OrbitType.normal; useSpeedVelocity = false; setSpeedVelocity = 500f; useAddForceAtPosition = false; useAddTorque = false; torqueAmount = 0; orbitOffset = 20f; orbitSpeed = 20f; useFx = false; fxSpeed = 0; fxType = FxType.Impulse; onlyUseFx = false; }
/// <summary>Returns a string that represents the current object.</summary> /// <returns>A string that represents the current object.</returns> public override string ToString() { var nameUpper = OrbitType.GetLabel().ToUpper(); var gtoString = $"{Apoapsis:n0}km x {Periapsis:n0}km @ {Inclination:n1}° Inclination"; var normalString = $"{Apoapsis:n0}km @ {Inclination}° Inclination"; return(nameUpper == "GTO" ? gtoString : normalString); }
public SpecificOrbitParameter(double deviationWindow, CelestialBody targetBody, OrbitType orbitType, double difficultyFactor) { this.deviationWindow = deviationWindow; this.targetBody = targetBody; this.successCounter = 0; beenSetup = false; this.orbitType = orbitType; this.difficultyFactor = difficultyFactor; }
public SpecificOrbitParameter() { deviationWindow = 10; targetBody = Planetarium.fetch.Home; this.successCounter = 0; beenSetup = false; orbitType = OrbitType.RANDOM; difficultyFactor = 0.5; }
private void setOrbitType(OrbitType targetType, double difficultyFactor) { if ((object)targetBody == null) { return; } if (targetType == OrbitType.SYNCHRONOUS) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else if (targetType == OrbitType.STATIONARY) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else if (targetType == OrbitType.MOLNIYA) { if (Util.canBodyBeMolniya(targetBody)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else if (targetType == OrbitType.TUNDRA) { if (Util.canBodyBeTundra(targetBody)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else { orbitType = targetType; } }
Vector2 mouseStartPos; // Track initial mouse position on click private void Update() { if (Input.GetButtonDown("Fire1")) // If click { mouseStartPos = Input.mousePosition + new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0); // Get mouse position in relation to center if (stopRotationOnClick) // If manual rotation on click { orbitType = OrbitType.Manual; // Start manual rotation } } }
public OrbitData(OrbitData orig, Contract contract) { type = orig.type; name = orig.name; orbitType = orig.orbitType; index = orig.index; count = orig.count; // Lazy copy of orbit - only really used to store the orbital parameters, so not // a huge deal. orbit = orig.orbit; }
public static void LoadNode(ConfigNode node, string nameOfClass, string nameOfValue, ref OrbitType orbitType, OrbitType defaultOrbitType) { bool hasValue = node.HasValue(nameOfValue); bool parsed = false; if (hasValue) { int loadedOrbitTypeInteger = 0; parsed = int.TryParse(node.GetValue(nameOfValue), out loadedOrbitTypeInteger); orbitType = (OrbitType)loadedOrbitTypeInteger; } if (!hasValue || !parsed) { switch (defaultOrbitType) { case OrbitType.EQUATORIAL: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of EQUATORIAL!"); break; case OrbitType.POLAR: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of POLAR!"); break; case OrbitType.RANDOM: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of RANDOM!"); break; case OrbitType.STATIONARY: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of STATIONARY!"); break; case OrbitType.SYNCHRONOUS: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of SYNCHRONOUS!"); break; case OrbitType.MOLNIYA: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of MOLNIYA!"); break; case OrbitType.TUNDRA: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of MOLNIYA!"); break; default: Debug.LogWarning("Fine Print" + nameOfClass + " failed to load " + nameOfValue + ", initializing with default of UNKNOWN!"); break; } orbitType = defaultOrbitType; resetBoard(); } }
protected override void OnLoad(ConfigNode node) { base.OnLoad(node); try { root = (DMLongOrbitParameter)Parent; } catch (Exception e) { loadFail("Could not find root long orbit parameter; removing DMSpecific Orbit Parameter\n" + e.ToString()); return; } if (HighLogic.LoadedScene == GameScenes.SPACECENTER && this.Root.ContractState == Contract.State.Active) { body = node.parse("TargetBody", (CelestialBody)null); if (body == null) { loadFail("Failed To Load Target Body; DMSpecific Orbit Parameter Removed"); return; } int oType = node.parse("orbitType", (int)1000); if (oType == 1000) { loadFail("Failed To Load Orbit Type; DMSpecific Orbit Parameter Removed"); return; } type = (OrbitType)oType; inc = node.parse("inclination", (double)90); ecc = node.parse("eccentricity", (double)0); sma = node.parse("sma", (double)0); aop = node.parse("argumentOfPeriapsis", (double)0); mae = node.parse("meanAnomalyAtEpoch", (double)0); epo = node.parse("epoch", (double)0); lan = node.parse("lan", (double)0); deviation = node.parse("deviationWindow", (double)10); setupOrbit(true); } if (this.Root.ContractState == Contract.State.Active) { orbitLoaded = testOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER); } loaded = true; }
public DMSpecificOrbitParameter(OrbitType orbitType, double inclination, double eccentricity, double semi, double la, double argumentOfPeriapsis, double meanAnomalyAtEpoch, double epoch, CelestialBody targetBody, double deviationWindow, DMLongOrbitParameter r) : base(orbitType, inclination, eccentricity, semi, la, argumentOfPeriapsis, meanAnomalyAtEpoch, epoch, targetBody, deviationWindow) { type = orbitType; body = targetBody; inc = inclination; ecc = eccentricity; sma = semi; lan = la; aop = argumentOfPeriapsis; mae = meanAnomalyAtEpoch; epo = epoch; deviation = deviationWindow; root = r; disableOnStateChange = false; }
public SpecificOrbitParameter(OrbitType orbitType, double inclination, double eccentricity, double sma, double lan, double argumentOfPeriapsis, double meanAnomalyAtEpoch, double epoch, CelestialBody targetBody, double difficultyFactor, double deviationWindow) { this.deviationWindow = deviationWindow; this.successCounter = 0; beenSetup = false; this.orbitType = orbitType; this.difficultyFactor = difficultyFactor; this.inclination = inclination; this.eccentricity = eccentricity; this.sma = sma; this.lan = lan; this.argumentOfPeriapsis = argumentOfPeriapsis; this.meanAnomalyAtEpoch = meanAnomalyAtEpoch; this.epoch = epoch; this.targetBody = targetBody; }
public SpecificOrbitParameter() { deviationWindow = 10; this.successCounter = 0; beenSetup = false; orbitType = OrbitType.RANDOM; difficultyFactor = 0.5; inclination = 0.0; eccentricity = 0.0; sma = 10000000.0; lan = 0.0; argumentOfPeriapsis = 0.0; meanAnomalyAtEpoch = 0.0; epoch = 0.0; targetBody = Planetarium.fetch.Home; }
public OrbitData(OrbitData orig, Contract contract) { type = orig.type; orbitType = orig.orbitType; count = orig.count; targetBody = orig.targetBody; altitudeFactor = orig.altitudeFactor; inclinationFactor = orig.inclinationFactor; eccentricity = orig.eccentricity; deviationWindow = orig.deviationWindow; this.contract = contract; // Lazy copy of orbit - only really used to store the orbital parameters, so not // a huge deal. orbit = orig.orbit; }
public OrbitData(OrbitData orig, Contract contract) { type = orig.type; name = orig.name; orbitType = orig.orbitType; index = orig.index; count = orig.count; targetBody = orig.targetBody; altitudeFactor = orig.altitudeFactor; inclinationFactor = orig.inclinationFactor; eccentricity = orig.eccentricity; deviationWindow = orig.deviationWindow; // Lazy copy of orbit - only really used to store the orbital parameters, so not // a huge deal. orbit = orig.orbit; }
private void Update() { if (SatelliteOverloadTimerScript.IsCurrentOrbitType(OrbitType.RelToEllipse) && currentOrbit == OrbitType.Arc) { OverloadToCircle(3); MoveToNextOrbitTypeStart <SateliteMoveCircleScript>(); currentOrbit = OrbitType.RelToEllipse; } else if (SatelliteOverloadTimerScript.IsCurrentOrbitType(OrbitType.Ellipse) && currentOrbit == OrbitType.RelToEllipse) { foreach (var sat in satellites) { sat.GetComponent <SateliteMoveCircleScript>().enabled = true; sat.GetComponent <SateliteMoveTowardScript>().enabled = false; } currentOrbit = OrbitType.Ellipse; } }
public static bool IsCurrentOrbitType(OrbitType orbitType) { return(orbitType.Equals(GetCurrentOrvitType())); }
private void setOrbitType(OrbitType targetType, double difficultyFactor) { if ((object)targetBody == null) { return; } //Check if the configuration allows this orbit type. switch (targetType) { case OrbitType.EQUATORIAL: if (!FPConfig.Satellite.AllowEquatorial) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.POLAR: if (!FPConfig.Satellite.AllowPolar) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.STATIONARY: if (!FPConfig.Satellite.AllowStationary) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.SYNCHRONOUS: if (!FPConfig.Satellite.AllowSynchronous) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.KOLNIYA: if (!FPConfig.Satellite.AllowKolniya) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.TUNDRA: if (!FPConfig.Satellite.AllowTundra) { orbitType = OrbitType.RANDOM; return; } break; } //Check if this orbit type is possible on the target body. if (targetType == OrbitType.SYNCHRONOUS) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else if (targetType == OrbitType.STATIONARY) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else if (targetType == OrbitType.KOLNIYA) { if (Util.canBodyBeKolniya(targetBody)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else if (targetType == OrbitType.TUNDRA) { if (Util.canBodyBeTundra(targetBody)) { orbitType = targetType; } else { orbitType = OrbitType.RANDOM; } } else { orbitType = targetType; } }
public SpecificOrbitWrapper(OrbitType orbitType, double inclination, double eccentricity, double sma, double lan, double argumentOfPeriapsis, double meanAnomalyAtEpoch, double epoch, CelestialBody targetBody, double deviationWindow) : base(orbitType, inclination, eccentricity, sma, lan, argumentOfPeriapsis, meanAnomalyAtEpoch, epoch, targetBody, deviationWindow) { }
private void setOrbitType(OrbitType targetType, double difficultyFactor) { if ((object)targetBody == null) return; //Check if the configuration allows this orbit type. switch (targetType) { case OrbitType.EQUATORIAL: if (!FPConfig.Satellite.AllowEquatorial) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.POLAR: if (!FPConfig.Satellite.AllowPolar) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.STATIONARY: if (!FPConfig.Satellite.AllowStationary) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.SYNCHRONOUS: if (!FPConfig.Satellite.AllowSynchronous) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.KOLNIYA: if (!FPConfig.Satellite.AllowKolniya) { orbitType = OrbitType.RANDOM; return; } break; case OrbitType.TUNDRA: if (!FPConfig.Satellite.AllowTundra) { orbitType = OrbitType.RANDOM; return; } break; } //Check if this orbit type is possible on the target body. if (targetType == OrbitType.SYNCHRONOUS) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else if (targetType == OrbitType.STATIONARY) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else if (targetType == OrbitType.KOLNIYA) { if (Util.canBodyBeKolniya(targetBody)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else if (targetType == OrbitType.TUNDRA) { if (Util.canBodyBeTundra(targetBody)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else orbitType = targetType; }
/// <summary> /// Initializes a new instance of the <see cref="CapabilitySummary"/> class. /// </summary> /// <param name="orbitType">The orbit type this summary represents.</param> /// <param name="payloadRange">The weight range that a payload can be for this orbit type.</param> public CapabilitySummary(OrbitType orbitType, PayloadRange payloadRange) { OrbitType = orbitType; PayloadRange = payloadRange; }
/// <summary> /// Initializes a new instance of the <see cref="Trajectory" /> class. /// </summary> /// <param name="orbitType">The type of this trajectory.</param> /// <param name="apoapsis">The orbit's apoapsis in kilometers.</param> /// <param name="periapsis">The orbit's periapsis in kilometers.</param> /// <param name="inclination">The orbit's inclination.</param> /// <param name="requiredDeltaV">Gets or sets the required amount of delta-v in m/s to reach the specified orbit.</param> public Trajectory(OrbitType orbitType, double apoapsis, double periapsis, double inclination, double requiredDeltaV) { OrbitType = orbitType; SetOrbitParameters(apoapsis, periapsis, inclination); RequiredDeltaV = requiredDeltaV; }
/// <summary> /// Returns a <see cref="CapabilitySummary"/> collection containing only summaries of the specified <see cref="OrbitType"/>. /// </summary> /// <param name="capabilitySummaries">The <see cref="CapabilitySummary"/> collection to search through.</param> /// <param name="orbitType">The <see cref="OrbitType"/> a summary must be in order to get added to the collection being returned.</param> public IEnumerable <CapabilitySummary> FilterSummaries(IEnumerable <CapabilitySummary> capabilitySummaries, OrbitType orbitType) { // Gather all summaries of the same OrbitType into a list of only that OrbitType. return(capabilitySummaries.Where(summary => summary.OrbitType == orbitType).ToList()); }
public Orbital(string name, OrbitType orbitType) { Name = name; OrbitType = orbitType; }
private void setOrbitType(OrbitType targetType, double difficultyFactor) { if ((object)targetBody == null) return; if (targetType == OrbitType.SYNCHRONOUS) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else if (targetType == OrbitType.STATIONARY) { if (Util.canBodyBeSynchronous(targetBody, difficultyFactor / 2)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else if (targetType == OrbitType.MOLNIYA) { if (Util.canBodyBeMolniya(targetBody)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else if (targetType == OrbitType.TUNDRA) { if (Util.canBodyBeTundra(targetBody)) orbitType = targetType; else orbitType = OrbitType.RANDOM; } else orbitType = targetType; }
protected override bool Generate() { DMReconContract[] reconContracts = ContractSystem.Instance.GetCurrentContracts <DMReconContract>(); int offers = 0; int active = 0; int maxOffers = DMContractDefs.DMRecon.maxOffers; int maxActive = DMContractDefs.DMRecon.maxActive; for (int i = 0; i < reconContracts.Length; i++) { DMReconContract r = reconContracts[i]; if (r.ContractState == State.Offered) { offers++; } else if (r.ContractState == State.Active) { active++; } } if (offers >= maxOffers) { return(false); } if (active >= maxActive) { return(false); } List <CelestialBody> customReachedBodies = new List <CelestialBody>(); switch (prestige) { case ContractPrestige.Trivial: Func <CelestialBody, bool> cb = delegate(CelestialBody b) { if (b == Planetarium.fetch.Sun) { return(false); } if (b.pqsController == null) { return(false); } return(true); }; customReachedBodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.ORBIT, true, cb)); customReachedBodies.AddRange(ProgressUtilities.GetNextUnreached(2, cb)); var activeBodies = ContractSystem.Instance.GetCurrentActiveContracts <DMReconContract>().Select(r => r.body).ToList(); customReachedBodies.RemoveAll(a => activeBodies.Contains(a)); var completedBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Select(r => r.body).ToList(); customReachedBodies.RemoveAll(a => completedBodies.Contains(a)); break; case ContractPrestige.Significant: customReachedBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Trivial).Select(r => r.body).ToList(); var activeSigBodies = ContractSystem.Instance.GetCurrentActiveContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Significant).Select(r => r.body).ToList(); customReachedBodies.RemoveAll(a => activeSigBodies.Contains(a)); var completedSigBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Significant).Select(r => r.body).ToList(); customReachedBodies.RemoveAll(a => completedSigBodies.Contains(a)); break; case ContractPrestige.Exceptional: customReachedBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Significant).Select(r => r.body).ToList(); var activeExcBodies = ContractSystem.Instance.GetCurrentActiveContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Exceptional).Select(r => r.body).ToList(); customReachedBodies.RemoveAll(a => activeExcBodies.Contains(a)); var completedExcBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Exceptional).Select(r => r.body).ToList(); customReachedBodies.RemoveAll(a => completedExcBodies.Contains(a)); break; } if (customReachedBodies.Count <= 0) { return(false); } body = customReachedBodies[rand.Next(0, customReachedBodies.Count)]; if (body == null) { return(false); } double time = 0; OrbitType orbitType = OrbitType.POLAR; Dictionary <int, List <string> > parts = new Dictionary <int, List <string> >(); Orbit o = new Orbit(); double incMod = (rand.NextDouble() * 10) - 5; double timeMod = 1080000; if (!DMUtils.availableScience.ContainsKey("All")) { return(false); } DMScienceContainer container = null; switch (prestige) { case ContractPrestige.Trivial: if (!DMUtils.partAvailable(DMContractDefs.DMRecon.reconTrivialParts)) { return(false); } parts.Add(0, DMContractDefs.DMRecon.reconTrivialParts); if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMRecon.trivialExperimentTitle)) { return(false); } container = DMUtils.availableScience["All"][DMContractDefs.DMRecon.trivialExperimentTitle]; o = CelestialUtilities.GenerateOrbit(orbitType, this.MissionSeed, body, 0.15, ContractDefs.Satellite.TrivialInclinationDifficulty); double st = o.semiMajorAxis - o.referenceBody.Radius; double mt = o.referenceBody.scienceValues.spaceAltitudeThreshold * 5 * .95; if (st > mt) { o.semiMajorAxis = (mt * Math.Max(0.4, rand.NextDouble())) + o.referenceBody.Radius; } timeMod = DMContractDefs.DMRecon.trivialTimeModifier * 6 * 3600; break; case ContractPrestige.Significant: if (!DMUtils.partAvailable(DMContractDefs.DMRecon.reconSignificantParts)) { return(false); } parts.Add(0, DMContractDefs.DMRecon.reconSignificantParts); if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMRecon.significantExperimentTitle)) { return(false); } container = DMUtils.availableScience["All"][DMContractDefs.DMRecon.significantExperimentTitle]; if (SystemUtilities.CoinFlip(rand)) { if (CelestialUtilities.CanBodyBeKolniya(body)) { orbitType = OrbitType.KOLNIYA; } else if (CelestialUtilities.CanBodyBeTundra(body)) { orbitType = OrbitType.TUNDRA; } else { orbitType = OrbitType.POLAR; } } else { if (CelestialUtilities.CanBodyBeTundra(body)) { orbitType = OrbitType.TUNDRA; } else if (CelestialUtilities.CanBodyBeKolniya(body)) { orbitType = OrbitType.KOLNIYA; } else { orbitType = OrbitType.POLAR; } } o = CelestialUtilities.GenerateOrbit(orbitType, this.MissionSeed, body, 0.5, ContractDefs.Satellite.TrivialInclinationDifficulty); timeMod = DMContractDefs.DMRecon.significantTimeModifier * 6 * 3600; incMod = 0; break; case ContractPrestige.Exceptional: if (!DMUtils.partAvailable(DMContractDefs.DMRecon.reconExceptionalParts)) { return(false); } parts.Add(0, DMContractDefs.DMRecon.reconExceptionalParts); if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMRecon.exceptionalExperimentTitle)) { return(false); } container = DMUtils.availableScience["All"][DMContractDefs.DMRecon.exceptionalExperimentTitle]; o = CelestialUtilities.GenerateOrbit(orbitType, this.MissionSeed, body, 0.15, ContractDefs.Satellite.TrivialInclinationDifficulty); double se = o.semiMajorAxis - o.referenceBody.Radius; double me = o.referenceBody.scienceValues.spaceAltitudeThreshold * 5 * .95; if (se > me) { o.semiMajorAxis = (me * Math.Max(0.4, rand.NextDouble())) + o.referenceBody.Radius; } timeMod = DMContractDefs.DMRecon.exceptionalTimeModifier * 6 * 3600; break; } if (container == null) { return(false); } time = timeMod * ((double)rand.Next(6, 17) / 10d); o.inclination += incMod; DMLongOrbitParameter longOrbit = new DMLongOrbitParameter(time); DMPartRequestParameter partRequest = new DMPartRequestParameter(parts, DMContractDefs.DMRecon.useVesselWaypoints, body); DMSpecificOrbitParameter reconParam = new DMSpecificOrbitParameter(orbitType, o.inclination, o.eccentricity, o.semiMajorAxis, o.LAN, o.argumentOfPeriapsis, o.meanAnomalyAtEpoch, o.epoch, body, ContractDefs.Satellite.SignificantDeviation, longOrbit); this.AddParameter(longOrbit); longOrbit.AddParameter(reconParam); longOrbit.AddParameter(partRequest); longOrbit.setPartRequest(partRequest); sciParams[0] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceLow, "SouthernHemisphere", container); sciParams[1] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceLow, "NorthernHemisphere", container); //Add the science collection parent parameter DMCompleteParameter DMcp = new DMCompleteParameter(1, 0); this.AddParameter(DMcp); foreach (DMCollectScience DMCS in sciParams) { if (DMCS == null) { return(false); } else { if (DMCS.Container == null) { continue; } float modifier = ((float)rand.Next(85, 116) / 100f); DMcp.addToSubParams(DMCS); DMCS.SetFunds(DMContractDefs.DMRecon.Funds.ParamReward * modifier, DMContractDefs.DMRecon.Funds.ParamFailure * modifier, body); DMCS.SetScience(DMContractDefs.DMRecon.Science.ParamReward * DMUtils.fixSubjectVal(DMCS.Situation, 1f, body), null); DMCS.SetReputation(DMContractDefs.DMRecon.Reputation.ParamReward * modifier, DMContractDefs.DMRecon.Reputation.ParamFailure * modifier, null); } } if (this.ParameterCount == 0) { return(false); } float primaryModifier = ((float)rand.Next(80, 121) / 100f); float diffModifier = 1 + ((float)this.Prestige * 0.5f); float Mod = primaryModifier * diffModifier; int t = rand.Next(0, 4); if (t == 0) { this.agent = AgentList.Instance.GetAgent("DMagic"); } else { this.agent = AgentList.Instance.GetAgentRandom(); } if (this.agent == null) { this.agent = AgentList.Instance.GetAgentRandom(); } base.SetExpiry(DMContractDefs.DMRecon.Expire.MinimumExpireDays, DMContractDefs.DMRecon.Expire.MaximumExpireDays); base.SetDeadlineDays((float)(time / ((KSPUtil.DefaultDateTimeFormatter)KSPUtil.dateTimeFormatter).KerbinDay) * DMContractDefs.DMRecon.Expire.DeadlineModifier * (this.GetDestinationWeight(body) / 1.4f) * primaryModifier, null); base.SetReputation(DMContractDefs.DMRecon.Reputation.BaseReward * Mod, DMContractDefs.DMRecon.Reputation.BaseFailure * Mod, null); base.SetFunds(DMContractDefs.DMRecon.Funds.BaseAdvance * Mod, DMContractDefs.DMRecon.Funds.BaseReward * Mod, DMContractDefs.DMRecon.Funds.BaseFailure * Mod, body); base.SetScience(DMContractDefs.DMRecon.Science.BaseReward * Mod, body); return(true); }
public static Orbit GenerateOrbit(OrbitType orbitType, int seed, CelestialBody targetBody, double difficultyFactor, double eccentricity = 0.0) { if ((object)targetBody == null) { return(null); } Orbit o = new Orbit(); System.Random generator = new System.Random(seed); //Initialize all the things. //Default inclination needs to be greater than one, just...just trust me on this. double inc = Math.Max(1, (generator.NextDouble() * 90.0) * difficultyFactor); double desiredPeriapsis = 0.0; double desiredApoapsis = 0.0; double pointA = 0.0; double pointB = 0.0; float maximumAltitude = 0f; double easeFactor = 1.0 - difficultyFactor; double minimumAltitude = Util.getMinimumOrbitalAltitude(targetBody); o.referenceBody = targetBody; o.LAN = generator.NextDouble() * 360.0; //If it chooses the sun, the infinite SOI can cause NAN, so choose Eeloo's altitude instead. //Use 90% of the SOI to give a little leeway for error correction. if (targetBody == Planetarium.fetch.Sun) { maximumAltitude = 113549713200f; } else { maximumAltitude = Math.Max((float)minimumAltitude, (float)targetBody.sphereOfInfluence * (float)difficultyFactor); } if (orbitType == OrbitType.RANDOM || orbitType == OrbitType.POLAR || orbitType == OrbitType.EQUATORIAL) { pointA = minimumAltitude + ((maximumAltitude - minimumAltitude) * generator.NextDouble()); pointB = minimumAltitude + ((maximumAltitude - minimumAltitude) * generator.NextDouble()); pointA = UnityEngine.Mathf.Lerp((float)pointA, (float)pointB, (float)easeFactor); desiredApoapsis = Math.Max(pointA, pointB); desiredPeriapsis = Math.Min(pointA, pointB); o.semiMajorAxis = (desiredApoapsis + desiredPeriapsis) / 2.0; o.eccentricity = (desiredApoapsis - desiredPeriapsis) / (desiredApoapsis + desiredPeriapsis); o.argumentOfPeriapsis = generator.NextDouble() * 360.0; } else if (orbitType == OrbitType.KOLNIYA) { o.semiMajorAxis = Util.kolniyaSMA(targetBody); desiredPeriapsis = minimumAltitude * 1.05; desiredApoapsis = (o.semiMajorAxis * 2) - desiredPeriapsis; o.eccentricity = (desiredApoapsis - desiredPeriapsis) / (desiredApoapsis + desiredPeriapsis); if (generator.Next(0, 100) > 50) { o.argumentOfPeriapsis = 270; } else { o.argumentOfPeriapsis = 90; } } else if (orbitType == OrbitType.TUNDRA) { o.semiMajorAxis = Util.synchronousSMA(targetBody); desiredPeriapsis = minimumAltitude * 1.05; desiredApoapsis = (o.semiMajorAxis * 2) - desiredPeriapsis; o.eccentricity = (desiredApoapsis - desiredPeriapsis) / (desiredApoapsis + desiredPeriapsis); if (generator.Next(0, 100) > 50) { o.argumentOfPeriapsis = 270; } else { o.argumentOfPeriapsis = 90; } } else if (orbitType == OrbitType.SYNCHRONOUS || orbitType == OrbitType.STATIONARY) { o.semiMajorAxis = Util.synchronousSMA(targetBody); if (orbitType == OrbitType.SYNCHRONOUS) { o.eccentricity = eccentricity; } else { o.eccentricity = 0.0; } o.argumentOfPeriapsis = generator.NextDouble() * 360.0; } if (orbitType == OrbitType.POLAR) { inc = 90; } else if (orbitType == OrbitType.EQUATORIAL || orbitType == OrbitType.STATIONARY) { inc = 0; o.an = Vector3.zero; o.LAN = 0.0; } //Retrograde orbits are harder on Kerbin and the Sun, but otherwise, 50% chance. //Kolniya and Tundra have invalid inclinations until this point. if (targetBody == Planetarium.fetch.Home || targetBody == Planetarium.fetch.Sun) { if (orbitType == OrbitType.RANDOM || orbitType == OrbitType.POLAR || orbitType == OrbitType.EQUATORIAL || orbitType == OrbitType.SYNCHRONOUS) { if (generator.Next(0, 100) < difficultyFactor * 50) { inc = 180.0 - inc; } } else if (orbitType == OrbitType.KOLNIYA || orbitType == OrbitType.TUNDRA) { if (generator.Next(0, 100) < difficultyFactor * 50) { inc = 116.6; } else { inc = 63.4; } } } else { if (orbitType == OrbitType.RANDOM || orbitType == OrbitType.POLAR || orbitType == OrbitType.EQUATORIAL || orbitType == OrbitType.SYNCHRONOUS) { if (generator.Next(0, 100) > 50) { inc = 180.0 - inc; } } else if (orbitType == OrbitType.KOLNIYA || orbitType == OrbitType.TUNDRA) { if (generator.Next(0, 100) > 50) { inc = 116.6; } else { inc = 63.4; } } } o.inclination = inc; o.meanAnomalyAtEpoch = (double)0.999f + generator.NextDouble() * (1.001 - 0.999); o.epoch = (double)0.999f + generator.NextDouble() * (1.001 - 0.999); o.Init(); PostProcessOrbit(ref o); return(o); }
/// <summary> /// Filters launches by orbit type. Note that you have to call <see cref="BuilderBase{TReturn}.Execute"/> or <see cref="BuilderBase{TReturn}.ExecuteAsync"/> /// to get result from the API. Every next call of this method will override previously saved orbit type filter. /// </summary> /// <param name="orbit">The orbit type (LEO, ISS, etc).</param> /// <returns>The launch builder.</returns> public TBuilder WithOrbit(OrbitType orbit) { AddFilter("orbit", orbit.GetEnumMemberAttributeValue(orbit)); return((TBuilder)this); }