# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 TheBorzoiMustConsume <197824988+TheBorzoiMustConsume@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: htnCompound
  id: XenoSlimeCompound
  branches:
  - tasks:
    - !type:HTNCompoundTask
      task: XenoSlimeFoodCompound
  - tasks:
    - !type:HTNCompoundTask
      task: LatchCompound
  - tasks:
    - !type:HTNCompoundTask
      task: IdleCompound

- type: htnCompound
  id: XenoSlimeFoodCompound
  branches:
  - tasks:
    - !type:HTNPrimitiveTask
      operator: !type:UtilityOperator
        proto: NearbyFood
    - !type:HTNPrimitiveTask
      operator: !type:MoveToOperator
        pathfindInPlanning: true
        removeKeyOnFinish: false
        targetKey: TargetCoordinates
        pathfindKey: TargetPathfind
        rangeKey: MeleeRange
    - !type:HTNPrimitiveTask
      preconditions:
      - !type:KeyExistsPrecondition
        key: Target
      operator: !type:AltInteractOperator
    - !type:HTNPrimitiveTask
      preconditions:
      - !type:KeyExistsPrecondition
        key: IdleTime
      operator: !type:WaitOperator
        key: IdleTime

- type: htnCompound
  id: LatchCompound
  branches:
  - tasks:
    - !type:HTNPrimitiveTask
      operator: !type:PickSlimeLatchTargetOperator
        targetKey: MovementTarget
        latchKey: LatchTarget
        rangeKey: IdleRange
    - !type:HTNPrimitiveTask
      operator: !type:MoveToOperator
        pathfindInPlanning: false
        targetKey: MovementTarget
        rangeKey: MeleeRange
    - !type:HTNPrimitiveTask
      operator: !type:SlimeLatchOperator
        latchKey: LatchTarget
    - !type:HTNPrimitiveTask
      preconditions:
      - !type:KeyExistsPrecondition
        key: IdleTime
      operator: !type:WaitOperator
        key: IdleTime
