fix item stealing

This commit is contained in:
bgkillas 2024-10-05 12:06:30 -04:00
parent e4ff04dbef
commit fc8ccf42a7
3 changed files with 7 additions and 8 deletions

View file

@ -161,9 +161,9 @@ function inventory_helper.deserialize_single_item(item_data)
ComponentSetValue2(item_cost_component, "cost", item_data.shop_info[1])
ComponentSetValue2(item_cost_component, "stealable", false)
-- Item is stealable
if item_data.shop_info[2] then
inventory_helper.make_item_stealable_later(item)
end
--if item_data.shop_info[2] then
--inventory_helper.make_item_stealable_later(item)
--end
util.ensure_component_present(item, "SpriteComponent", "shop_cost", {

View file

@ -31,10 +31,10 @@ local function run_spawn_fn(fn_name, x, y, ...)
if fn_info == nil then
print("Could find spawn_fn:", fn_name)
end
--Call the function.
local ret = fn_info.fn(x, y, ...)
-- Check what it returns, we might need to sync it to other clients.
if ret == nil then
return
@ -44,7 +44,7 @@ local function run_spawn_fn(fn_name, x, y, ...)
local eid = ret
ctx.cap.item_sync.globalize(eid, true, ctx.rpc_peer_id)
-- Avoid item losing it's cost on host.
inventory_helper.make_item_stealable_later(eid)
--inventory_helper.make_item_stealable_later(eid)
end
end
@ -64,4 +64,4 @@ np.CrossCallAdd("ew_sync_gen", function(fn_name, x, y, ...)
end
end)
return module
return module

View file

@ -179,7 +179,6 @@ local function send_item_positions()
local costcom = EntityGetFirstComponentIncludingDisabled(item, "ItemCostComponent")
local cost = 0
if costcom ~= nil then
ComponentSetValue2(costcom, "stealable", true)
cost = ComponentGetValue2(costcom, "cost")
end
position_data[gid] = {x, y, cost}