Cut 13d fixes: trample threshold, tile repair, AssetHash, impostor wind & LOD perf
This commit is contained in:
parent
9446c5bc7b
commit
5e7bff860b
6 changed files with 304 additions and 83 deletions
|
|
@ -21,6 +21,8 @@ namespace RustToDust.Tests
|
|||
var catalog = sion.Trees;
|
||||
|
||||
Assert.InRange(catalog.Count, 500, SionTreeCatalog.MaxTrees);
|
||||
Assert.False(string.IsNullOrWhiteSpace(catalog.AssetHash));
|
||||
Assert.Contains($":trees:{catalog.AssetHash}", sion.AssetFingerprint, StringComparison.Ordinal);
|
||||
|
||||
// Check binary disk budget + tree assets directory <= 12.4 MiB
|
||||
string treesBin = Path.Combine(sion.DirectoryPath, "trees_sion.bin");
|
||||
|
|
@ -191,20 +193,28 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void SionTreeDestruction_HeavyWalkerTramplesThinTreesButNotThickOrMonumental()
|
||||
{
|
||||
var sion = SionMapLoader.Load();
|
||||
var trees = new SionTreeDestructionState(sion.Trees);
|
||||
using var session = new ArenaSession(seed: 42, mapKind: ArenaMapKind.Sion, slot0Human: true);
|
||||
var sion = session.State.SionMap!;
|
||||
var trees = session.State.SionTrees!;
|
||||
|
||||
Assert.True(Catalog.Raptor.MassKg < SionTreeDestructionState.HeavyWalkerMinMassKg,
|
||||
$"Expected Raptor ({Catalog.Raptor.MassKg}kg) < HeavyWalkerMinMassKg");
|
||||
Assert.True(Catalog.Bastion.MassKg >= SionTreeDestructionState.HeavyWalkerMinMassKg,
|
||||
$"Expected Bastion ({Catalog.Bastion.MassKg}kg) >= HeavyWalkerMinMassKg");
|
||||
|
||||
SionTreePlacement thin = default;
|
||||
SionTreePlacement thick = default;
|
||||
bool foundThin = false, foundThick = false;
|
||||
foreach (var t in sion.Trees.Trees)
|
||||
{
|
||||
if (!foundThin && t.TrunkRadiusM >= 0.14f && t.TrunkRadiusM < SionTreeDestructionState.WalkerTrampleMaxTrunkRadiusM)
|
||||
if (!foundThin && t.TrunkRadiusM >= 0.12f && t.TrunkRadiusM < SionTreeDestructionState.WalkerTrampleMaxTrunkRadiusM &&
|
||||
!sion.IsInsideAnyBuildingXz(t.X, t.Z, 4.0f))
|
||||
{
|
||||
thin = t;
|
||||
foundThin = true;
|
||||
}
|
||||
if (!foundThick && t.TrunkRadiusM >= 0.45f)
|
||||
if (!foundThick && t.TrunkRadiusM >= 0.45f &&
|
||||
!sion.IsInsideAnyBuildingXz(t.X, t.Z, 4.0f))
|
||||
{
|
||||
thick = t;
|
||||
foundThick = true;
|
||||
|
|
@ -213,19 +223,122 @@ namespace RustToDust.Tests
|
|||
}
|
||||
Assert.True(foundThin && foundThick);
|
||||
|
||||
// Light < 30t mech does not trample
|
||||
trees.ApplyWalkerTrample(thin.X, thin.Z, 2.0f, 20_000f);
|
||||
// Light walker (Raptor < HeavyWalkerMinMassKg) placed overlapping thin tree must NOT trample it
|
||||
session.SetContenderPose(0, thin.X, thin.Z, 0f);
|
||||
session.State.SpawnChassisDrop(thin.X, thin.Z, Catalog.Raptor);
|
||||
Assert.True(session.TrySwapNearbyChassis(0), "Expected swap to Raptor near thin tree");
|
||||
session.SetContenderPose(0, thin.X, thin.Z, 0f);
|
||||
session.Step();
|
||||
Assert.Equal(SionTreeState.Intact, trees.GetState(thin.TreeId));
|
||||
|
||||
// Heavy >= 30t walker tramples thin (< 0.30m) tree
|
||||
trees.ApplyWalkerTrample(thin.X, thin.Z, 2.0f, 35_000f);
|
||||
// Heavy walker (Bastion >= HeavyWalkerMinMassKg) trampling same thin (< 0.30m) tree snaps it cleanly
|
||||
session.State.SpawnChassisDrop(thin.X, thin.Z, Catalog.Bastion);
|
||||
Assert.True(session.TrySwapNearbyChassis(0), "Expected swap to Bastion near thin tree");
|
||||
session.SetContenderPose(0, thin.X, thin.Z, 0f);
|
||||
session.Step();
|
||||
Assert.Equal(SionTreeState.Snapped, trees.GetState(thin.TreeId));
|
||||
|
||||
// Heavy walker does NOT trample thick (>= 0.30m) / monumental trees
|
||||
trees.ApplyWalkerTrample(thick.X, thick.Z, 2.0f, 65_000f);
|
||||
// Heavy walker overlapping thick (>= 0.30m) tree must NOT trample it
|
||||
session.SetContenderPose(0, thick.X, thick.Z, 0f);
|
||||
session.Step();
|
||||
Assert.Equal(SionTreeState.Intact, trees.GetState(thick.TreeId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SionTreeDestruction_FlushDirtyTreeTiles_RestoresColliderImmediatelyAfterAllTileTreesSnappedAndRepaired()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42, mapKind: ArenaMapKind.Sion, slot0Human: true);
|
||||
var sion = session.State.SionMap!;
|
||||
var trees = session.State.SionTrees!;
|
||||
|
||||
// Find an active-near tile or any tile containing solid (>= 0.20m) trees clear of buildings
|
||||
SionTreePlacement targetTree = default;
|
||||
bool found = false;
|
||||
for (int i = 0; i < sion.Trees.Count; i++)
|
||||
{
|
||||
var t = sion.Trees.Trees[i];
|
||||
if (t.TrunkRadiusM >= SionTreeDestructionState.MinColliderTrunkRadiusM &&
|
||||
!sion.IsInsideAnyBuildingXz(t.X, t.Z, 4.5f))
|
||||
{
|
||||
targetTree = t;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.True(found);
|
||||
|
||||
// Place contender 0 in the target tile so SyncNeededTreeTiles keeps it needed across Step(),
|
||||
// and do NOT manually call EnsureTreeTileResident after repair.
|
||||
session.SetContenderPose(0, targetTree.X + 8.0f, targetTree.Z + 8.0f, 0f);
|
||||
session.TileSync.EnsureTreeTileResident(session.World, trees, targetTree.Tx, targetTree.Tz);
|
||||
ulong expectedStableId = Box3DPhysicsTileSync.TreeTileStableIdBase + (ulong)targetTree.TileIndex;
|
||||
var rayOrigin = new Vector3(targetTree.X - 4.0f, targetTree.Y + 1.4f, targetTree.Z);
|
||||
var raySpan = new Vector3(8.0f, 0f, 0f);
|
||||
Assert.Equal(expectedStableId, session.CastWorldRayClosest(rayOrigin, raySpan).StableId);
|
||||
|
||||
// Snap EVERY solid tree in that tile -> removes the Box3D body completely (ResidentTreeTileCount drops)
|
||||
foreach (int idx in sion.Trees.GetTileTreeIndices(targetTree.Tx, targetTree.Tz))
|
||||
{
|
||||
var tileTree = sion.Trees.Trees[idx];
|
||||
if (tileTree.TrunkRadiusM >= SionTreeDestructionState.MinColliderTrunkRadiusM)
|
||||
{
|
||||
trees.ApplyBlast(new Vector3(tileTree.X, tileTree.Y + 0.5f, tileTree.Z), splashRadius: 4f, blastDamage: 300f);
|
||||
}
|
||||
}
|
||||
session.TileSync.FlushDirtyTreeTiles(session.World, trees, maxTilesPerTick: 8);
|
||||
var afterSnapHit = session.CastWorldRayClosest(rayOrigin, raySpan);
|
||||
Assert.False(afterSnapHit.Hit && afterSnapHit.StableId == expectedStableId,
|
||||
"Expected Box3D tree tile body to be removed when all collider trees in tile are snapped");
|
||||
|
||||
// RepairArenaScars() + Step() (NO manual EnsureTreeTileResident!) must immediately restore Box3D collider
|
||||
session.RepairArenaScars();
|
||||
var immediateHit = session.CastWorldRayClosest(rayOrigin, raySpan);
|
||||
Assert.True(immediateHit.Hit && immediateHit.StableId == expectedStableId,
|
||||
$"Expected RepairArenaScars FlushDirtyTreeTiles to restore tree collider {expectedStableId}, got Hit={immediateHit.Hit} StableId={immediateHit.StableId}");
|
||||
session.Step();
|
||||
var stepHit = session.CastWorldRayClosest(rayOrigin, raySpan);
|
||||
Assert.True(stepHit.Hit && stepHit.StableId == expectedStableId,
|
||||
$"Expected tick-0 Step() to keep restored tree collider {expectedStableId}, got Hit={stepHit.Hit} StableId={stepHit.StableId}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SionTreeDestruction_CumulativeBlastDamage_TwoColdStartRecoillessHitsSnapMediumTrunk()
|
||||
{
|
||||
var sion = SionMapLoader.Load();
|
||||
var trees = new SionTreeDestructionState(sion.Trees);
|
||||
|
||||
SionTreePlacement med = default;
|
||||
bool found = false;
|
||||
foreach (var t in sion.Trees.Trees)
|
||||
{
|
||||
if (t.TrunkRadiusM >= 0.32f && t.TrunkRadiusM <= 0.39f)
|
||||
{
|
||||
med = t;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.True(found, "Expected a medium ~0.35m trunk tree in Sion catalog");
|
||||
|
||||
// Cold-start Recoilless shell: WeaponDamage=85 * ~0.65 cold thermal scale = ~55.25 damage (< 65f one-shot core threshold)
|
||||
float coldRecoillessDmg = Catalog.Recoilless.WeaponDamage * 0.65f;
|
||||
var hitPoint = new Vector3(med.X + med.TrunkRadiusM, med.Y + 1.0f, med.Z);
|
||||
|
||||
// Hit #1: chars the tree without snapping it immediately
|
||||
trees.ApplyBlast(hitPoint, splashRadius: 2.5f, blastDamage: coldRecoillessDmg);
|
||||
Assert.Equal(SionTreeState.Charred, trees.GetState(med.TreeId));
|
||||
|
||||
// Hit #2: cumulative damage reaches snapThreshold (~98..105) -> cleanly snaps the trunk
|
||||
trees.ApplyBlast(hitPoint, splashRadius: 2.5f, blastDamage: coldRecoillessDmg);
|
||||
Assert.Equal(SionTreeState.Snapped, trees.GetState(med.TreeId));
|
||||
|
||||
// Repair clears accumulated damage so another single cold-start hit only chars again
|
||||
trees.RepairAll();
|
||||
Assert.Equal(SionTreeState.Intact, trees.GetState(med.TreeId));
|
||||
trees.ApplyBlast(hitPoint, splashRadius: 2.5f, blastDamage: coldRecoillessDmg);
|
||||
Assert.Equal(SionTreeState.Charred, trees.GetState(med.TreeId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CultNet_RemoteClientSyncsTreeScarsInPersistentSnapshotBubbleAndRepair()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue