diff --git a/client/src/dojo/queries.ts b/client/src/dojo/queries.ts index b0334ecad..26d895795 100644 --- a/client/src/dojo/queries.ts +++ b/client/src/dojo/queries.ts @@ -149,3 +149,57 @@ export const addMarketSubscription = async ( const end = performance.now(); console.log("MarketEnd", end - start); }; + +export const addArrivalsSubscription = async ( + entityIds: number[], + client: ToriiClient, + components: Component[], +) => { + const start = performance.now(); + console.log("ArrivalsEnd: starting resource arrivals"); + await getEntities( + client, + { + Composite: { + operator: "And", + clauses: [ + { + Composite: { + operator: "And", + clauses: entityIds.map((id) => ({ + Member: { + model: "s0_eternum-EntityOwner", + member: "entity_owner_id", + operator: "Eq", + value: { Primitive: { U32: id } }, + }, + })), + }, + }, + { + Member: { + model: "s0_eternum-OwnedResourcesTracker", + member: "resource_types", + operator: "Neq", + value: { Primitive: { U256: "0" } }, + }, + }, + ], + }, + }, + components, + [], + [ + "s0_eternum-Army", + "s0_eternum-Position", + "s0_eternum-EntityOwner", + "s0_eternum-Weight", + "s0_eternum-OwnedResourcesTracker", + "s0_eternum-ArrivalTime", + ], + 1000, + false, + ); + const end = performance.now(); + console.log("ArrivalsEnd", end - start); +};