From 7f90a21db1749289ad7a61386a46324fe1837a1c Mon Sep 17 00:00:00 2001 From: IQuant Date: Thu, 22 Aug 2024 17:53:14 +0300 Subject: [PATCH] Fix the weird item duplication thing. --- docs/hooks.md | 1 + quant.ew/files/resource/debug/marker.png | Bin 0 -> 129 bytes quant.ew/files/system/debug.lua | 1 + quant.ew/files/system/item_sync.lua | 21 ++++++++++++++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 quant.ew/files/resource/debug/marker.png diff --git a/docs/hooks.md b/docs/hooks.md index 33c58a95..ce0ab0b2 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -8,4 +8,5 @@ - `ctx.hook.on_local_player_spawn(my_player)` - `ctx.hook.on_client_spawned(peer_id, new_playerdata)` - `ctx.hook.on_should_send_updates()` - called either when we connect, or somebody else connects (and sends "welcome" message) + - `ctx.hook.on_draw_debug_window(imgui)` \ No newline at end of file diff --git a/quant.ew/files/resource/debug/marker.png b/quant.ew/files/resource/debug/marker.png new file mode 100644 index 0000000000000000000000000000000000000000..916685fb440708ec8b866fd971d9f9cb92f52564 GIT binary patch literal 129 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>1|%O$WD@{!3Opi<85s1GL71^(seKtx(Ad+( zF+?IfIYEKRKxy?)eij2eWq}7*`qv1!3hHsrun_h!-Q~p7+v0PmK-!G=$xpu7+ZjdL W)t|;hJW&T~XYh3Ob6Mw<&;$UO;viK3 literal 0 HcmV?d00001 diff --git a/quant.ew/files/system/debug.lua b/quant.ew/files/system/debug.lua index c91b082a..c44c6553 100644 --- a/quant.ew/files/system/debug.lua +++ b/quant.ew/files/system/debug.lua @@ -104,6 +104,7 @@ function module.on_world_update_post() show_game_effects() end -- imgui.Text("lalala") + ctx.hook.on_draw_debug_window(imgui) imgui.End() end end diff --git a/quant.ew/files/system/item_sync.lua b/quant.ew/files/system/item_sync.lua index 6f087fdf..0c046f25 100644 --- a/quant.ew/files/system/item_sync.lua +++ b/quant.ew/files/system/item_sync.lua @@ -120,7 +120,7 @@ function item_sync.make_item_global(item, instant) return end item_sync.ensure_notify_component(item) - local gid_component = EntityGetFirstComponent(item, "VariableStorageComponent", "ew_global_item_id") + local gid_component = EntityGetFirstComponentIncludingDisabled(item, "VariableStorageComponent", "ew_global_item_id") local gid if gid_component == nil then gid = allocate_global_id() @@ -227,6 +227,25 @@ function item_sync.on_should_send_updates() rpc.initial_items(item_list) end +function item_sync.on_draw_debug_window(imgui) + local mx, my = DEBUG_GetMouseWorld() + local ent = EntityGetClosestWithTag(mx, my, "ew_global_item") + if ent ~= nil and ent ~= 0 then + if imgui.CollapsingHeader("Item gid") then + local x, y = EntityGetTransform(ent) + GameCreateSpriteForXFrames("mods/quant.ew/files/resource/debug/marker.png", x, y, true, 0, 0, 1, true) + local gid = item_sync.get_global_item_id(ent) + imgui.Text("GID: "..tostring(gid)) + local prevented = ctx.item_prevent_localize[gid] + if prevented then + imgui.Text("Localize prevented") + else + imgui.Text("Localize allowed") + end + end + end +end + local function add_stuff_to_globalized_item(item, gid) EntityAddTag(item, "ew_global_item") item_sync.ensure_notify_component(item)