mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59:44 +00:00
Merge branch 'dev' into pathfinding-update
This commit is contained in:
commit
98cd85f4f6
16 changed files with 124 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<panel size='400' color='0' interval='1' context='menu'>
|
||||
<button onclick='menu.page="worlds"'>@Worlds</button>
|
||||
<button id='worlds_btn' onclick='menu.page="worlds"'>@Worlds</button>
|
||||
<button onclick='menu.page="scripts"'>@Scripts</button>
|
||||
<button onclick='menu.page="settings"'>@Settings</button>
|
||||
<button onclick='menu.page="content_menu"'>@Content</button>
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
</textbox>
|
||||
<label>@Seed</label>
|
||||
<textbox id='seed_box' placeholder='-' padding='4'></textbox>
|
||||
<button onclick='save_state() menu.page="generators"' id='generator_btn'>
|
||||
<button id='generator_btn' onclick='save_state() menu.page="generators"'>
|
||||
@World generator
|
||||
</button>
|
||||
<button id='content_btn' onclick='save_state() menu.page="content"'/>
|
||||
<button onclick='create_world()' margin='0,20,0,1'>
|
||||
<button id='create_world_btn' onclick='create_world()' margin='0,20,0,1'>
|
||||
@Create World
|
||||
</button>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<button onclick='gui.close_menu()'>@Continue</button>
|
||||
<button onclick='menu.page="content?mode=world"'>@Content</button>
|
||||
<button onclick='menu.page="settings"'>@Settings</button>
|
||||
<button onclick='app.close_world(true)'>
|
||||
<button id='quit_btn' onclick='app.close_world(true)'>
|
||||
@Save and Quit to Menu
|
||||
</button>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<panel size='400' color='0' interval='1' context='menu'>
|
||||
<button onclick='menu.page="new_world"'>@New World</button>
|
||||
<button id="new_world_btn" onclick='menu.page="new_world"'>@New World</button>
|
||||
|
||||
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -47,6 +47,25 @@ function next_waypoint()
|
|||
return route[#route]
|
||||
end
|
||||
|
||||
local function is_passed(waypoint, next_point, pos)
|
||||
local wx, wz = waypoint[1] + 0.5, waypoint[3] + 0.5
|
||||
local dx, dz = pos[1] - wx, pos[3] - wz
|
||||
if dx * dx + dz * dz > 2.25 then
|
||||
return false
|
||||
end
|
||||
return dx * (next_point[1] + 0.5 - wx) + dz * (next_point[3] + 0.5 - wz) > 0
|
||||
end
|
||||
|
||||
local function drop_passed_waypoints(new_route)
|
||||
table.remove(new_route, #new_route)
|
||||
local pos = tsf:get_pos()
|
||||
while #new_route >= 2 and
|
||||
is_passed(new_route[#new_route], new_route[#new_route - 1], pos) do
|
||||
table.remove(new_route, #new_route)
|
||||
end
|
||||
return new_route
|
||||
end
|
||||
|
||||
local refresh_internal = 100
|
||||
local frameid = math.random(0, refresh_internal)
|
||||
|
||||
|
|
@ -66,7 +85,7 @@ function on_update()
|
|||
else
|
||||
local new_route = pathfinding.pull_route(agent)
|
||||
if new_route then
|
||||
route = new_route
|
||||
route = drop_passed_waypoints(new_route)
|
||||
started = false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue