mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
fix player when polied into phys object, fix throwing potion mimic
This commit is contained in:
parent
65714117b2
commit
8ada6ab75d
4 changed files with 23 additions and 9 deletions
|
@ -285,6 +285,9 @@ local function pickup_item(entity, item)
|
|||
if entity_children ~= nil then
|
||||
for _, child in pairs( entity_children ) do
|
||||
if EntityGetName( child ) == "inventory_quick" then
|
||||
if EntityGetParent(item) ~= 0 then
|
||||
EntityRemoveFromParent(item)
|
||||
end
|
||||
EntityAddChild( child, item)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -483,13 +483,12 @@ function player_fns.deserialize_position(message, phys_infos, phys_infos_2, play
|
|||
|
||||
ComponentSetValue2(velocity_comp, "gravity_y", 0)
|
||||
|
||||
ComponentSetValue2(character_data, "mVelocity", message.vel_x, message.vel_y)
|
||||
|
||||
EntityApplyTransform(entity, message.x, message.y)
|
||||
local had_phys = false
|
||||
for i, phys_component in ipairs(EntityGetComponent(entity, "PhysicsBodyComponent") or {}) do
|
||||
local phys_info = phys_infos[i]
|
||||
if phys_component ~= nil and phys_component ~= 0 and phys_info ~= nil then
|
||||
deserialize_phys_component(phys_component, phys_info)
|
||||
had_phys = true
|
||||
end
|
||||
end
|
||||
for i, phys_component in ipairs(EntityGetComponent(entity, "PhysicsBody2Component") or {}) do
|
||||
|
@ -499,9 +498,14 @@ function player_fns.deserialize_position(message, phys_infos, phys_infos_2, play
|
|||
local initialized = ComponentGetValue2(phys_component, "mInitialized")
|
||||
if initialized then
|
||||
deserialize_phys_component(phys_component, phys_info)
|
||||
had_phys = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not had_phys then
|
||||
ComponentSetValue2(character_data, "mVelocity", message.vel_x, message.vel_y)
|
||||
EntityApplyTransform(entity, message.x, message.y)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
function throw_item()
|
||||
CrossCall("ew_potion_mimic_throw", GetUpdatedEntityID())
|
||||
function throw_item(xi, yi, xf, yf)
|
||||
local dx = xf - xi
|
||||
local dy = yf - yi
|
||||
CrossCall("ew_potion_mimic_throw", GetUpdatedEntityID(), dx / 8, dy / 8)
|
||||
end
|
||||
|
||||
function item_pickup()
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
local rpc = net.new_rpc_namespace()
|
||||
local potion = {}
|
||||
|
||||
function rpc.got_thrown(peer_id)
|
||||
function rpc.got_thrown(peer_id, vx, vy)
|
||||
local item = ctx.players[peer_id].entity
|
||||
for _, com in ipairs(EntityGetAllComponents(item) or {}) do
|
||||
EntitySetComponentIsEnabled(item, com, true)
|
||||
end
|
||||
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "SpriteComponent", "enable_in_hand"), false)
|
||||
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "SpriteComponent", "enabled_in_hand"), false)
|
||||
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "ItemChestComponent"), false)
|
||||
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "ItemComponent"), false)
|
||||
if EntityGetParent(item) ~= 0 then
|
||||
EntityRemoveFromParent(item)
|
||||
end
|
||||
if peer_id == ctx.my_player.peer_id then
|
||||
local phys_component = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "PhysicsBodyComponent")
|
||||
local px, py, pr, pvx, pvy, pvr = np.PhysBodyGetTransform(phys_component)
|
||||
np.PhysBodySetTransform(phys_component, px, py, pr, pvx + vx, pvy + vy, pvr)
|
||||
end
|
||||
end
|
||||
|
||||
np.CrossCallAdd("ew_potion_mimic_throw", function(item)
|
||||
rpc.got_thrown(player_fns.get_player_data_by_local_entity_id(item).peer_id)
|
||||
np.CrossCallAdd("ew_potion_mimic_throw", function(item, vx, vy)
|
||||
rpc.got_thrown(player_fns.get_player_data_by_local_entity_id(item).peer_id, vx, vy)
|
||||
end)
|
||||
|
||||
np.CrossCallAdd("ew_potion_mimic_pickup", function()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue