File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1744,4 +1744,31 @@ public Signature GetSignature(Entity entity)
17441744 }
17451745}
17461746
1747+ public partial class World
1748+ {
1749+ /// <summary>
1750+ /// Creates a deep copy of the world, copying archetypes and chunks.
1751+ /// </summary>
1752+ /// <returns>A newly created World with all data copied from the original.</returns>
1753+ public World Copy ( )
1754+ {
1755+ var copy = Create ( ) ;
1756+ var archetypes = Archetypes . Items ;
1757+ for ( var index = 0 ; index < archetypes . Count ; index ++ )
1758+ {
1759+ var archetype = archetypes [ index ] ;
1760+ if ( archetype . EntityCount <= 0 )
1761+ {
1762+ continue ;
1763+ }
1764+
1765+ var newArchetype = GetOrCreate ( archetype . Signature ) ;
1766+ Archetype . Copy ( archetype , newArchetype ) ;
1767+ copy . Archetypes . Add ( newArchetype ) ;
1768+ }
1769+
1770+ return copy ;
1771+ }
1772+ }
1773+
17471774#endregion
You can’t perform that action at this time.
0 commit comments