sync ingestion

This commit is contained in:
bgkillas 2024-11-13 16:56:49 -05:00
parent 38eb84bd28
commit 43c24a8f3d

View file

@ -6,12 +6,16 @@ local rpc = net.new_rpc_namespace()
local module = {} local module = {}
function rpc.send_money(money) function rpc.send_money_and_ingestion(money, ingestion_size)
local entity = ctx.rpc_player_data.entity local entity = ctx.rpc_player_data.entity
local wallet = EntityGetFirstComponentIncludingDisabled(entity, "WalletComponent") local wallet = EntityGetFirstComponentIncludingDisabled(entity, "WalletComponent")
if wallet ~= nil then if wallet ~= nil then
ComponentSetValue2(wallet, "money", money) ComponentSetValue2(wallet, "money", money)
end end
local ingestion = EntityGetFirstComponentIncludingDisabled(entity, "IngestionComponent")
if ingestion ~= nil then
ComponentSetValue2(ingestion, "ingestion_size", ingestion_size)
end
end end
function rpc.player_update(input_data, pos_data, current_slot, team) function rpc.player_update(input_data, pos_data, current_slot, team)
@ -126,8 +130,10 @@ function module.on_world_update()
if GameGetFrameNum() % 60 == 47 then if GameGetFrameNum() % 60 == 47 then
local wallet = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "WalletComponent") local wallet = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "WalletComponent")
if wallet ~= nil then local ingestion = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "IngestionComponent")
rpc.send_money(ComponentGetValue2(wallet, "money")) if wallet ~= nil or ingestion ~= nil then
rpc.send_money_and_ingestion(wallet and ComponentGetValue2(wallet, "money"),
ingestion and ComponentGetValue2(ingestion, "ingestion_size"))
end end
end end
end end