Allow queuing villagers with more complex tasks
For instance, queuing a villager to build several buildings in a row is now possible. Also adds a task queue for villagers. Any idle villager will automatically grab the first task in the queue. The task queue is used to implement the more complex initial villager tasks, so it is possible that a different villager will do later tasks in the queued villager's chain of tasks, but only if there are already idle villagers. As long as the user does not wish to leave villagers idle for a long time, this should not affect accuracy too badly.
This commit is contained in:
@@ -64,8 +64,16 @@ class Gameplay():
|
||||
|
||||
|
||||
def queue_villager(self, action_time, initial_task, **kwargs):
|
||||
'''
|
||||
initial_task can be instance of one of the following:
|
||||
Tasks -- assign this task along with any keyword arguments
|
||||
(Tasks, dict) -- assume the dict contains the keyword arguments
|
||||
List of (Tasks, dict) -- several tasks to complete in order, each with
|
||||
its own keyword arguments
|
||||
'''
|
||||
self._check_time(action_time)
|
||||
initial_task = (initial_task, kwargs)
|
||||
if isinstance(initial_task, Tasks):
|
||||
initial_task = (initial_task, kwargs)
|
||||
self.actions[action_time].append((self.world.queue_villager,
|
||||
(initial_task,)))
|
||||
|
||||
@@ -97,6 +105,12 @@ class Gameplay():
|
||||
(old_task, new_task, count,)))
|
||||
|
||||
|
||||
def add_task_to_work_queue(self, action_time, task):
|
||||
self._check_time(action_time)
|
||||
self.actions[action_time].append((self.world.add_task_to_work_queue,
|
||||
(task,)))
|
||||
|
||||
|
||||
def get_relic(self, action_time, walking_time=60):
|
||||
self._check_time(action_time)
|
||||
self.actions[action_time].append((self.world.get_relic,
|
||||
|
||||
Reference in New Issue
Block a user