From 855b8d6487128672f26d55349a9cb121e8c76696 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 12 Oct 2023 12:46:25 -0700 Subject: [PATCH] PrepareTransferTo method to speed up transfers --- src/World.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/World.cs b/src/World.cs index a26f243..9c14ad4 100644 --- a/src/World.cs +++ b/src/World.cs @@ -145,6 +145,14 @@ namespace MoonTools.ECS private Dictionary WorldToTransferID = new Dictionary(); + /// + /// If you are using the World Transfer feature, call this once after your systems/filters have all been initialized. + /// + 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) {