mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-11-04 10:59:18 +00:00 
			
		
		
		
	Fix entity lookup
This commit is contained in:
		
							parent
							
								
									06aba5548f
								
							
						
					
					
						commit
						6ebac90fd9
					
				
					 1 changed files with 11 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -5,15 +5,19 @@ local collect = require("../collect")
 | 
			
		|||
local client_ids = {}
 | 
			
		||||
 | 
			
		||||
local function ecs_map_get(world: types.World, id: types.Entity)
 | 
			
		||||
	local deserialised_id = 0
 | 
			
		||||
 | 
			
		||||
	if not world:exists(id) or not world:contains(id) then
 | 
			
		||||
	local deserialised_id = client_ids[id]
 | 
			
		||||
	if not deserialised_id then
 | 
			
		||||
		if world:has(id, jecs.Name) then
 | 
			
		||||
			deserialised_id = world:entity(id)
 | 
			
		||||
		client_ids[id] = deserialised_id
 | 
			
		||||
		else
 | 
			
		||||
		deserialised_id = client_ids[id]
 | 
			
		||||
			if world:exists(id) then
 | 
			
		||||
				deserialised_id = world:entity()
 | 
			
		||||
			else
 | 
			
		||||
				deserialised_id = world:entity(id)
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		client_ids[id] = deserialised_id
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	return deserialised_id
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue