/// <summary> /// Generates a new asteroid name appropriate for the chosen set. /// </summary> /// /// <param name="group">The set to which the asteroid belongs.</param> /// <returns>A randomly generated name. The name will be prefixed by a population-specific /// name if custom names are enabled, or by "Ast." if they are disabled.</returns> /// /// <exception cref="System.InvalidOperationException">Thrown if <c>group</c> cannot /// generate valid names. The program state will be unchanged in the event of an /// exception.</exception> /// <exception cref="System.NullReferenceException">Thrown if <c>group</c> is /// null.</exception> private static string makeName(AsteroidSet group) { string name = DiscoverableObjectsUtil.GenerateAsteroidName(); if (AsteroidManager.getOptions().getRenameOption()) { GroupCollection parsed = astName.Match(name).Groups; if (parsed [0].Success) { string newBase = group.getAsteroidName(); if (!newBase.Contains("<<1>>")) { newBase += " <<1>>"; } string id = parsed ["id"].ToString(); name = Localizer.Format(newBase, id); } // if asteroid name doesn't match expected format, leave it as-is #if DEBUG Debug.Log("[CustomAsteroids]: " + Localizer.Format("#autoLOC_CustomAsteroids_LogRename", name)); #endif } return(name); }
/// <summary> /// Prints an error message visible to the player. Does not throw exceptions. /// </summary> /// <param name="format">The error message, a localization tag, or a Lingoona format string /// for the message.</param> /// <param name="param">Any parameters to place in the format string (optional).</param> public static void errorToPlayerLoc(string format, params object [] param) { if (AsteroidManager.getOptions().getErrorReporting()) { ScreenMessages.PostScreenMessage( "[CustomAsteroids]: " + Localizer.Format(format, param), 5.0f, ScreenMessageStyle.UPPER_RIGHT); } }
public Tuple <double, double> drawTrackingTime() { Tuple <float, float> trackTimes = AsteroidManager.getOptions().getUntrackedTimes(); double lifetime = RandomDist.drawUniform(trackTimes.Item1, trackTimes.Item2) * SECONDS_PER_EARTH_DAY; double maxLifetime = trackTimes.Item2 * SECONDS_PER_EARTH_DAY; return(Tuple.Create(lifetime, maxLifetime)); }
/// <summary> /// Generates tracking station info appropriate for the chosen set. /// </summary> /// /// <param name="group">The set to which the asteroid belongs.</param> /// <returns>A ConfigNode storing the asteroid's DiscoveryInfo object.</returns> /// /// <exception cref="System.InvalidOperationException">Thrown if <c>group</c> cannot /// generate valid data. The program state will be unchanged in the event of an /// exception.</exception> /// <exception cref="System.NullReferenceException">Thrown if <c>group</c> is /// null.</exception> private static ConfigNode makeDiscoveryInfo(AsteroidSet group) { Pair <float, float> trackTimes = AsteroidManager.getOptions().getUntrackedTimes(); double lifetime = UnityEngine.Random.Range(trackTimes.first, trackTimes.second) * SECONDS_PER_EARTH_DAY; double maxLifetime = trackTimes.second * SECONDS_PER_EARTH_DAY; UntrackedObjectClass size = (UntrackedObjectClass)(int) (stockSizeCurve.Evaluate(UnityEngine.Random.Range(0.0f, 1.0f)) * Enum.GetNames(typeof(UntrackedObjectClass)).Length); ConfigNode trackingInfo = ProtoVessel.CreateDiscoveryNode( DiscoveryLevels.Presence, size, lifetime, maxLifetime); return(trackingInfo); }
/// <summary>Initializes the scenario prior to loading persistent data. Custom Asteroids /// options must have already been loaded.</summary> internal CustomAsteroidSpawner() { driverRoutine = null; var spawnerType = AsteroidManager.getOptions().getSpawner(); switch (spawnerType) { case SpawnerType.FixedRate: spawner = new FixedRateSpawner(); break; case SpawnerType.Stock: spawner = new StockalikeSpawner(); break; default: throw new System.InvalidOperationException( Localizer.Format("#autoLOC_CustomAsteroids_ErrorNoSpawner", spawnerType)); } }