//这是一个微调视角直到目标到屏幕中间的节点，可以通用，其他人只需要按以下步骤操作，
//1.复制整个文件，将出入口节点、自定义识别节点、文件名改成自己专属的名字
//2.将自定义识别节点改成自己需要识别的东西
//3.设定custom节点的参数，target一定要指向自定义识别节点
//连接节点的出入口即可正常工作
//开始工作后，节点会使用自定义的识别方式查找目标，然后一点点将目标挪到视野正中间
//节点从Start进入，开始前要保证目标可以被看到
//节点从Exit离开，这里关联下一个阶段的节点
//无法中断循环，需要单独将判断距离在范围内做成custom的recognition节点
{
    //节点出入口
    "_AutoEcoFarmSwipeToTargetStart": {
        "desc": "微调视角直到目标到屏幕中间",
        "next": [
            "_AutoEcoFarmInWorld",
            "[JumpBack]SceneAnyEnterWorld"
        ]
    },
    "_AutoEcoFarmSwipeToTargetExit": {
        "next": [
            "_AutoEcoFarmMoveAndWorkStart"
        ]
    },
    "_AutoEcoFarmTargeRecognition": {
        "desc": "自定义识别节点，按需选择一个合适的方法识别目标",
        "recognition": {
            "type": "TemplateMatch",
            "param": {
                "roi": [
                    171,
                    64,
                    951,
                    563
                ],
                "template": "AutoEcoFarm/AutoEcoFarmFarmlandGAI.png",
                "green_mask": true,
                "method": 5,
                "threshold": 0.4
            }
        },
        "pre_delay": 0,
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmCalculateSwipeTarget"
        ]
    },
    "_AutoEcoFarmTargeInCenter": {
        "desc": "判断目标在视野中央的节点,识别方法同上，但是范围更小",
        "recognition": {
            "type": "TemplateMatch",
            "param": {
                "roi": [
                    620,
                    300,
                    40,
                    100
                ],
                "template": "AutoEcoFarm/AutoEcoFarmFarmland.png",
                "threshold": 0.4
            }
        },
        "pre_delay": 0,
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmSwipeToTargetExit"
        ]
    },
    "_AutoEcoFarmTargeInBack": {
        "desc": "判断目标在视野下方，即背后",
        "recognition": {
            "type": "TemplateMatch",
            "param": {
                "roi": [
                    22,
                    406,
                    1230,
                    299
                ],
                "template": "AutoEcoFarm/AutoEcoFarmFarmland.png",
                "threshold": 0.4
            }
        },
        "pre_delay": 0,
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmTurnAround1"
        ]
    },
    //这里会调用一个Custom节点，计算要将视角拉近目标多少比例所需要的swipe的end坐标
    "_AutoEcoFarmCalculateSwipeTarget": {
        "desc": "生成拉近目标所需要的坐标",
        "recognition": {
            "type": "Custom",
            "param": {
                "custom_recognition": "autoEcoFarmCalculateSwipeTarget",
                "custom_recognition_param": {
                    //将视角拉向目标多少比例
                    "xStepRatio": 0.5,
                    "yStepRatio": 0.5
                },
                "roi": "_AutoEcoFarmTargeRecognition"
            }
        },
        "next": [
            "_AutoEcoFarmSwipeToTarget"
        ]
    },
    //下面是内部节点，不用改
    "_AutoEcoFarmInWorld": {
        "desc": "判断是否在大世界，避免误识别地图上的标点",
        "recognition": {
            "type": "OCR",
            "param": {
                "roi": [
                    32,
                    14,
                    128,
                    41
                ],
                "expected": [
                    "探索|工业",
                    "探索|工業",
                    "(?i)Explore|Factory",
                    "탐색|공업"
                ],
                "threshold": 0.7
            }
        },
        "next": [
            "[Anchor]_AutoEcoFarmSwipeLoopAnchor"
        ]
    },
    "_AutoEcoFarmCheckTarget": {
        "desc": "识别标记状态并判断下一步做什么",
        "max_hit": 20,
        "next": [
            "_AutoEcoFarmTargeInBack",
            "_AutoEcoFarmTargeRecognition",
            "[JumpBack]_AutoEcoFarmSwipeToGround",
            "[JumpBack]_AutoEcoFarmSwipeRandomWithErr",
            "_AutoEcoFarmMoveToTargetErrFindTarget"
        ]
    },
    "_AutoEcoFarmSwipeToTarget": {
        "desc": "转向到识别结果",
        "pre_delay": 0,
        "action": {
            "type": "Swipe",
            "param": {
                "begin": [
                    640,
                    360,
                    1,
                    1
                ],
                "end": "_AutoEcoFarmCalculateSwipeTarget",
                "only_hover": true,
                "duration": 200
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmAltDown"
        ]
    },
    "_AutoEcoFarmTurnAround1": {
        "desc": "长按 S 0.1 秒，转身",
        "action": {
            "type": "LongPressKey",
            "param": {
                "duration": 100,
                "key": 83
            }
        },
        "next": [
            "_AutoEcoFarmTurnAround2"
        ]
    },
    "_AutoEcoFarmTurnAround2": {
        "desc": "按一下鼠标中键",
        "action": {
            "type": "Click",
            "param": {
                "contact": 2
            }
        },
        "next": [
            "_AutoEcoFarmAltUp"
        ]
    },
    "_AutoEcoFarmSwipeRandomWithErr": {
        "desc": "识别不到标记时将标记随便拉一下，尝试解决问题",
        "max_hit": 3,
        "action": {
            "type": "Swipe",
            "param": {
                "begin": [
                    640,
                    360
                ],
                "end": [
                    320,
                    180,
                    640,
                    360
                ],
                "only_hover": true,
                "duration": 1000
            }
        },
        "next": [
            "_AutoEcoFarmAltDown"
        ],
        "focus": {
            "Node.Action.Starting": "识别不到标记，随便转转视角尝试解决问题"
        }
    },
    "_AutoEcoFarmAltDown": {
        "desc": "按下alt",
        "action": {
            "type": "KeyDown",
            "param": {
                "key": 18 //alt键
            }
        },
        "next": [
            "_AutoEcoFarmClick"
        ]
    },
    "_AutoEcoFarmClick": {
        "desc": "按下鼠标左键",
        "pre_delay": 0,
        "action": {
            "type": "Click",
            "param": {
                "target": [
                    640,
                    700,
                    1,
                    1
                ]
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmAltUp"
        ]
    },
    "_AutoEcoFarmAltUp": {
        "desc": "松开alt",
        "pre_delay": 0,
        "action": {
            "type": "KeyUp",
            "param": {
                "key": 18 //alt键
            }
        },
        "post_delay": 0,
        "next": [
            //目标在中央则直接结束该子任务，否则继续循环
            "_AutoEcoFarmTargeInCenter",
            "[Anchor]_AutoEcoFarmSwipeLoopAnchor",
            //循环控制节点超上限后会失效，直接结束任务
            "_AutoEcoFarmMoveToTargetErr"
        ]
    }
}
