/// <summary> /// <para>Creates a new asteroid from a randomly chosen asteroid set. The asteroid will be /// given the properties specified by that set, and added to the game as an untracked /// object.</para> /// <para>If asteroid creation failed for any reason, this method will log the error rather /// than propagating the exception into client code.</para> /// </summary> /// <returns>the newly created asteroid, or null if no asteroid was created. May be used as /// a hook by spawners that need more control over asteroid properties. Clients should /// assume the returned vessel is already registered in the game.</returns> protected ProtoVessel spawnAsteroid() { try { return(spawnAsteroid(AsteroidManager.drawAsteroidSet())); } catch (Exception e) { Util.errorToPlayer(e, Localizer.Format("#autoLOC_CustomAsteroids_ErrorSpawnFail")); Debug.LogException(e); return(null); } }
/// <summary> /// <para>Creates a new asteroid from a randomly chosen asteroid set. The asteroid will be /// given the properties specified by that set, and added to the game as an untracked /// object.</para> /// <para>If asteroid creation failed for any reason, this method will log the error rather /// than propagating the exception into client code.</para> /// </summary> /// <returns>the newly created asteroid, or null if no asteroid was created. May be used as /// a hook by spawners that need more control over asteroid properties. Clients should /// assume the returned vessel is already registered in the game.</returns> /// <remarks>At least one population must have a positive spawn rate.</remarks> protected ProtoVessel spawnAsteroid() { try { AsteroidSet group = AsteroidManager.drawAsteroidSet(); ProtoVessel asteroid = spawnAsteroid(group); try { registerAsteroid(asteroid, group); } catch (ArgumentException e) { Debug.LogWarning("[CustomAsteroids]: Duplicate entry in CustomAsteroidRegistry."); Debug.LogException(e); } return(asteroid); } catch (Exception e) { Util.errorToPlayer(e, Localizer.Format("#autoLOC_CustomAsteroids_ErrorSpawnFail")); Debug.LogException(e); return(null); } }