Skip to content

Commit

Permalink
Merge pull request #195 from InvalidArgument3/initialversion
Browse files Browse the repository at this point in the history
restore muzz speed check, ringroid gradient toward gasgiant
  • Loading branch information
InvalidArgument3 authored Oct 26, 2024
2 parents 6458bc7 + 64ee6a6 commit a05c4ea
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,23 @@ public static AsteroidEntity CreateAsteroid(Vector3D position, float size, Vecto
if (entityId.HasValue)
ent.EntityId = entityId.Value;

// Only generate random rotation on server if none provided
var massRange = AsteroidSettings.MinMaxMassByType[type];

string ringDebugInfo;
float distanceScale = AsteroidSettings.CalculateMassScaleByDistance(position, MainSession.I.RealGasGiantsApi, out ringDebugInfo);

float randomFactor = (float)MainSession.I.Rand.NextDouble() * 0.2f - 0.1f;
float finalMass = MathHelper.Lerp(massRange.MinMass, massRange.MaxMass, distanceScale + randomFactor);
finalMass = MathHelper.Clamp(finalMass, massRange.MinMass, massRange.MaxMass);

ent.Properties = AsteroidPhysicalProperties.CreateFromMass(finalMass, AsteroidPhysicalProperties.DEFAULT_DENSITY, ent);

if (!rotation.HasValue && MyAPIGateway.Session.IsServer) {
Vector3D randomAxis = RandVector();
float randomAngle = (float)(MainSession.I.Rand.NextDouble() * Math.PI * 2);
rotation = Quaternion.CreateFromAxisAngle(randomAxis, randomAngle);
}
else if (!rotation.HasValue) {
// On client, use identity rotation until server update arrives
rotation = Quaternion.Identity;
}

Expand All @@ -109,7 +118,16 @@ public static AsteroidEntity CreateAsteroid(Vector3D position, float size, Vecto
return null;
}

Log.Info($"Successfully added asteroid {ent.EntityId} to the scene at position {position} with rotation {rotation.Value}");
// Detailed spawn logging
Log.Info($"Spawned ring asteroid {ent.EntityId}:" +
$"\nType: {type}" +
$"\nMass Range: {massRange.MinMass:N0}kg - {massRange.MaxMass:N0}kg" +
$"\nFinal Mass: {finalMass:N0}kg" +
$"\nRandom Factor: {randomFactor:F3}" +
$"\nPosition: {position}" +
$"\nVelocity: {initialVelocity.Length():F1}m/s" +
$"\n{ringDebugInfo}");

return ent;
}
catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void ResetInstability() {
CurrentInstability = 0f;
_lastChunkThreshold = 0f;
}

}

}
Expand Down
Loading

0 comments on commit a05c4ea

Please sign in to comment.