using Unity.Entities; namespace ProjectM.Simulation { /// /// Pure save-apply helpers shared by the server spawn system (born-correct load) and EditMode tests. /// Burst-safe: unmanaged, non-generic, no enums (avoids the cross-assembly-generic Burst ICE class). /// public static class SaveApply { /// Replace a StorageEntry ledger buffer's contents with a staged PendingSaveLedgerRow buffer. public static void WriteLedger(DynamicBuffer src, DynamicBuffer dest) { dest.Clear(); for (int i = 0; i < src.Length; i++) dest.Add(new StorageEntry { ItemId = src[i].ItemId, Count = src[i].Count }); } /// EB-1: map a serialized to the staged /// (the menu->ServerWorld copy in WorldLauncher). Pure so the field-for-field copy — including the /// easy-to-miss HP — is unit-tested; an omitted field here silently restores every structure at full HP. public static PendingStructure ToPending(in StructureSave s) => new PendingStructure { Type = s.Type, CellX = s.CellX, CellZ = s.CellZ, Direction = s.Direction, RemainingTicks = s.RemainingTicks, ConveyorResId = s.ConveyorResId, ConveyorCount = s.ConveyorCount, HP = s.HP, }; } }