Pin the dice of a zone without a run seed at their pre-run-seed values

A zone with no galaxy and a zone of a save written before run-seed (seed 0)
drop the items and scatter the mines they did at eb27ced1; values computed
at that base.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-18 17:33:11 +02:00
commit 727c409659
2 changed files with 47 additions and 10 deletions

View file

@ -238,6 +238,31 @@ public sealed class LootTests : IDisposable
Assert.True(Differ(first, DropsAt("Other dice", 7)));
}
// Pinned at eb27ced1, before run-seed: a zone with no galaxy, and a zone of a save written before run-seed (seed 0),
// roll on the zone's name alone and drop exactly what they dropped.
[Theory]
[InlineData(false)]
[InlineData(true)]
public void AZoneWithoutARunSeedKeepsItsDrops(bool restoredFromAnOldSave)
{
var drops = restoredFromAnOldSave ? DropsAt("Dice", 0) : Released(KillInNewLab("Dice"), 0);
Assert.Equal(new[] { "Spare", "Orex7", "Spare" }, drops.Select(d => d.Item));
Assert.All(drops, d => Assert.Equal(new float2(31, -17), d.Position));
var velocities = new[] { float2(-17.977364f, 17.372805f), float2(-5.908107f, 24.291857f), float2(-24.228783f, -6.1616626f) };
for (var i = 0; i < velocities.Length; i++)
{
Assert.Equal(velocities[i].x, drops[i].Velocity.x, 3);
Assert.Equal(velocities[i].y, drops[i].Velocity.y, 3);
}
}
private Lab KillInNewLab(string zoneName)
{
var lab = Build(zoneName);
Kill(Spawn(lab, float3(31, 0, -17)));
return lab;
}
[Fact]
public void GearDropsByProbabilityCargoAlways()
{

View file

@ -690,19 +690,31 @@ public sealed class MineTests : IDisposable
[Fact]
public void ANewGameScattersMinesDifferently()
{
float2 LaunchAt(uint runSeed)
{
var lab = Build(spread: 40f, velocity: 5f, layerFaction: A, runSeed: runSeed);
var atLay = default(KinematicBody);
using var sub = lab.Zone.Mines.ObserveAdd().Subscribe(e => atLay = e.Value.Body);
lab.Layer.Direction = normalize(float2(1, 2));
LayOne(lab);
return atLay.Velocity;
}
Assert.NotEqual(LaunchAt(1), LaunchAt(2));
}
private float2 LaunchAt(uint? runSeed)
{
var lab = Build(spread: 40f, velocity: 5f, layerFaction: A, runSeed: runSeed);
var atLay = default(KinematicBody);
using var sub = lab.Zone.Mines.ObserveAdd().Subscribe(e => atLay = e.Value.Body);
lab.Layer.Direction = normalize(float2(1, 2));
LayOne(lab);
return atLay.Velocity;
}
// Pinned at eb27ced1, before run-seed: a zone with no galaxy, and a zone of a save written before run-seed (seed 0),
// scatter their mines on the zone's name alone.
[Theory]
[InlineData(false)]
[InlineData(true)]
public void AZoneWithoutARunSeedKeepsItsMineScatter(bool restoredFromAnOldSave)
{
var velocity = LaunchAt(restoredFromAnOldSave ? 0u : (uint?) null);
Assert.Equal(3.2546253f, velocity.x, 3);
Assert.Equal(3.795711f, velocity.y, 3);
}
[Fact]
public void TheLaunchAngleIsTheMinesOwnDice()
{