Skip to content

Commit

Permalink
resource arrivals sync
Browse files Browse the repository at this point in the history
  • Loading branch information
aymericdelab committed Dec 17, 2024
1 parent 4fddc1a commit 080f8ce
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions client/src/dojo/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,57 @@ export const addMarketSubscription = async <S extends Schema>(
const end = performance.now();
console.log("MarketEnd", end - start);
};

export const addArrivalsSubscription = async <S extends Schema>(
entityIds: number[],
client: ToriiClient,
components: Component<S, Metadata, undefined>[],
) => {
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);
};

0 comments on commit 080f8ce

Please sign in to comment.