Skip to content

Commit

Permalink
querybuilder - optional support
Browse files Browse the repository at this point in the history
  • Loading branch information
andreakarasho committed May 17, 2024
1 parent 649ee59 commit 42291f3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ public QueryBuilder Without(EcsID id)
return this;
}

public QueryBuilder Optional<T>() where T :struct
=> Optional(_world.Component<T>().ID);

public QueryBuilder Optional(EcsID id)
{
_components.Add(new Term() { ID = id, Op = TermOp.Optional });
return this;
}

public Query Build()
{
var terms = _components.ToImmutableArray();
Expand Down

0 comments on commit 42291f3

Please sign in to comment.