29 lines
		
	
	
		
			813 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
		
		
			
		
	
	
			29 lines
		
	
	
		
			813 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
| 
								 | 
							
								local BuildUtils = {}
							 | 
						||
| 
								 | 
							
								local BusyActorManagerSubSystem = import("BusyActorManagerSubSystem")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								local function BuildBonfire(wco)
							 | 
						||
| 
								 | 
							
								    local sub_system = BusyActorManagerSubSystem.Get(wco)
							 | 
						||
| 
								 | 
							
								    local role = sub_system.current_role
							 | 
						||
| 
								 | 
							
								    local bonfire = sub_system:GetNearestBonfire()
							 | 
						||
| 
								 | 
							
								    local role_pos = role:K2_GetActorLocation()
							 | 
						||
| 
								 | 
							
								    local bonfire_pos = bonfire:K2_GetActorLocation()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    local distance = (role_pos.X - bonfire_pos.X)^2 + (role_pos.Y - bonfire_pos.Y)^2
							 | 
						||
| 
								 | 
							
								    if distance >= 90000 then
							 | 
						||
| 
								 | 
							
								        sub_system:SpawnBonfire(role_pos)
							 | 
						||
| 
								 | 
							
								        return true
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								    return false
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								local build_mapping = {
							 | 
						||
| 
								 | 
							
								    [200001] = BuildBonfire
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								function BuildUtils.Build(wco, item_id)
							 | 
						||
| 
								 | 
							
								    local build_function = build_mapping[item_id]
							 | 
						||
| 
								 | 
							
								    return build_function and build_function(wco) or false
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								return BuildUtils
							 |