Hack around spells falling through ground sometimes

This commit is contained in:
IQuant 2024-08-30 11:52:37 +03:00
parent b4eb3e762b
commit ed9438fcd3
2 changed files with 23 additions and 4 deletions

View file

@ -5,12 +5,11 @@ if load_imgui == nil then
return {}
end
imgui = load_imgui({version="1.20.0", mod="Entangled Worlds Debug Mode"})
imgui = load_imgui({ version = "1.20.0", mod = "Entangled Worlds Debug Mode" })
local module = {}
function module.on_local_player_spawn(my_player)
local player_entity = my_player.entity
-- EntitySetTransform(player_entity, 1333, 770)
@ -30,7 +29,6 @@ function module.on_local_player_spawn(my_player)
-- perk_spawn(x-50, y, "GLASS_CANNON", true)
-- perk_spawn(x-25, y, "EDIT_WANDS_EVERYWHERE", true)
-- EntityLoad("data/entities/items/pickup/heart.xml", x-75, y-20)
end
function module.on_world_update_host()
@ -87,7 +85,7 @@ function module.on_world_update_post()
end
if imgui.CollapsingHeader("Teleports") then
tp_button("Starting area", 0, -100)
tp_button("Vault", 0, 8600-20)
tp_button("Vault", 0, 8600 - 20)
tp_button("Portal to lab", 350.332, 12852.998)
tp_button("Kolmi room", 3400, 13040)
tp_button("The Work", 6300, 15155)
@ -99,6 +97,7 @@ function module.on_world_update_post()
tp_button("Tree", -1901.962, -1405.003)
tp_button("Essence - Laser", 16000, -1800.003)
tp_button("Essence - Eater", 12620.563, -141.003)
tp_button("Mines HM", -200, 1390)
end
if imgui.CollapsingHeader("Game effects") then
show_game_effects()

View file

@ -265,6 +265,24 @@ local function add_stuff_to_globalized_item(item, gid)
ctx.item_prevent_localize[gid] = false
end
local function maybe_disable_physics(item_new)
local x, y = EntityGetTransform(item_new)
-- Disable physics if world doesn't exist yet, so the item doesn't fall off.
if not DoesWorldExistAt(x - 5, y - 5, x + 5, y + 5) then
async(function()
wait(1)
local simple_physics_component = EntityGetFirstComponent(item_new, "SimplePhysicsComponent")
if simple_physics_component ~= nil and simple_physics_component ~= 0 then
EntitySetComponentIsEnabled(item_new, simple_physics_component, false)
end
local velocity = EntityGetFirstComponent(item_new, "VelocityComponent")
if velocity ~= nil and velocity ~= 0 then
EntitySetComponentIsEnabled(item_new, velocity, false)
end
end)
end
end
rpc.opts_reliable()
function rpc.initial_items(item_list)
-- Only run once ever, as it tends to duplicate items otherwise
@ -277,6 +295,7 @@ function rpc.initial_items(item_list)
if item == nil then
local item_new = inventory_helper.deserialize_single_item(item_data)
add_stuff_to_globalized_item(item_new, item_data.gid)
maybe_disable_physics(item_new)
end
end
end
@ -288,6 +307,7 @@ function rpc.item_globalize(item_data)
end
local item = inventory_helper.deserialize_single_item(item_data)
add_stuff_to_globalized_item(item, item_data.gid)
maybe_disable_physics(item)
end
rpc.opts_reliable()