b34945c2d2
Deletes CyclePhaseSystem, GoalReachedSystem, CoreDamage/CoreRestore, ThreatDirector, CoreIntegrity/GoalProgress/RunPhase/RunOutcome/ThreatState components, CoreVisualFeedbackSystem, and the whole Client/Onboarding slice (+6 test files). Keepers reworked: RunDirectorSystem (UpdateBefore attr + launch guard + goal/threat bank removed; sole SaveRequest raiser now), CycleDirectorSpawnSystem (ledger/meta host only), WaveSystem UNGATED (waves run wherever a WaveDirector is baked), EnemyAISystem core-fallback stripped, AmbientAudioSystem reworked (bed + run cues; no CycleState gate), MusicSystem RunInfo-only, HudSystem big trim (goal meter, core bar, siege banner, terminal banner, outcome flash, onboarding hook all gone), MetaShop/ClassPrep/AimReticle siege gates dropped, DebugOverlay/ops re-meant (SpawnWave=force next wave, EndSiege=quiet arena; SetCalm/AdvanceGoal/SetHeat retired, bytes reserved), TuningConfig Core knobs retired (ids 20-23 reserved), StorageMath.DrainFraction deleted, HowToPlay copy rewritten. Save epoch v7 (fresh epoch, operator-approved): SaveData drops goal/core/outcome + conveyor/machine-IO fields; MinLoadableVersion=7; PendingSave/PendingStructure trimmed; RollTerminalCampaignForward deleted; SaveStructureScan signature slimmed. 390 tests green; Play world-creation clean (player + waves live, no exceptions). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
149 lines
4.5 KiB
C#
149 lines
4.5 KiB
C#
using NUnit.Framework;
|
|
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
|
|
namespace ProjectM.Tests
|
|
{
|
|
/// <summary>
|
|
/// Plain-Entities tests for <see cref="StorageMath"/> deposit/withdraw merge logic, using a temp World
|
|
/// and a real DynamicBuffer<StorageEntry> (no netcode world). Pins shared-storage semantics:
|
|
/// deposits merge by item id, withdraws clamp to available and drop empty rows.
|
|
/// </summary>
|
|
public class StorageMathTests
|
|
{
|
|
static (World world, Entity e) MakeWorld()
|
|
{
|
|
var world = new World("StorageMathTestWorld");
|
|
var e = world.EntityManager.CreateEntity(typeof(StorageEntry));
|
|
return (world, e);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
public void Deposit_New_Item_Appends_Row()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 5);
|
|
Assert.AreEqual(1, buf.Length);
|
|
Assert.AreEqual((ushort)1, buf[0].ItemId);
|
|
Assert.AreEqual(5, buf[0].Count);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
|
|
[Test]
|
|
public void Deposit_Same_Item_Merges()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 5);
|
|
StorageMath.Deposit(buf, 1, 3);
|
|
Assert.AreEqual(1, buf.Length);
|
|
Assert.AreEqual(8, buf[0].Count);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
|
|
[Test]
|
|
public void Deposit_Different_Items_Separate_Rows()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 5);
|
|
StorageMath.Deposit(buf, 2, 7);
|
|
Assert.AreEqual(2, buf.Length);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
|
|
[Test]
|
|
public void Withdraw_Partial_Decrements()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 5);
|
|
int taken = StorageMath.Withdraw(buf, 1, 2);
|
|
Assert.AreEqual(2, taken);
|
|
Assert.AreEqual(1, buf.Length);
|
|
Assert.AreEqual(3, buf[0].Count);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
|
|
[Test]
|
|
public void Withdraw_To_Zero_Drops_Row()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 5);
|
|
int taken = StorageMath.Withdraw(buf, 1, 5);
|
|
Assert.AreEqual(5, taken);
|
|
Assert.AreEqual(0, buf.Length);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
|
|
[Test]
|
|
public void Withdraw_More_Than_Available_Clamps()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 3);
|
|
int taken = StorageMath.Withdraw(buf, 1, 10);
|
|
Assert.AreEqual(3, taken);
|
|
Assert.AreEqual(0, buf.Length);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
|
|
[Test]
|
|
public void Withdraw_Missing_Item_Is_NoOp()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 3);
|
|
int taken = StorageMath.Withdraw(buf, 99, 1);
|
|
Assert.AreEqual(0, taken);
|
|
Assert.AreEqual(1, buf.Length);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
|
|
[Test]
|
|
public void Deposit_Ignores_NonPositive_And_ZeroItem()
|
|
{
|
|
var (world, e) = MakeWorld();
|
|
try
|
|
{
|
|
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
|
|
StorageMath.Deposit(buf, 1, 0);
|
|
StorageMath.Deposit(buf, 1, -5);
|
|
StorageMath.Deposit(buf, 0, 5);
|
|
Assert.AreEqual(0, buf.Length);
|
|
}
|
|
finally { world.Dispose(); }
|
|
}
|
|
}
|
|
}
|