resize component storage if necessary
parent
2fc1b68f41
commit
b30d53e71d
|
@ -118,9 +118,18 @@ namespace MoonTools.ECS
|
|||
public override void Serialize(ComponentStorageState serializedComponentStorage)
|
||||
{
|
||||
ReadOnlySpan<byte> entityIDBytes = MemoryMarshal.Cast<int, byte>(new ReadOnlySpan<int>(entityIDs, 0, nextID));
|
||||
|
||||
if (entityIDBytes.Length > serializedComponentStorage.EntityIDs.Length)
|
||||
{
|
||||
Array.Resize(ref serializedComponentStorage.EntityIDs, entityIDBytes.Length);
|
||||
}
|
||||
entityIDBytes.CopyTo(serializedComponentStorage.EntityIDs);
|
||||
|
||||
ReadOnlySpan<byte> componentBytes = MemoryMarshal.Cast<TComponent, byte>(AllComponents());
|
||||
if (componentBytes.Length > serializedComponentStorage.Components.Length)
|
||||
{
|
||||
Array.Resize(ref serializedComponentStorage.Components, componentBytes.Length);
|
||||
}
|
||||
componentBytes.CopyTo(serializedComponentStorage.Components);
|
||||
|
||||
serializedComponentStorage.EntityIdToStorageIndex.Clear();
|
||||
|
|
Loading…
Reference in New Issue