Skip to content

Commit

Permalink
Merge pull request #55 from martindevans/fix_query_world_mismatch
Browse files Browse the repository at this point in the history
Partial Fix For Source Generated Queries
  • Loading branch information
genaray authored Dec 11, 2023
2 parents 01644ad + 8ded3f7 commit f533a44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Arch.System.SourceGenerator/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ partial class {{queryMethod.ClassName}}{
Exclusive = {{exclusiveTypeArray}}
};

private {{staticModifier}} bool _{{queryMethod.MethodName}}_Initialized;
private {{staticModifier}} World? _{{queryMethod.MethodName}}_Initialized;
private {{staticModifier}} Query _{{queryMethod.MethodName}}_Query;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public {{staticModifier}} void {{queryMethod.MethodName}}Query(World world {{data}}){

if(!_{{queryMethod.MethodName}}_Initialized){
if(!ReferenceEquals(_{{queryMethod.MethodName}}_Initialized, world)) {
_{{queryMethod.MethodName}}_Query = world.Query(in {{queryMethod.MethodName}}_QueryDescription);
_{{queryMethod.MethodName}}_Initialized = true;
_{{queryMethod.MethodName}}_Initialized = world;
}

foreach(ref var chunk in _{{queryMethod.MethodName}}_Query.GetChunkIterator()){
Expand Down

0 comments on commit f533a44

Please sign in to comment.