PrepareTransferTo method to speed up transfers

pull/5/head
cosmonaut 2023-10-12 12:46:25 -07:00
parent 2aa8fc87e7
commit 855b8d6487
1 changed files with 8 additions and 4 deletions

View File

@ -145,6 +145,14 @@ namespace MoonTools.ECS
private Dictionary<int, int> WorldToTransferID = new Dictionary<int, int>();
/// <summary>
/// If you are using the World Transfer feature, call this once after your systems/filters have all been initialized.
/// </summary>
public void PrepareTransferTo(World other)
{
other.FilterStorage.CreateMissingStorages(FilterStorage);
}
// FIXME: there's probably a better way to handle Filters so they are not world-bound
public unsafe void Transfer(World other, Filter filter, Filter otherFilter)
{
@ -152,10 +160,6 @@ namespace MoonTools.ECS
other.ComponentDepot.CreateMissingStorages(ComponentDepot);
other.RelationDepot.CreateMissingStorages(RelationDepot);
// FIXME: we could just do this once on startup
// Could have a PrepareTransfer method or something
other.FilterStorage.CreateMissingStorages(FilterStorage);
// destroy all entities matching the filter
foreach (var entity in otherFilter.Entities)
{