improve meteor spawning (#29057)
This commit is contained in:
@@ -66,7 +66,14 @@ public sealed class MeteorSwarmSystem : GameRuleSystem<MeteorSwarmComponent>
|
||||
: new Random(uid.Id).NextAngle();
|
||||
|
||||
var offset = angle.RotateVec(new Vector2((maximumDistance - minimumDistance) * RobustRandom.NextFloat() + minimumDistance, 0));
|
||||
var subOffset = RobustRandom.NextAngle().RotateVec(new Vector2( (playableArea.TopRight - playableArea.Center).Length() / 2 * RobustRandom.NextFloat(), 0));
|
||||
|
||||
// the line at which spawns occur is perpendicular to the offset.
|
||||
// This means the meteors are less likely to bunch up and hit the same thing.
|
||||
var subOffsetAngle = RobustRandom.Prob(0.5f)
|
||||
? angle + Math.PI / 2
|
||||
: angle - Math.PI / 2;
|
||||
var subOffset = subOffsetAngle.RotateVec(new Vector2( (playableArea.TopRight - playableArea.Center).Length() / 3 * RobustRandom.NextFloat(), 0));
|
||||
|
||||
var spawnPosition = new MapCoordinates(center + offset + subOffset, mapId);
|
||||
var meteor = Spawn(spawnProto, spawnPosition);
|
||||
var physics = Comp<PhysicsComponent>(meteor);
|
||||
|
||||
Reference in New Issue
Block a user