fix some explosion logic from last commits

This commit is contained in:
bgkillas 2025-02-09 10:09:32 -05:00
parent 2cd5c30857
commit 6de1cd2278
4 changed files with 11 additions and 4 deletions

View file

@ -1,6 +1,7 @@
# List of available hooks: # List of available hooks:
- `ctx.hook.on_world_initialized()` - called on OnWorldInitialized. - `ctx.hook.on_world_initialized()` - called on OnWorldInitialized.
- `ctx.hook.on_new_entity(ent)` - called on new alive entity.
- `ctx.hook.on_world_update()` - called on OnWorldPreUpdate. - `ctx.hook.on_world_update()` - called on OnWorldPreUpdate.
- `ctx.hook.on_world_update_client()` - called on OnWorldPreUpdate, but only on clients. - `ctx.hook.on_world_update_client()` - called on OnWorldPreUpdate, but only on clients.
- `ctx.hook.on_world_update_host()` - called on OnWorldPreUpdate, but only on host. - `ctx.hook.on_world_update_host()` - called on OnWorldPreUpdate, but only on host.
@ -11,4 +12,4 @@
- `ctx.hook.on_draw_debug_window(imgui)` - `ctx.hook.on_draw_debug_window(imgui)`
- `ctx.hook.on_local_player_polymorphed(currently_polymorphed)` - `ctx.hook.on_local_player_polymorphed(currently_polymorphed)`
- `ctx.hook.on_client_polymorphed(peer_id, player_data)` - `ctx.hook.on_client_polymorphed(peer_id, player_data)`
- `ctx.hook.on_late_init()` - called on OnModPostInit. - `ctx.hook.on_late_init()` - called on OnModPostInit.

View file

@ -166,9 +166,11 @@ end
local exists local exists
local new_ents = {}
function mod.on_new_entity(ent) function mod.on_new_entity(ent)
if ctx.is_host then if ctx.is_host then
update(ent, 1) table.insert(new_ents, ent)
end end
end end
@ -226,6 +228,10 @@ function mod.on_world_pre_update()
count2 = count2 - update(ent, count2) count2 = count2 - update(ent, count2)
end end
end end
for _, ent in ipairs(new_ents) do
update(ent, 1)
end
new_ents = {}
if exists then if exists then
net.proxy_send("flush_exp", "") net.proxy_send("flush_exp", "")
exists = nil exists = nil

View file

@ -146,4 +146,4 @@ function tele.on_world_update()
end end
end end
return tele return tele

View file

@ -677,4 +677,4 @@ end
function OnPlayerDied(player_entity) function OnPlayerDied(player_entity)
ctx.hook.on_player_died(player_entity) ctx.hook.on_player_died(player_entity)
print("player died") print("player died")
end end