mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
add log performance button in proxy ui
This commit is contained in:
parent
0bac664c0f
commit
3beed97f2d
10 changed files with 110 additions and 47 deletions
|
@ -1,40 +1,40 @@
|
|||
dofile_once("data/scripts/lib/utilities.lua")
|
||||
|
||||
local entity_id = GetUpdatedEntityID()
|
||||
local pos_x, pos_y = EntityGetTransform( entity_id )
|
||||
pos_x = pos_x - 5
|
||||
|
||||
local stones = {
|
||||
"data/entities/props/physics_stone_01.xml",
|
||||
"data/entities/props/physics_stone_02.xml",
|
||||
"data/entities/props/physics_stone_03.xml",
|
||||
"data/entities/props/physics_stone_03.xml",
|
||||
"data/entities/props/physics_stone_04.xml",
|
||||
"data/entities/props/physics_stone_04.xml",
|
||||
}
|
||||
|
||||
local props = {
|
||||
"data/entities/props/physics_box_explosive.xml",
|
||||
"data/entities/props/physics_barrel_oil.xml",
|
||||
"data/entities/props/physics_seamine.xml",
|
||||
"data/entities/props/physics/minecart.xml",
|
||||
}
|
||||
|
||||
local count = ProceduralRandomi(pos_x, pos_y, 2, 7)
|
||||
|
||||
if not GameHasFlagRun("ew_flag_this_is_host") then
|
||||
return
|
||||
end
|
||||
|
||||
for i=1,count do
|
||||
local obj
|
||||
local r = ProceduralRandomf(i + pos_x, pos_y + 4)
|
||||
if r > 0.9 then
|
||||
obj = props[ProceduralRandomi(pos_x - 4, pos_y + i, 1, #props)]
|
||||
else
|
||||
obj = stones[ProceduralRandomi(pos_x - 4, pos_y + i, 1, #stones)]
|
||||
end
|
||||
|
||||
EntityLoad(obj, pos_x + r * 8, pos_y)
|
||||
pos_y = pos_y - 5
|
||||
end
|
||||
dofile_once("data/scripts/lib/utilities.lua")
|
||||
|
||||
local entity_id = GetUpdatedEntityID()
|
||||
local pos_x, pos_y = EntityGetTransform(entity_id)
|
||||
pos_x = pos_x - 5
|
||||
|
||||
local stones = {
|
||||
"data/entities/props/physics_stone_01.xml",
|
||||
"data/entities/props/physics_stone_02.xml",
|
||||
"data/entities/props/physics_stone_03.xml",
|
||||
"data/entities/props/physics_stone_03.xml",
|
||||
"data/entities/props/physics_stone_04.xml",
|
||||
"data/entities/props/physics_stone_04.xml",
|
||||
}
|
||||
|
||||
local props = {
|
||||
"data/entities/props/physics_box_explosive.xml",
|
||||
"data/entities/props/physics_barrel_oil.xml",
|
||||
"data/entities/props/physics_seamine.xml",
|
||||
"data/entities/props/physics/minecart.xml",
|
||||
}
|
||||
|
||||
local count = ProceduralRandomi(pos_x, pos_y, 2, 7)
|
||||
|
||||
if not GameHasFlagRun("ew_flag_this_is_host") then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, count do
|
||||
local obj
|
||||
local r = ProceduralRandomf(i + pos_x, pos_y + 4)
|
||||
if r > 0.9 then
|
||||
obj = props[ProceduralRandomi(pos_x - 4, pos_y + i, 1, #props)]
|
||||
else
|
||||
obj = stones[ProceduralRandomi(pos_x - 4, pos_y + i, 1, #stones)]
|
||||
end
|
||||
|
||||
EntityLoad(obj, pos_x + r * 8, pos_y)
|
||||
pos_y = pos_y - 5
|
||||
end
|
||||
|
|
|
@ -288,4 +288,4 @@ for line in string.gmatch(ModTextFileGetContent("mods/quant.ew/files/resource/in
|
|||
module.interned_filename_to_index[line] = #module.interned_index_to_filename
|
||||
end
|
||||
|
||||
return module
|
||||
return module
|
||||
|
|
|
@ -28,11 +28,19 @@ ctx.init = function()
|
|||
ctx.host_frame_num = 0
|
||||
ctx.is_texting = false
|
||||
ctx.stop_cam = false
|
||||
ctx.timings = ""
|
||||
end
|
||||
|
||||
local function is_measure_perf_enabled()
|
||||
-- return ctx.proxy_opt.debug
|
||||
return false
|
||||
return ctx.proxy_opt.log_performance
|
||||
end
|
||||
|
||||
function ctx.finish()
|
||||
if is_measure_perf_enabled() and string.len(ctx.timings) > 1 then
|
||||
print(string.sub(ctx.timings, 1, -2) .. "}")
|
||||
ctx.timings = "{"
|
||||
end
|
||||
end
|
||||
|
||||
function ctx.add_hook(hook_name, system_name, fn)
|
||||
|
@ -45,10 +53,8 @@ function ctx.add_hook(hook_name, system_name, fn)
|
|||
local start_time = GameGetRealWorldTimeSinceStarted()
|
||||
util.tpcall(entry.fn, ...)
|
||||
local end_time = GameGetRealWorldTimeSinceStarted()
|
||||
local delta = (end_time - start_time) * 1000
|
||||
if delta > 0.02 then
|
||||
print("Hook " .. hook_name .. " took " .. delta .. " ms to run for " .. entry.system_name)
|
||||
end
|
||||
local delta = (end_time - start_time) * 1000000
|
||||
ctx.timings = ctx.timings .. entry.system_name .. ":" .. delta .. ","
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -11,6 +11,9 @@ local module = {}
|
|||
EwextSerialize = util.serialize_entity
|
||||
EwextDeserialize = util.deserialize_entity
|
||||
EwextPrintError = util.print_error
|
||||
function EwextPrint(s)
|
||||
print(s)
|
||||
end
|
||||
function EwextAddInitLuaComponent(entity, file)
|
||||
return EntityAddComponent2(entity, "LuaComponent", {
|
||||
script_source_file = file,
|
||||
|
@ -29,6 +32,7 @@ function module.on_world_initialized()
|
|||
local material_list = tonumber(ffi.cast("intptr_t", world_ffi.get_material_ptr(0)))
|
||||
ewext.init_particle_world_state(grid_world, chunk_map, material_list)
|
||||
ewext.module_on_world_init()
|
||||
ewext.set_log(ctx.proxy_opt.log_performance)
|
||||
end
|
||||
|
||||
local function oh_another_world_state(entity)
|
||||
|
|
|
@ -64,7 +64,12 @@ local first = true
|
|||
|
||||
local function hole(item)
|
||||
local ce = EntityGetFirstComponent(item, "CellEaterComponent")
|
||||
if ce == nil or ComponentGetValue2(ce, "only_stain") or ComponentGetValue2(ce, "limited_materials") or EntityGetFirstComponent(item, "PhysicsBodyComponent") ~= nil then
|
||||
if
|
||||
ce == nil
|
||||
or ComponentGetValue2(ce, "only_stain")
|
||||
or ComponentGetValue2(ce, "limited_materials")
|
||||
or EntityGetFirstComponent(item, "PhysicsBodyComponent") ~= nil
|
||||
then
|
||||
return
|
||||
end
|
||||
local r = 0
|
||||
|
|
|
@ -634,6 +634,7 @@ function OnWorldPostUpdate() -- This is called every time the game has finished
|
|||
util.tpcall(on_world_post_update_inner)
|
||||
ctx.events = {}
|
||||
net.proxy_send("flush", "")
|
||||
ctx.finish()
|
||||
end
|
||||
|
||||
function register_localizations(translation_file, clear_count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue