11import type { EntityId , RelationId , WildcardRelationId } from "./entity" ;
22import {
3- decodeRelationId ,
3+ getComponentIdFromRelationId ,
44 getDetailedIdType ,
55 getIdType ,
6+ getTargetIdFromRelationId ,
67 isDontFragmentComponent ,
78 isWildcardRelationId ,
89} from "./entity" ;
@@ -278,8 +279,7 @@ export class Archetype {
278279 }
279280
280281 if ( isWildcardRelationId ( componentType ) ) {
281- const decoded = decodeRelationId ( componentType ) ;
282- const componentId = decoded . componentId ;
282+ const componentId = getComponentIdFromRelationId ( componentType ) ;
283283 const relations : [ EntityId < unknown > , any ] [ ] = [ ] ;
284284
285285 // Check regular archetype components
@@ -507,14 +507,13 @@ export class Archetype {
507507 for ( const relType of matchingRelations ) {
508508 const dataArray = this . getComponentData ( relType ) ;
509509 const data = dataArray [ entityIndex ] ;
510- const decodedRel = decodeRelationId ( relType as RelationId < any > ) ;
511- relations . push ( [ decodedRel . targetId , data === MISSING_COMPONENT ? undefined : data ] ) ;
510+ const targetId = getTargetIdFromRelationId ( relType ) ! ;
511+ relations . push ( [ targetId , data === MISSING_COMPONENT ? undefined : data ] ) ;
512512 }
513513
514514 // Add dontFragment relations for this entity
515515 // Get the component ID from the wildcard relation type
516- const wildcardDecoded = decodeRelationId ( wildcardRelationType ) ;
517- const targetComponentId = wildcardDecoded . componentId ;
516+ const targetComponentId = getComponentIdFromRelationId ( wildcardRelationType ) ;
518517
519518 const dontFragmentData = this . dontFragmentRelations . get ( entityId ) ;
520519 if ( dontFragmentData ) {
@@ -533,9 +532,9 @@ export class Archetype {
533532 // If no relations found and not optional, this entity doesn't match
534533 if ( relations . length === 0 ) {
535534 if ( ! optional ) {
536- const wildcardDecoded = decodeRelationId ( wildcardRelationType ) ;
535+ const componentId = getComponentIdFromRelationId ( wildcardRelationType ) ;
537536 throw new Error (
538- `No matching relations found for mandatory wildcard relation component ${ wildcardDecoded . componentId } on entity ${ entityId } ` ,
537+ `No matching relations found for mandatory wildcard relation component ${ componentId } on entity ${ entityId } ` ,
539538 ) ;
540539 }
541540 // For optional, return undefined when there are no relations
0 commit comments