Skip to content

Commit

Permalink
Merge pull request #41 from InvalidArgument3/cores
Browse files Browse the repository at this point in the history
distribution, enough for now
  • Loading branch information
InvalidArgument3 authored Jun 8, 2024
2 parents fe501a7 + adce1d2 commit efb2502
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public static AsteroidEntity CreateAsteroid(Vector3D position, float size, Vecto
return ent;
}

public float Size = 3;
public float Size;
public string ModelString = "";
public AsteroidType Type;
private float _integrity = 1;
private float _integrity;

public void SplitAsteroid()
{
Expand Down Expand Up @@ -175,7 +175,9 @@ private void Init(Vector3D position, float size, Vector3D initialVelocity, Aster
ModelString = Path.Combine(modPath, UraniniteAsteroidModels[MainSession.I.Rand.Next(UraniniteAsteroidModels.Length)]);
break;
}

Size = size;
_integrity = AsteroidSettings.BaseIntegrity * Size;

Log.Info($"Attempting to load model: {ModelString}");

Expand All @@ -196,7 +198,7 @@ private void Init(Vector3D position, float size, Vector3D initialVelocity, Aster

CreatePhysics();
Physics.LinearVelocity = initialVelocity + RandVector() * AsteroidSettings.VelocityVariability;
Physics.AngularVelocity = RandVector() * AsteroidSettings.AngularVelocityVariability; // Set initial angular velocity
Physics.AngularVelocity = RandVector() * AsteroidSettings.GetRandomAngularVelocity(MainSession.I.Rand); // Set initial angular velocity

Log.Info($"Asteroid model {ModelString} loaded successfully with initial angular velocity: {Physics.AngularVelocity}");
}
Expand Down Expand Up @@ -235,4 +237,3 @@ private Vector3D RandVector()
}
}
}

42 changes: 28 additions & 14 deletions Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ internal static class AsteroidSettings
public static int MaxAsteroidCount = 1000;
public static int AsteroidSpawnRadius = 10000;
public static int AsteroidVelocityBase = 0;
public static double VelocityVariability = 10; // New setting for velocity variability
public static double AngularVelocityVariability = 0.1; // New setting for angular velocity variability
public static double VelocityVariability = 10;
public static double AngularVelocityVariability = 0.1;

// Weights for asteroid type frequencies
public static double IceWeight = 0.45; // 45%
public static double StoneWeight = 0.45; // 45%
public static double IceWeight = 0.80;
public static double StoneWeight = 0.11;
public static double IronWeight = 0.01;
public static double NickelWeight = 0.01;
public static double CobaltWeight = 0.01;
Expand All @@ -25,17 +25,22 @@ internal static class AsteroidSettings
public static double PlatinumWeight = 0.01;
public static double UraniniteWeight = 0.01;

// New settings for base integrity and size
public static float BaseIntegrity = 1f;
public static float MinAsteroidSize = 1.5f;
public static float MaxAsteroidSize = 500f;

public static SpawnableArea[] ValidSpawnLocations =
{
new SpawnableArea
{
CenterPosition = new Vector3D(148001024.50, 1024.50, 1024.50),
Normal = new Vector3D(1, 10, 0.5).Normalized(),
Radius = 60268000 * 2.5,
InnerRadius = 60268000 * 1.2,
HeightFromCenter = 1000,
}
};
new SpawnableArea
{
CenterPosition = new Vector3D(148001024.50, 1024.50, 1024.50),
Normal = new Vector3D(1, 10, 0.5).Normalized(),
Radius = 60268000 * 2.5,
InnerRadius = 60268000 * 1.2,
HeightFromCenter = 1000,
}
};

public static bool CanSpawnAsteroidAtPoint(Vector3D point, out Vector3D velocity)
{
Expand Down Expand Up @@ -88,8 +93,17 @@ public static AsteroidType GetRandomAsteroidType(Random rand)
randomValue -= PlatinumWeight;
return AsteroidType.Uraninite;
}
}

public static double GetRandomAngularVelocity(Random rand)
{
return AngularVelocityVariability * rand.NextDouble();
}

public static float GetRandomAsteroidSize(Random rand)
{
return MinAsteroidSize + (float)rand.NextDouble() * (MaxAsteroidSize - MinAsteroidSize);
}
}
internal class SpawnableArea
{
public Vector3D CenterPosition;
Expand Down

0 comments on commit efb2502

Please sign in to comment.