@@ -13,18 +13,18 @@ public sealed partial class World
1313 /// </summary>
1414 /// <param name="maxComponentId"></param>
1515 public World ( ulong maxComponentId = 256 )
16- {
17- _comparer = new ComponentComparer ( this ) ;
18- _archRoot = new Archetype (
19- this ,
20- [ ] ,
21- _comparer
22- ) ;
16+ {
17+ _comparer = new ComponentComparer ( this ) ;
18+ _archRoot = new Archetype (
19+ this ,
20+ [ ] ,
21+ _comparer
22+ ) ;
2323 _typeIndex . Add ( _archRoot . Id , _archRoot ) ;
2424 LastArchetypeId = _archRoot . Id ;
2525
2626 _maxCmpId = maxComponentId ;
27- _entities . MaxID = maxComponentId ;
27+ _entities . MaxID = maxComponentId ;
2828
2929#if USE_PAIR
3030 _ = Component < Rule > ( ) ;
@@ -69,7 +69,7 @@ static EntityView setCommon(EntityView entity, string name)
6969 NamingEntityMapper = new ( this ) ;
7070
7171 OnPluginInitialization ? . Invoke ( this ) ;
72- }
72+ }
7373
7474
7575
@@ -92,10 +92,10 @@ static EntityView setCommon(EntityView entity, string name)
9292 /// Cleanup the world.
9393 /// </summary>
9494 public void Dispose ( )
95- {
96- _entities . Clear ( ) ;
97- _archRoot . Clear ( ) ;
98- _typeIndex . Clear ( ) ;
95+ {
96+ _entities . Clear ( ) ;
97+ _archRoot . Clear ( ) ;
98+ _typeIndex . Clear ( ) ;
9999 _cachedComponents . Clear ( ) ;
100100 RelationshipEntityMapper . Clear ( ) ;
101101 NamingEntityMapper . Clear ( ) ;
@@ -127,7 +127,9 @@ public Archetype Archetype(params Span<ComponentInfo> ids)
127127
128128 ids . SortNoAlloc ( _comparisonCmps ) ;
129129
130- var hash = RollingHash . Calculate ( ids ) ;
130+ var hash = 0ul ;
131+ foreach ( ref readonly var cmp in ids )
132+ hash = UnorderedSetHasher . Combine ( hash , cmp . ID ) ;
131133 if ( ! _typeIndex . TryGetValue ( hash , out var archetype ) )
132134 {
133135 var archLessOne = Archetype ( ids [ ..^ 1 ] ) ;
@@ -164,7 +166,7 @@ public EntityView Entity(Archetype arch)
164166 /// </summary>
165167 /// <param name="id"></param>
166168 /// <returns></returns>
167- public EntityView Entity ( ulong id = 0 )
169+ public EntityView Entity ( ulong id = 0 )
168170 {
169171 lock ( _newEntLock )
170172 {
@@ -243,8 +245,8 @@ public EntityView Entity(string name)
243245 /// Associated children are deleted too.
244246 /// </summary>
245247 /// <param name="entity"></param>
246- public void Delete ( EcsID entity )
247- {
248+ public void Delete ( EcsID entity )
249+ {
248250 if ( IsDeferred )
249251 {
250252 if ( Exists ( entity ) )
@@ -314,15 +316,15 @@ static void applyDeleteRules(World world, EcsID entity, params Span<IQueryTerm>
314316 EcsAssert . Assert ( removedId == entity ) ;
315317 _entities . Remove ( removedId ) ;
316318 }
317- }
319+ }
318320
319321 /// <summary>
320322 /// Check if the entity is valid and alive.
321323 /// </summary>
322324 /// <param name="entity"></param>
323325 /// <returns></returns>
324- public bool Exists ( EcsID entity )
325- {
326+ public bool Exists ( EcsID entity )
327+ {
326328#if USE_PAIR
327329 if ( entity . IsPair ( ) )
328330 {
@@ -331,8 +333,8 @@ public bool Exists(EcsID entity)
331333 }
332334#endif
333335
334- return _entities . Contains ( entity ) ;
335- }
336+ return _entities . Contains ( entity ) ;
337+ }
336338
337339 /// <summary>
338340 /// Use this function to analyze pairs members.<br/>
@@ -363,21 +365,21 @@ public EcsID GetAlive(EcsID id)
363365 /// </summary>
364366 /// <param name="id"></param>
365367 /// <returns></returns>
366- public ReadOnlySpan < ComponentInfo > GetType ( EcsID id )
367- {
368- ref var record = ref GetRecord ( id ) ;
369- return record . Archetype . All . AsSpan ( ) ;
370- }
368+ public ReadOnlySpan < ComponentInfo > GetType ( EcsID id )
369+ {
370+ ref var record = ref GetRecord ( id ) ;
371+ return record . Archetype . All . AsSpan ( ) ;
372+ }
371373
372374 /// <summary>
373375 /// Add a Tag to the entity.
374376 /// </summary>
375377 /// <typeparam name="T"></typeparam>
376378 /// <param name="entity"></param>
377- public void Add < T > ( EcsID entity ) where T : struct
379+ public void Add < T > ( EcsID entity ) where T : struct
378380 {
379- ref readonly var cmp = ref Component < T > ( ) ;
380- EcsAssert . Panic ( cmp . Size <= 0 , "this is not a tag" ) ;
381+ ref readonly var cmp = ref Component < T > ( ) ;
382+ EcsAssert . Panic ( cmp . Size <= 0 , "this is not a tag" ) ;
381383
382384 if ( IsDeferred && ! Has ( entity , cmp . ID ) )
383385 {
@@ -386,19 +388,19 @@ public void Add<T>(EcsID entity) where T : struct
386388 return ;
387389 }
388390
389- _ = Attach ( entity , cmp . ID , cmp . Size ) ;
390- }
391+ _ = Attach ( entity , cmp . ID , cmp . Size ) ;
392+ }
391393
392394 /// <summary>
393395 /// Set a Component to the entity.
394396 /// </summary>
395397 /// <typeparam name="T"></typeparam>
396398 /// <param name="entity"></param>
397399 /// <param name="component"></param>
398- public void Set < T > ( EcsID entity , T component ) where T : struct
400+ public void Set < T > ( EcsID entity , T component ) where T : struct
399401 {
400402 ref readonly var cmp = ref Component < T > ( ) ;
401- EcsAssert . Panic ( cmp . Size > 0 , "this is not a component" ) ;
403+ EcsAssert . Panic ( cmp . Size > 0 , "this is not a component" ) ;
402404
403405 if ( IsDeferred && ! Has ( entity , cmp . ID ) )
404406 {
@@ -407,9 +409,9 @@ public void Set<T>(EcsID entity, T component) where T : struct
407409 return ;
408410 }
409411
410- ( var raw , var row ) = Attach ( entity , cmp . ID , cmp . Size ) ;
411- var array = ( T [ ] ) raw ! ;
412- array [ row & TinyEcs . Archetype . CHUNK_THRESHOLD ] = component ;
412+ ( var raw , var row ) = Attach ( entity , cmp . ID , cmp . Size ) ;
413+ var array = ( T [ ] ) raw ! ;
414+ array [ row & TinyEcs . Archetype . CHUNK_THRESHOLD ] = component ;
413415 }
414416
415417 /// <summary>
@@ -434,7 +436,7 @@ public void Add(EcsID entity, EcsID id)
434436 /// </summary>
435437 /// <typeparam name="T"></typeparam>
436438 /// <param name="entity"></param>
437- public void Unset < T > ( EcsID entity ) where T : struct
439+ public void Unset < T > ( EcsID entity ) where T : struct
438440 => Unset ( entity , Component < T > ( ) . ID ) ;
439441
440442 /// <summary>
@@ -460,7 +462,7 @@ public void Unset(EcsID entity, EcsID id)
460462 /// <typeparam name="T"></typeparam>
461463 /// <param name="entity"></param>
462464 /// <returns></returns>
463- public bool Has < T > ( EcsID entity ) where T : struct
465+ public bool Has < T > ( EcsID entity ) where T : struct
464466 => Has ( entity , Component < T > ( ) . ID ) ;
465467
466468 /// <summary>
@@ -471,21 +473,21 @@ public bool Has<T>(EcsID entity) where T : struct
471473 /// <param name="id"></param>
472474 /// <returns></returns>
473475 public bool Has ( EcsID entity , EcsID id )
474- {
476+ {
475477 return IsAttached ( ref GetRecord ( entity ) , id ) ;
476- }
478+ }
477479
478480 /// <summary>
479481 /// Get a component from the entity.
480482 /// </summary>
481483 /// <typeparam name="T"></typeparam>
482484 /// <param name="entity"></param>
483485 /// <returns></returns>
484- public ref T Get < T > ( EcsID entity ) where T : struct
486+ public ref T Get < T > ( EcsID entity ) where T : struct
485487 {
486488 ref readonly var cmp = ref Component < T > ( ) ;
487489 return ref GetUntrusted < T > ( entity , cmp . ID , cmp . Size ) ;
488- }
490+ }
489491
490492 /// <summary>
491493 /// Get the name associated to the entity.
@@ -537,9 +539,9 @@ public void Rule(EcsID entity, EcsID ruleId)
537539 /// Print the archetype graph.
538540 /// </summary>
539541 public void PrintGraph ( )
540- {
541- _archRoot . Print ( 0 ) ;
542- }
542+ {
543+ _archRoot . Print ( 0 ) ;
544+ }
543545
544546 /// <summary>
545547 ///
0 commit comments