from src.repositories.gameWindow.typings import Creature
from ...typings import Context
from .common.vector import VectorTask
from .collectDeadCorpse import CollectDeadCorpseTask
from .walkToCoordinate import WalkToCoordinateTask


class LootCorpseTask(VectorTask):
    """Erst neben die Leiche laufen, dann gezielt looten."""

    def __init__(self, creature: Creature):
        super().__init__()
        self.name = 'lootCorpse'
        self.isRootTask = True
        self.creature = creature

    def onBeforeStart(self, context: Context) -> Context:
        self.tasks = [
            WalkToCoordinateTask(
                self.creature['coordinate'], tolerance=1,
            ).setParentTask(self).setRootTask(self),
            CollectDeadCorpseTask(self.creature).setParentTask(
                self).setRootTask(self),
        ]
        return context
