mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-11-03 18:39:19 +00:00 
			
		
		
		
	docs(api): consolidate and clarify contains method documentation (#264)
Remove duplicate contains method section and update description to be more precise about checking both entities and components. Also fix example code references to use contains instead of has for consistency.
This commit is contained in:
		
							parent
							
								
									1d650d12e9
								
							
						
					
					
						commit
						f031dcee8d
					
				
					 1 changed files with 4 additions and 41 deletions
				
			
		| 
						 | 
					@ -355,46 +355,9 @@ This operation is the same as calling:
 | 
				
			||||||
world:target(entity, jecs.ChildOf, 0)
 | 
					world:target(entity, jecs.ChildOf, 0)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## contains
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Checks if an entity or component (id) exists in the world.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```luau
 | 
					 | 
				
			||||||
function World:contains(
 | 
					 | 
				
			||||||
    entity: Entity,
 | 
					 | 
				
			||||||
): boolean
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Example:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
::: code-group
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```luau [luau]
 | 
					 | 
				
			||||||
local entity = world:entity()
 | 
					 | 
				
			||||||
print(world:contains(entity))
 | 
					 | 
				
			||||||
print(world:contains(1))
 | 
					 | 
				
			||||||
print(world:contains(2))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-- Outputs:
 | 
					 | 
				
			||||||
-- true
 | 
					 | 
				
			||||||
-- true
 | 
					 | 
				
			||||||
-- false
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```ts [typescript]
 | 
					 | 
				
			||||||
const entity = world.entity();
 | 
					 | 
				
			||||||
print(world.contains(entity));
 | 
					 | 
				
			||||||
print(world.contains(1));
 | 
					 | 
				
			||||||
print(world.contains(2));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Outputs:
 | 
					 | 
				
			||||||
// true
 | 
					 | 
				
			||||||
// true
 | 
					 | 
				
			||||||
// false
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
:::
 | 
					:::
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## remove
 | 
					## remove
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Removes a component (ID) from an entity
 | 
					Removes a component (ID) from an entity
 | 
				
			||||||
| 
						 | 
					@ -460,11 +423,11 @@ Example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```luau [luau]
 | 
					```luau [luau]
 | 
				
			||||||
local entity = world:entity()
 | 
					local entity = world:entity()
 | 
				
			||||||
print(world:has(entity))
 | 
					print(world:contains(entity))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
world:delete(entity)
 | 
					world:delete(entity)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
print(world:has(entity))
 | 
					print(world:contains(entity))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Outputs:
 | 
					-- Outputs:
 | 
				
			||||||
-- true
 | 
					-- true
 | 
				
			||||||
| 
						 | 
					@ -601,7 +564,7 @@ print(retrievedParent === parent) // true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## contains
 | 
					## contains
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Checks if an entity exists and is alive in the world.
 | 
					Checks if an entity or component (id) exists and is alive in the world.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```luau
 | 
					```luau
 | 
				
			||||||
function World:contains(
 | 
					function World:contains(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue