Unity Plugin (UP) & API
Delays & Queues
In many games, producing, consuming, and trading resources takes time. The time it requires to complete an action might be crucial for the game balance – think about all the games out there with a time-based economy.
Same Node, 2 functions
In a Machinations diagram, use a Delay Node to delay the flow of Resources as they get distributed in your diagram.
A Delay is represented by a small circle with an hourglass inside.
The Formula on the Delay’s output connection indicates how many time steps a Resource is delayed.
Note that this is different from most Formulas on Resource Connections, which ordinarily represent a flow rate.
This time is dynamic, it can be change by other elements in the diagram via Formula Modifiers.
🔧 In the Delay example below, play the diagram Step by Step. Notice the counter in the play bar (next to the Reset Button) and the flow of the Soldiers Resource. It is delayed by 5 Steps.
Here’s the step by step rundown:
Step 1: Three Gold are converted into a Soldier & sent to Delay
Step 2: First Soldier is delayed, and a second one is commissioned
Steps 3 – 6: both Soldiers are delayed
Step 7: First Soldier is pushed to the Soldiers Pool, second is delayed still
Step 8: Second Soldier is sent to the Soldiers Pool
A Delay can process multiple Resources simultaneously. This means that all incoming Resources are delayed for the specified number of time steps regardless of the number of Resources currently being delayed.
Other elements in the diagram can change the delay setting through Formula Modifiers.
Or you can specify a random delay time using dice notation.
Delays can be turned into Queues. A Queue has 2 hourglass symbols instead of one.
Queues process only one Resource at a time.
🔧 In the Queue example above, play the diagram (Step by Step). In this case, orders from Build are queued and processed 1 at a time, every 5 Time Steps.
Step by step rundown:
Step 1: Three Gold are converted into a Soldier & sent to Queue
Step 2: Initial Soldier is being Queued for 1 step. Another three Gold are converted into a Soldier & sent to Queue
Step 3-5: the first Soldier is delayed & the second Soldier waits in queue
Step 6: the first Soldier gets pushed to the Soldiers Pool & the second Soldier starts being delayed
Step 6-10: second Soldier is delayed
Step 11: the second Soldier gets pushed to the Soldiers Pool
Delays and Queues can use State Connections that communicate the number of Resources they are currently processing (including the number of Resources waiting in a Queue to be processed).