mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-10-31 17:20:32 +00:00 
			
		
		
		
	Merge upstream changes
This commit is contained in:
		
							parent
							
								
									f063a5cf24
								
							
						
					
					
						commit
						cf694bddd1
					
				
					 2 changed files with 8 additions and 4 deletions
				
			
		|  | @ -469,14 +469,17 @@ function World.set(world: World, entityId: i53, componentId: i53, data: unknown) | ||||||
| 	to.columns[archetypeRecord][record.row] = data | 	to.columns[archetypeRecord][record.row] = data | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| local function archetypeTraverseRemove(world: World, componentId: i53, archetype: Archetype?): Archetype | local function archetypeTraverseRemove(world: World, componentId: i53, from: Archetype): Archetype | ||||||
| 	local from = (archetype or world.ROOT_ARCHETYPE) :: Archetype |  | ||||||
| 	local edge = ensureEdge(from, componentId) | 	local edge = ensureEdge(from, componentId) | ||||||
| 
 | 
 | ||||||
| 	local remove = edge.remove | 	local remove = edge.remove | ||||||
| 	if not remove then | 	if not remove then | ||||||
| 		local to = table.clone(from.types) | 		local to = table.clone(from.types) | ||||||
| 		table.remove(to, table.find(to, componentId)) | 		local at = table.find(to, componentId) | ||||||
|  | 		if not at then  | ||||||
|  | 			return from | ||||||
|  | 		end | ||||||
|  | 		table.remove(to, at) | ||||||
| 		remove = ensureArchetype(world, to, from) | 		remove = ensureArchetype(world, to, from) | ||||||
| 		edge.remove = remove :: never | 		edge.remove = remove :: never | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
|  | @ -160,7 +160,7 @@ TEST("world", function() | ||||||
| 
 | 
 | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     do CASE "show allow remove that doesn't exist on entity"  |     do CASE "should allow remove that doesn't exist on entity"  | ||||||
|         local world = jecs.World.new() |         local world = jecs.World.new() | ||||||
| 
 | 
 | ||||||
|         local Health = world:entity() |         local Health = world:entity() | ||||||
|  | @ -171,6 +171,7 @@ TEST("world", function() | ||||||
|         world:remove(id, Poison) |         world:remove(id, Poison) | ||||||
| 
 | 
 | ||||||
|         CHECK(world:get(id, Poison) == nil) |         CHECK(world:get(id, Poison) == nil) | ||||||
|  |         print(world:get(id, Health)) | ||||||
|         CHECK(world:get(id, Health) == 50) |         CHECK(world:get(id, Health) == 50) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue