This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
This provides a deadline queue, where the item is retured at the appropriate | |
tick or soon after if it has already expired. | |
Keys must be unique for the item. (entity.unit_number) | |
Values must be a table. The field "_deadline" is added to the table. | |
Conceptually, this is an infinite series of buckets with each spanning SLICE_TICKS tick. | |
The buckets are processed until empty and expired. Then we advance to the | |
next bucket. The prior buckets are always empty, so they are discarded. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Direct implementation if DeadlineQueue from Lua. | |
''' | |
from game_tick import game | |
import math | |
class DeadlineQueue: | |
def __init__(self, slice_ticks, slice_count): | |
self.SLICE_TICKS = slice_ticks | |
self.SLICE_COUNT = slice_count |