- Read-Only: Never modify game state
- Real-Time: Reflect current world state
- Flexible: Support complex filtering and searching
- Efficient: Optimized for fast data retrieval
Basic Query
Query Structure
Queries consist of three main parts:Find
Specify which components to search for:- Component Names: List of component types to match
- Case Sensitive: Component names must match exactly
Match
How to match components:- “exact”: Entity must have exactly these components
- “contains”: Entity must have at least these components
Match Type: Contains
Returns entities that contain at least the specified components (they may have additional components):Match Type: Contains
- Entity with
[PlayerTag, Position, Health]
→ ✅ Match - Entity with
[PlayerTag, Position]
→ ✅ Match - Entity with
[PlayerTag]
→ ❌ No match
Match Type: Exact
Returns entities that contain exactly the specified components (no more, no less):Match Type: Exact
- Entity with
[PlayerTag, Position, Health]
→ ❌ No match - Entity with
[PlayerTag, Position]
→ ✅ Match - Entity with
[PlayerTag]
→ ❌ No match
ECS Concept: These match types reflect Entity Component System (ECS) patterns.
contains
is
useful for finding entities by their capabilities, while exact
is useful for finding entities
with a specific component combination.Where Clause (Optional)
Filter results using expression language. Thewhere
field uses the
Expr expression language, which provides:
- Comparison operators:
==
,!=
,<
,<=
,>
,>=
- Logical operators:
&&
,||
,!
- Membership testing:
in
,not in
- Built-in functions:
len()
,all()
,any()
,filter()
,map()
- Comparisons:
Health.HP > 100
- Logic:
PlayerTag.Level >= 10 && Health.HP > 50
- String Operations:
PlayerTag.Nickname contains "admin"
Where Clause Examples
By Online Status
By Name
By Nickname
By Online Status and Position
By PlayerTag ID
By Nickname Length and Position