NickA
NickA

Reputation: 443

Is there a way to access how many unique agents a resource unit has interacted with?

How can I access how many unique agents a specific unit of a resource pool has interacted with? For context, I would like to trigger an event when a certain resource unit has interacted with 17 unique agents.

Upvotes: 0

Views: 55

Answers (1)

Emile Zankoul
Emile Zankoul

Reputation: 2213

Start by creating a resource type.

enter image description here

Add a collection to that agent. enter image description here

Then, in the on seize resource pool block, write the following code:

unit.seizedAgents.add(agent);

And then, in the on release field write:

if( unit.seizedAgents.stream().distinct().count() == 17 ) {
  <action >;
}

enter image description here

Of course, make sure to set the resource pool type to the right one.

Upvotes: 2

Related Questions