Merge branch 'dev' into pathfinding-update

This commit is contained in:
MihailRis 2026-11-01 18:37:28 +03:00
commit 98cd85f4f6
16 changed files with 124 additions and 17 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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