mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-11-04 02:49:18 +00:00 
			
		
		
		
	Union entity types with number
This commit is contained in:
		
							parent
							
								
									46d363ad5f
								
							
						
					
					
						commit
						0fea5a259d
					
				
					 1 changed files with 8 additions and 7 deletions
				
			
		
							
								
								
									
										15
									
								
								jecs.luau
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								jecs.luau
									
									
									
									
									
								
							| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
--!optimize 2
 | 
					--!optimize 2
 | 
				
			||||||
--!native
 | 
					--!native
 | 
				
			||||||
--!strict
 | 
					--!strict
 | 
				
			||||||
| 
						 | 
					@ -825,7 +826,7 @@ local function world_entity(world: ecs_world_t, entity: i53?): i53
 | 
				
			||||||
			return entity
 | 
								return entity
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	return entity_index_new_id(entity_index, entity)
 | 
						return entity_index_new_id(entity_index)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function world_parent(world: ecs_world_t, entity: i53)
 | 
					local function world_parent(world: ecs_world_t, entity: i53)
 | 
				
			||||||
| 
						 | 
					@ -1051,7 +1052,7 @@ local function world_remove(world: ecs_world_t, entity: i53, id: i53)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function archetype_fast_delete_last(columns: { Column }, column_count: number, types: { i53 }, entity: i53)
 | 
					local function archetype_fast_delete_last(columns: { Column }, column_count: number)
 | 
				
			||||||
	for i, column in columns do
 | 
						for i, column in columns do
 | 
				
			||||||
		if column ~= NULL_ARRAY then
 | 
							if column ~= NULL_ARRAY then
 | 
				
			||||||
			column[column_count] = nil
 | 
								column[column_count] = nil
 | 
				
			||||||
| 
						 | 
					@ -1059,7 +1060,7 @@ local function archetype_fast_delete_last(columns: { Column }, column_count: num
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function archetype_fast_delete(columns: { Column }, column_count: number, row, types, entity)
 | 
					local function archetype_fast_delete(columns: { Column }, column_count: number, row: number)
 | 
				
			||||||
	for i, column in columns do
 | 
						for i, column in columns do
 | 
				
			||||||
		if column ~= NULL_ARRAY then
 | 
							if column ~= NULL_ARRAY then
 | 
				
			||||||
			column[row] = column[column_count]
 | 
								column[row] = column[column_count]
 | 
				
			||||||
| 
						 | 
					@ -1101,9 +1102,9 @@ local function archetype_delete(world: ecs_world_t, archetype: ecs_archetype_t,
 | 
				
			||||||
	entities[last] = nil :: any
 | 
						entities[last] = nil :: any
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if row == last then
 | 
						if row == last then
 | 
				
			||||||
		archetype_fast_delete_last(columns, column_count, id_types, delete)
 | 
							archetype_fast_delete_last(columns, column_count)
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		archetype_fast_delete(columns, column_count, row, id_types, delete)
 | 
							archetype_fast_delete(columns, column_count, row)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1409,8 +1410,8 @@ local function world_delete(world: ecs_world_t, entity: i53)
 | 
				
			||||||
				local tr = idr_r_archetype.records[rel]
 | 
									local tr = idr_r_archetype.records[rel]
 | 
				
			||||||
				local tr_count = idr_r_archetype.counts[rel]
 | 
									local tr_count = idr_r_archetype.counts[rel]
 | 
				
			||||||
				local types = idr_r_archetype.types
 | 
									local types = idr_r_archetype.types
 | 
				
			||||||
				for i = tr, tr_count do
 | 
									for i = tr, tr + tr_count - 1 do
 | 
				
			||||||
					ids[types[tr]] = true
 | 
										ids[types[i]] = true
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
				local n = #entities
 | 
									local n = #entities
 | 
				
			||||||
				table.move(entities, 1, n, count + 1, children)
 | 
									table.move(entities, 1, n, count + 1, children)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue